Skip to content

Commit 9d9ae19

Browse files
committed
🚿
1 parent 3f61453 commit 9d9ae19

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

examples/svgRandomColoredDots.php

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,7 @@ protected function collectModules(Closure $transform):array{
5252
&& !$this->matrix->checkTypeIn($x, $y, $this->options->excludeFromConnect)
5353
){
5454
// to connect paths we'll redeclare the $M_TYPE_LAYER to data only
55-
$M_TYPE_LAYER = QRMatrix::M_DATA;
56-
57-
if($this->matrix->check($x, $y)){
58-
$M_TYPE_LAYER = QRMatrix::M_DATA_DARK;
59-
}
55+
$M_TYPE_LAYER = $this->matrix->check($x, $y) ? QRMatrix::M_DATA_DARK : QRMatrix::M_DATA;
6056
}
6157

6258
// randomly assign another $M_TYPE_LAYER for the given types
@@ -104,13 +100,14 @@ class RandomDotsOptions extends QROptions{
104100
$options = new RandomDotsOptions;
105101

106102
// our custom dot colors
103+
// adding the IS_DARK flag so that the proper layer css class is assigned
107104
$options->dotColors = [
108-
111 => '#e2453c',
109-
222 => '#e07e39',
110-
333 => '#e5d667',
111-
444 => '#51b95b',
112-
555 => '#1e72b7',
113-
666 => '#6f5ba7',
105+
(111 | QRMatrix::IS_DARK) => '#e2453c',
106+
(222 | QRMatrix::IS_DARK) => '#e07e39',
107+
(333 | QRMatrix::IS_DARK) => '#e5d667',
108+
(444 | QRMatrix::IS_DARK) => '#51b95b',
109+
(555 | QRMatrix::IS_DARK) => '#1e72b7',
110+
(666 | QRMatrix::IS_DARK) => '#6f5ba7',
114111
];
115112

116113
// generate the CSS for the several colored layers
@@ -122,7 +119,6 @@ class RandomDotsOptions extends QROptions{
122119

123120
$options->svgDefs = '
124121
<style><![CDATA[
125-
.light{ fill: #dedede; }
126122
.dark{ fill: #424242; }
127123
'.$layerColors.'
128124
]]></style>';

0 commit comments

Comments
 (0)