Skip to content

color QR code #195

Answered by codemasher
mrdraft asked this question in Q&A
Apr 14, 2023 · 1 comments · 10 replies
Discussion options

You must be logged in to vote

Ok, the issue I'm seeing is that the options array is not properly constructed:

 $moduleValues = ['moduleValues' => [
    // ...
 ]];
 
 $this->options = new QROptions([
            $moduleValues
]);

This will create an array with a numerical key at the root and it will contain one element, moduleValues, that contains the actual value.
Instead it should be:

 $moduleValues =  [
    // ...
 ];
 
 $this->options = new QROptions([
    // ...
    'moduleValues' => $moduleValues,
]);

I fixed that and ran the code locally and the matrix appeared blue.

use chillerlan\QRCode\Data\QRCodeDataException;
use chillerlan\QRCode\Data\QRMatrix;
use chillerlan\QRCode\Output\QRImage;
use chillerlan\QRCode\Q…

Replies: 1 comment 10 replies

Comment options

You must be logged in to vote
10 replies
@mrdraft
Comment options

@codemasher
Comment options

@mrdraft
Comment options

@codemasher
Comment options

Answer selected by mrdraft
@mrdraft
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants