You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Documentation for RendererStyle and Fill to set foregroundColor and backgroundColor #91
Do we have more thorough documentation available beyond what's in README.md? I've searched up and down and most of the examples I find elsewhere seem to rely on the previous version and do not work with 2.0.0.
For instance, I'd like to change the foreground and background colors of the QR code. The constructor for RendererStyle in RendererStyle.php appears to provide access for this in the fifth argument. In the Fill constructor in Fill.php there are references to foregroundColor and backgroundColor.
However, I cannot determine the combination of use statements, classes, and method calls required to actually set the colors. May we have a bit of documentation added to README.md or the wiki demonstrating this functionality?
Likewise, is there information about setting the bit-depth of generated PNGs? The default output is not compatible with FPDF.
I am struggling with using modules and gradients, among other things. Ive managed to use background, foreground and eye colors, but that's about it.
Documentation and working examples would be very welcome.
My code for now:
<?php
require 'vendor/autoload.php';
use BaconQrCode\Renderer\ImageRenderer;
use BaconQrCode\Renderer\Image\ImagickImageBackEnd;
use BaconQrCode\Renderer\RendererStyle\RendererStyle;
use BaconQrCode\Renderer\RendererStyle\Fill;
use BaconQrCode\Writer;
$backgroundColor = new \BaconQrCode\Renderer\Color\Rgb(255, 255, 255);
$foregroundColor = new \BaconQrCode\Renderer\Color\Rgb(1, 101, 185);
$eyeColor = new \BaconQrCode\Renderer\Color\Rgb(254,145,2);
$eyeFill = new BaconQrCode\Renderer\RendererStyle\EyeFill($eyeColor, $eyeColor);
$fill = Fill::withForegroundColor($backgroundColor, $foregroundColor, $eyeFill, $eyeFill, $eyeFill);
$renderer = new ImageRenderer(
new RendererStyle(300, 0, null, null, $fill),
new ImagickImageBackEnd()
);
$writer = new Writer($renderer);
$writer->writeFile('https://www.youtube.com/watch?v=EKLnEQWOYwI', './temp/qrcode.png');
?>
<img src="/temp/qrcode.png" alt="">
Reacted by Lrnt, Patrik Horváth, Adam and Marlo Corridor
Activity
joldnl commentedon Sep 22, 2021
I agree, but I also found some nice example codes:
https://hotexamples.com/examples/-/BaconQrCode%255CWriter/-/php-baconqrcode%255cwriter-class-examples.html
DASPRiD commentedon Sep 22, 2021
I'm open to accepting pull requests.
joldnl commentedon Sep 22, 2021
I am struggling with using modules and gradients, among other things. Ive managed to use background, foreground and eye colors, but that's about it.
Documentation and working examples would be very welcome.
My code for now: