Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation for RendererStyle and Fill to set foregroundColor and backgroundColor #91

Open
danielmreck opened this issue Sep 18, 2021 · 3 comments
Labels

Comments

@danielmreck
Copy link

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.

Thank you.

@joldnl
Copy link

joldnl commented Sep 22, 2021

@DASPRiD
Copy link
Member

DASPRiD commented Sep 22, 2021

I'm open to accepting pull requests.

@joldnl
Copy link

joldnl commented 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:

<?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="">

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants