Skip to content

Commit 51d7c2b

Browse files
committed
:octocat: added QRMatrix::M_*_DARK constants for convenience
1 parent 428df0d commit 51d7c2b

21 files changed

+270
-251
lines changed

examples/eps.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,32 +23,32 @@
2323
'cachefile' => __DIR__.'/test.eps', // save to file
2424
'moduleValues' => [
2525
// finder
26-
(QRMatrix::M_FINDER | QRMatrix::IS_DARK) => [0, 63, 255], // dark (true)
27-
QRMatrix::M_FINDER => [233, 233, 233], // light (false)
28-
(QRMatrix::M_FINDER_DOT | QRMatrix::IS_DARK) => [0, 63, 255], // finder dot, dark (true)
26+
QRMatrix::M_FINDER_DARK => [0, 63, 255], // dark (true)
27+
QRMatrix::M_FINDER_DOT => [0, 63, 255], // finder dot, dark (true)
28+
QRMatrix::M_FINDER => [233, 233, 233], // light (false)
2929
// alignment
30-
(QRMatrix::M_ALIGNMENT | QRMatrix::IS_DARK) => [255, 0, 255],
31-
QRMatrix::M_ALIGNMENT => [233, 233, 233],
30+
QRMatrix::M_ALIGNMENT_DARK => [255, 0, 255],
31+
QRMatrix::M_ALIGNMENT => [233, 233, 233],
3232
// timing
33-
(QRMatrix::M_TIMING | QRMatrix::IS_DARK) => [255, 0, 0],
34-
QRMatrix::M_TIMING => [233, 233, 233],
33+
QRMatrix::M_TIMING_DARK => [255, 0, 0],
34+
QRMatrix::M_TIMING => [233, 233, 233],
3535
// format
36-
(QRMatrix::M_FORMAT | QRMatrix::IS_DARK) => [67, 159, 84],
37-
QRMatrix::M_FORMAT => [233, 233, 233],
36+
QRMatrix::M_FORMAT_DARK => [67, 159, 84],
37+
QRMatrix::M_FORMAT => [233, 233, 233],
3838
// version
39-
(QRMatrix::M_VERSION | QRMatrix::IS_DARK) => [62, 174, 190],
40-
QRMatrix::M_VERSION => [233, 233, 233],
39+
QRMatrix::M_VERSION_DARK => [62, 174, 190],
40+
QRMatrix::M_VERSION => [233, 233, 233],
4141
// data
42-
(QRMatrix::M_DATA | QRMatrix::IS_DARK) => [0, 0, 0],
43-
QRMatrix::M_DATA => [233, 233, 233],
42+
QRMatrix::M_DATA_DARK => [0, 0, 0],
43+
QRMatrix::M_DATA => [233, 233, 233],
4444
// darkmodule
45-
(QRMatrix::M_DARKMODULE | QRMatrix::IS_DARK) => [0, 0, 0],
45+
QRMatrix::M_DARKMODULE => [0, 0, 0],
4646
// separator
47-
QRMatrix::M_SEPARATOR => [233, 233, 233],
47+
QRMatrix::M_SEPARATOR => [233, 233, 233],
4848
// quietzone
49-
QRMatrix::M_QUIETZONE => [233, 233, 233],
49+
QRMatrix::M_QUIETZONE => [233, 233, 233],
5050
// logo (requires a call to QRMatrix::setLogoSpace()), see QRImageWithLogo
51-
QRMatrix::M_LOGO => [233, 233, 233],
51+
QRMatrix::M_LOGO => [233, 233, 233],
5252
],
5353
]);
5454

examples/fpdf.php

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,29 +22,30 @@
2222
'imageBase64' => false,
2323
'moduleValues' => [
2424
// finder
25-
(QRMatrix::M_FINDER | QRMatrix::IS_DARK) => [0, 63, 255], // dark (true)
26-
QRMatrix::M_FINDER => [255, 255, 255], // light (false), white is the transparency color and is enabled by default
25+
QRMatrix::M_FINDER_DARK => [0, 63, 255], // dark (true)
26+
QRMatrix::M_FINDER_DOT => [0, 63, 255], // finder dot, dark (true)
27+
QRMatrix::M_FINDER => [255, 255, 255], // light (false), white is the transparency color and is enabled by default
2728
// alignment
28-
(QRMatrix::M_ALIGNMENT | QRMatrix::IS_DARK) => [255, 0, 255],
29-
QRMatrix::M_ALIGNMENT => [255, 255, 255],
29+
QRMatrix::M_ALIGNMENT_DARK => [255, 0, 255],
30+
QRMatrix::M_ALIGNMENT => [255, 255, 255],
3031
// timing
31-
(QRMatrix::M_TIMING | QRMatrix::IS_DARK) => [255, 0, 0],
32-
QRMatrix::M_TIMING => [255, 255, 255],
32+
QRMatrix::M_TIMING_DARK => [255, 0, 0],
33+
QRMatrix::M_TIMING => [255, 255, 255],
3334
// format
34-
(QRMatrix::M_FORMAT | QRMatrix::IS_DARK) => [67, 191, 84],
35-
QRMatrix::M_FORMAT => [255, 255, 255],
35+
QRMatrix::M_FORMAT_DARK => [67, 191, 84],
36+
QRMatrix::M_FORMAT => [255, 255, 255],
3637
// version
37-
(QRMatrix::M_VERSION | QRMatrix::IS_DARK) => [62, 174, 190],
38-
QRMatrix::M_VERSION => [255, 255, 255],
38+
QRMatrix::M_VERSION_DARK => [62, 174, 190],
39+
QRMatrix::M_VERSION => [255, 255, 255],
3940
// data
40-
(QRMatrix::M_DATA | QRMatrix::IS_DARK) => [0, 0, 0],
41-
QRMatrix::M_DATA => [255, 255, 255],
41+
QRMatrix::M_DATA_DARK => [0, 0, 0],
42+
QRMatrix::M_DATA => [255, 255, 255],
4243
// darkmodule
43-
(QRMatrix::M_DARKMODULE | QRMatrix::IS_DARK) => [0, 0, 0],
44+
QRMatrix::M_DARKMODULE => [0, 0, 0],
4445
// separator
45-
QRMatrix::M_SEPARATOR => [255, 255, 255],
46+
QRMatrix::M_SEPARATOR => [255, 255, 255],
4647
// quietzone
47-
QRMatrix::M_QUIETZONE => [255, 255, 255],
48+
QRMatrix::M_QUIETZONE => [255, 255, 255],
4849
],
4950
]);
5051

examples/html.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,30 +22,30 @@
2222
'cssClass' => 'qrcode',
2323
'moduleValues' => [
2424
// finder
25-
(QRMatrix::M_FINDER | QRMatrix::IS_DARK) => '#A71111', // dark (true)
26-
QRMatrix::M_FINDER => '#FFBFBF', // light (false)
27-
(QRMatrix::M_FINDER_DOT | QRMatrix::IS_DARK) => '#A71111', // finder dot, dark (true)
25+
QRMatrix::M_FINDER_DARK => '#A71111', // dark (true)
26+
QRMatrix::M_FINDER_DOT => '#A71111', // finder dot, dark (true)
27+
QRMatrix::M_FINDER => '#FFBFBF', // light (false)
2828
// alignment
29-
(QRMatrix::M_ALIGNMENT | QRMatrix::IS_DARK) => '#A70364',
30-
QRMatrix::M_ALIGNMENT => '#FFC9C9',
29+
QRMatrix::M_ALIGNMENT_DARK => '#A70364',
30+
QRMatrix::M_ALIGNMENT => '#FFC9C9',
3131
// timing
32-
(QRMatrix::M_TIMING | QRMatrix::IS_DARK) => '#98005D',
33-
QRMatrix::M_TIMING => '#FFB8E9',
32+
QRMatrix::M_TIMING_DARK => '#98005D',
33+
QRMatrix::M_TIMING => '#FFB8E9',
3434
// format
35-
(QRMatrix::M_FORMAT | QRMatrix::IS_DARK) => '#003804',
36-
QRMatrix::M_FORMAT => '#00FB12',
35+
QRMatrix::M_FORMAT_DARK => '#003804',
36+
QRMatrix::M_FORMAT => '#00FB12',
3737
// version
38-
(QRMatrix::M_VERSION | QRMatrix::IS_DARK) => '#650098',
39-
QRMatrix::M_VERSION => '#E0B8FF',
38+
QRMatrix::M_VERSION_DARK => '#650098',
39+
QRMatrix::M_VERSION => '#E0B8FF',
4040
// data
41-
(QRMatrix::M_DATA | QRMatrix::IS_DARK) => '#4A6000',
42-
QRMatrix::M_DATA => '#ECF9BE',
41+
QRMatrix::M_DATA_DARK => '#4A6000',
42+
QRMatrix::M_DATA => '#ECF9BE',
4343
// darkmodule
44-
(QRMatrix::M_DARKMODULE | QRMatrix::IS_DARK) => '#080063',
44+
QRMatrix::M_DARKMODULE => '#080063',
4545
// separator
46-
QRMatrix::M_SEPARATOR => '#AFBFBF',
46+
QRMatrix::M_SEPARATOR => '#AFBFBF',
4747
// quietzone
48-
QRMatrix::M_QUIETZONE => '#DDDDDD',
48+
QRMatrix::M_QUIETZONE => '#DDDDDD',
4949
],
5050
]);
5151

@@ -58,7 +58,7 @@
5858
<title>QRCode test</title>
5959
<style>
6060
div.qrcode{
61-
margin: 5em;
61+
margin: 1em;
6262
}
6363

6464
/* rows */

examples/image.php

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,45 +17,45 @@
1717
'version' => 7,
1818
'outputType' => QROutputInterface::GDIMAGE_PNG,
1919
'eccLevel' => EccLevel::L,
20-
'scale' => 10,
20+
'scale' => 20,
2121
'imageBase64' => false,
22-
'bgColor' => [200, 200, 200],
22+
'bgColor' => [200, 150, 200],
2323
'imageTransparent' => false,
2424
'drawCircularModules' => true,
2525
'circleRadius' => 0.4,
2626
'keepAsSquare' => [
27-
(QRMatrix::M_FINDER|QRMatrix::IS_DARK),
27+
QRMatrix::M_FINDER_DARK,
2828
QRMatrix::M_FINDER_DOT,
29-
(QRMatrix::M_ALIGNMENT|QRMatrix::IS_DARK),
29+
QRMatrix::M_ALIGNMENT_DARK,
3030
],
3131
'moduleValues' => [
3232
// finder
33-
(QRMatrix::M_FINDER | QRMatrix::IS_DARK) => [0, 63, 255], // dark (true)
34-
QRMatrix::M_FINDER => [233, 233, 233], // light (false), white is the transparency color and is enabled by default
35-
(QRMatrix::M_FINDER_DOT | QRMatrix::IS_DARK) => [0, 63, 255], // finder dot, dark (true)
33+
QRMatrix::M_FINDER_DARK => [0, 63, 255], // dark (true)
34+
QRMatrix::M_FINDER_DOT => [0, 63, 255], // finder dot, dark (true)
35+
QRMatrix::M_FINDER => [233, 233, 233], // light (false), white is the transparency color and is enabled by default
3636
// alignment
37-
(QRMatrix::M_ALIGNMENT | QRMatrix::IS_DARK) => [255, 0, 255],
38-
QRMatrix::M_ALIGNMENT => [233, 233, 233],
37+
QRMatrix::M_ALIGNMENT_DARK => [255, 0, 255],
38+
QRMatrix::M_ALIGNMENT => [233, 233, 233],
3939
// timing
40-
(QRMatrix::M_TIMING | QRMatrix::IS_DARK) => [255, 0, 0],
41-
QRMatrix::M_TIMING => [233, 233, 233],
40+
QRMatrix::M_TIMING_DARK => [255, 0, 0],
41+
QRMatrix::M_TIMING => [233, 233, 233],
4242
// format
43-
(QRMatrix::M_FORMAT | QRMatrix::IS_DARK) => [67, 159, 84],
44-
QRMatrix::M_FORMAT => [233, 233, 233],
43+
QRMatrix::M_FORMAT_DARK => [67, 159, 84],
44+
QRMatrix::M_FORMAT => [233, 233, 233],
4545
// version
46-
(QRMatrix::M_VERSION | QRMatrix::IS_DARK) => [62, 174, 190],
47-
QRMatrix::M_VERSION => [233, 233, 233],
46+
QRMatrix::M_VERSION_DARK => [62, 174, 190],
47+
QRMatrix::M_VERSION => [233, 233, 233],
4848
// data
49-
(QRMatrix::M_DATA | QRMatrix::IS_DARK) => [0, 0, 0],
50-
QRMatrix::M_DATA => [233, 233, 233],
49+
QRMatrix::M_DATA_DARK => [0, 0, 0],
50+
QRMatrix::M_DATA => [233, 233, 233],
5151
// darkmodule
52-
(QRMatrix::M_DARKMODULE | QRMatrix::IS_DARK) => [0, 0, 0],
52+
QRMatrix::M_DARKMODULE => [0, 0, 0],
5353
// separator
54-
QRMatrix::M_SEPARATOR => [233, 233, 233],
54+
QRMatrix::M_SEPARATOR => [233, 233, 233],
5555
// quietzone
56-
QRMatrix::M_QUIETZONE => [233, 233, 233],
56+
QRMatrix::M_QUIETZONE => [233, 233, 233],
5757
// logo (requires a call to QRMatrix::setLogoSpace()), see QRImageWithLogo
58-
QRMatrix::M_LOGO => [233, 233, 233],
58+
QRMatrix::M_LOGO => [233, 233, 233],
5959
],
6060
]);
6161

examples/imagick.php

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,43 +17,44 @@
1717
'version' => 7,
1818
'outputType' => QROutputInterface::IMAGICK,
1919
'eccLevel' => EccLevel::L,
20-
'bgColor' => '#cccccc', // overrides the imageTransparent setting
20+
'imageBase64' => false,
21+
'bgColor' => '#ccccaa', // overrides the imageTransparent setting
2122
'imageTransparent' => true,
2223
'scale' => 20,
2324
'drawLightModules' => true,
2425
'drawCircularModules' => true,
2526
'circleRadius' => 0.4,
2627
'keepAsSquare' => [
27-
(QRMatrix::M_FINDER|QRMatrix::IS_DARK),
28+
QRMatrix::M_FINDER_DARK,
2829
QRMatrix::M_FINDER_DOT,
29-
(QRMatrix::M_ALIGNMENT|QRMatrix::IS_DARK),
30+
QRMatrix::M_ALIGNMENT_DARK,
3031
],
3132
'moduleValues' => [
3233
// finder
33-
(QRMatrix::M_FINDER | QRMatrix::IS_DARK) => '#A71111', // dark (true)
34-
QRMatrix::M_FINDER => '#FFBFBF', // light (false)
35-
(QRMatrix::M_FINDER_DOT | QRMatrix::IS_DARK) => '#A71111', // finder dot, dark (true)
34+
QRMatrix::M_FINDER_DARK => '#A71111', // dark (true)
35+
QRMatrix::M_FINDER_DOT => '#A71111', // finder dot, dark (true)
36+
QRMatrix::M_FINDER => '#FFBFBF', // light (false)
3637
// alignment
37-
(QRMatrix::M_ALIGNMENT | QRMatrix::IS_DARK) => '#A70364',
38-
QRMatrix::M_ALIGNMENT => '#FFC9C9',
38+
QRMatrix::M_ALIGNMENT_DARK => '#A70364',
39+
QRMatrix::M_ALIGNMENT => '#FFC9C9',
3940
// timing
40-
(QRMatrix::M_TIMING | QRMatrix::IS_DARK) => '#98005D',
41-
QRMatrix::M_TIMING => '#FFB8E9',
41+
QRMatrix::M_TIMING_DARK => '#98005D',
42+
QRMatrix::M_TIMING => '#FFB8E9',
4243
// format
43-
(QRMatrix::M_FORMAT | QRMatrix::IS_DARK) => '#003804',
44-
QRMatrix::M_FORMAT => '#CCFB12',
44+
QRMatrix::M_FORMAT_DARK => '#003804',
45+
QRMatrix::M_FORMAT => '#CCFB12',
4546
// version
46-
(QRMatrix::M_VERSION | QRMatrix::IS_DARK) => '#650098',
47-
QRMatrix::M_VERSION => '#E0B8FF',
47+
QRMatrix::M_VERSION_DARK => '#650098',
48+
QRMatrix::M_VERSION => '#E0B8FF',
4849
// data
49-
(QRMatrix::M_DATA | QRMatrix::IS_DARK) => '#4A6000',
50-
QRMatrix::M_DATA => '#ECF9BE',
50+
QRMatrix::M_DATA_DARK => '#4A6000',
51+
QRMatrix::M_DATA => '#ECF9BE',
5152
// darkmodule
52-
(QRMatrix::M_DARKMODULE | QRMatrix::IS_DARK) => '#080063',
53+
QRMatrix::M_DARKMODULE => '#080063',
5354
// separator
54-
QRMatrix::M_SEPARATOR => '#DDDDDD',
55+
QRMatrix::M_SEPARATOR => '#DDDDDD',
5556
// quietzone
56-
QRMatrix::M_QUIETZONE => '#DDDDDD',
57+
QRMatrix::M_QUIETZONE => '#DDDDDD',
5758
],
5859
]);
5960

examples/imagickWithLogo.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@
1010

1111
use chillerlan\QRCode\{QRCode, QRCodeException, QROptions};
1212
use chillerlan\QRCode\Common\EccLevel;
13-
use chillerlan\QRCode\Output\QRImagick;
1413
use chillerlan\QRCode\Data\QRMatrix;
15-
use chillerlan\QRCode\Output\QROutputInterface;
14+
use chillerlan\QRCode\Output\{QRImagick, QROutputInterface};
1615

1716
require_once __DIR__.'/../vendor/autoload.php';
1817

@@ -110,9 +109,9 @@ protected function set_pngLogo(string $pngLogo):void{
110109
'drawCircularModules' => true,
111110
'circleRadius' => 0.4,
112111
'keepAsSquare' => [
113-
(QRMatrix::M_FINDER|QRMatrix::IS_DARK),
112+
QRMatrix::M_FINDER_DARK,
114113
QRMatrix::M_FINDER_DOT,
115-
(QRMatrix::M_ALIGNMENT|QRMatrix::IS_DARK),
114+
QRMatrix::M_ALIGNMENT_DARK,
116115
],
117116
]);
118117

examples/qrcode-interactive.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,32 +18,32 @@
1818

1919
$moduleValues = [
2020
// finder
21-
(QRMatrix::M_FINDER | QRMatrix::IS_DARK) => $_POST['m_finder_dark'],
22-
QRMatrix::M_FINDER => $_POST['m_finder_light'],
23-
(QRMatrix::M_FINDER_DOT | QRMatrix::IS_DARK) => $_POST['m_finder_dot_dark'],
21+
QRMatrix::M_FINDER_DARK => $_POST['m_finder_dark'],
22+
QRMatrix::M_FINDER_DOT => $_POST['m_finder_dot_dark'],
23+
QRMatrix::M_FINDER => $_POST['m_finder_light'],
2424
// alignment
25-
(QRMatrix::M_ALIGNMENT | QRMatrix::IS_DARK) => $_POST['m_alignment_dark'],
26-
QRMatrix::M_ALIGNMENT => $_POST['m_alignment_light'],
25+
QRMatrix::M_ALIGNMENT_DARK => $_POST['m_alignment_dark'],
26+
QRMatrix::M_ALIGNMENT => $_POST['m_alignment_light'],
2727
// timing
28-
(QRMatrix::M_TIMING | QRMatrix::IS_DARK) => $_POST['m_timing_dark'],
29-
QRMatrix::M_TIMING => $_POST['m_timing_light'],
28+
QRMatrix::M_TIMING_DARK => $_POST['m_timing_dark'],
29+
QRMatrix::M_TIMING => $_POST['m_timing_light'],
3030
// format
31-
(QRMatrix::M_FORMAT | QRMatrix::IS_DARK) => $_POST['m_format_dark'],
32-
QRMatrix::M_FORMAT => $_POST['m_format_light'],
31+
QRMatrix::M_FORMAT_DARK => $_POST['m_format_dark'],
32+
QRMatrix::M_FORMAT => $_POST['m_format_light'],
3333
// version
34-
(QRMatrix::M_VERSION | QRMatrix::IS_DARK) => $_POST['m_version_dark'],
35-
QRMatrix::M_VERSION => $_POST['m_version_light'],
34+
QRMatrix::M_VERSION_DARK => $_POST['m_version_dark'],
35+
QRMatrix::M_VERSION => $_POST['m_version_light'],
3636
// data
37-
(QRMatrix::M_DATA | QRMatrix::IS_DARK) => $_POST['m_data_dark'],
38-
QRMatrix::M_DATA => $_POST['m_data_light'],
37+
QRMatrix::M_DATA_DARK => $_POST['m_data_dark'],
38+
QRMatrix::M_DATA => $_POST['m_data_light'],
3939
// darkmodule
40-
(QRMatrix::M_DARKMODULE | QRMatrix::IS_DARK) => $_POST['m_darkmodule_dark'],
40+
QRMatrix::M_DARKMODULE => $_POST['m_darkmodule_dark'],
4141
// separator
42-
QRMatrix::M_SEPARATOR => $_POST['m_separator_light'],
42+
QRMatrix::M_SEPARATOR => $_POST['m_separator_light'],
4343
// quietzone
44-
QRMatrix::M_QUIETZONE => $_POST['m_quietzone_light'],
44+
QRMatrix::M_QUIETZONE => $_POST['m_quietzone_light'],
4545
// logo
46-
QRMatrix::M_LOGO => $_POST['m_logo_light'],
46+
QRMatrix::M_LOGO => $_POST['m_logo_light'],
4747
];
4848

4949
$moduleValues = array_map(function($v){

examples/svg.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@
3434
'connectPaths' => true,
3535
// keep modules of these types as square
3636
'keepAsSquare' => [
37-
(QRMatrix::M_FINDER|QRMatrix::IS_DARK),
37+
QRMatrix::M_FINDER_DARK,
3838
QRMatrix::M_FINDER_DOT,
39-
(QRMatrix::M_ALIGNMENT|QRMatrix::IS_DARK),
39+
QRMatrix::M_ALIGNMENT_DARK,
4040
],
4141
// https://developer.mozilla.org/en-US/docs/Web/SVG/Element/linearGradient
4242
'svgDefs' => '

examples/svgMeltedModules.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
* @see https://github.com/chillerlan/php-qrcode/issues/127
88
*/
99

10+
use chillerlan\QRCode\{QRCode, QROptions};
1011
use chillerlan\QRCode\Common\EccLevel;
1112
use chillerlan\QRCode\Data\QRMatrix;
1213
use chillerlan\QRCode\Output\{QROutputInterface, QRMarkupSVG};
13-
use chillerlan\QRCode\{QRCode, QROptions};
1414

1515
require_once __DIR__.'/../vendor/autoload.php';
1616

@@ -260,8 +260,8 @@ protected function set_meltRadius(float $meltRadius):void{
260260
'outputType' => QROutputInterface::CUSTOM,
261261
'outputInterface' => MeltedSVGQRCodeOutput::class,
262262
'excludeFromConnect' => [
263-
(QRMatrix::M_FINDER|QRMatrix::IS_DARK),
264-
(QRMatrix::M_FINDER_DOT|QRMatrix::IS_DARK),
263+
QRMatrix::M_FINDER_DARK,
264+
QRMatrix::M_FINDER_DOT,
265265
],
266266
'svgDefs' => '
267267
<linearGradient id="rainbow" x1="100%" y2="100%">

0 commit comments

Comments
 (0)