@@ -26,43 +26,43 @@ class QRMatrix{
26
26
/** @var int */
27
27
public const M_NULL = 0b000000000000 ;
28
28
/** @var int */
29
- public const M_DARKMODULE = ( 0b000000000001 | self :: IS_DARK ) ;
29
+ public const M_DARKMODULE = 0b100000000001 ;
30
30
/** @var int */
31
31
public const M_DATA = 0b000000000010 ;
32
32
/** @var int */
33
- public const M_DATA_DARK = ( self :: M_DATA | self :: IS_DARK ) ;
33
+ public const M_DATA_DARK = 0b100000000010 ;
34
34
/** @var int */
35
35
public const M_FINDER = 0b000000000100 ;
36
36
/** @var int */
37
- public const M_FINDER_DARK = ( self :: M_FINDER | self :: IS_DARK ) ;
37
+ public const M_FINDER_DARK = 0b100000000100 ;
38
38
/** @var int */
39
39
public const M_SEPARATOR = 0b000000001000 ;
40
40
/** @var int */
41
41
public const M_ALIGNMENT = 0b000000010000 ;
42
42
/** @var int */
43
- public const M_ALIGNMENT_DARK = ( self :: M_ALIGNMENT | self :: IS_DARK ) ;
43
+ public const M_ALIGNMENT_DARK = 0b100000010000 ;
44
44
/** @var int */
45
45
public const M_TIMING = 0b000000100000 ;
46
46
/** @var int */
47
- public const M_TIMING_DARK = ( self :: M_TIMING | self :: IS_DARK ) ;
47
+ public const M_TIMING_DARK = 0b100000100000 ;
48
48
/** @var int */
49
49
public const M_FORMAT = 0b000001000000 ;
50
50
/** @var int */
51
- public const M_FORMAT_DARK = ( self :: M_FORMAT | self :: IS_DARK ) ;
51
+ public const M_FORMAT_DARK = 0b100001000000 ;
52
52
/** @var int */
53
53
public const M_VERSION = 0b000010000000 ;
54
54
/** @var int */
55
- public const M_VERSION_DARK = ( self :: M_VERSION | self :: IS_DARK ) ;
55
+ public const M_VERSION_DARK = 0b100010000000 ;
56
56
/** @var int */
57
57
public const M_QUIETZONE = 0b000100000000 ;
58
58
/** @var int */
59
59
public const M_LOGO = 0b001000000000 ;
60
60
/** @var int */
61
- public const M_FINDER_DOT = ( 0b010000000000 | self :: IS_DARK ) ;
61
+ public const M_FINDER_DOT = 0b110000000000 ;
62
62
/** @var int */
63
63
public const M_TEST = 0b011111111111 ;
64
64
/** @var int */
65
- public const M_TEST_DARK = ( self :: M_TEST | self :: IS_DARK ) ;
65
+ public const M_TEST_DARK = 0b111111111111 ;
66
66
67
67
/**
68
68
* Map of flag => coord
@@ -584,6 +584,9 @@ public function setQuietZone(int $quietZoneSize):self{
584
584
* using $startX and $startY. If either of these are null, the logo space will be centered in that direction.
585
585
* ECC level "H" (30%) is required.
586
586
*
587
+ * The coordinates of $startX and $startY do not include the quiet zone:
588
+ * [0, 0] is always the top left module of the top left finder pattern, negative values go into the quiet zone top and left.
589
+ *
587
590
* Please note that adding a logo space minimizes the error correction capacity of the QR Code and
588
591
* created images may become unreadable, especially when printed with a chance to receive damage.
589
592
* Please test thoroughly before using this feature in production.
@@ -643,18 +646,18 @@ public function setLogoSpace(int $width, int $height = null, int $startX = null,
643
646
// determine start coordinates
644
647
$ startX = ((($ startX !== null ) ? $ startX : ($ length - $ width ) / 2 ) + $ qz );
645
648
$ startY = ((($ startY !== null ) ? $ startY : ($ length - $ height ) / 2 ) + $ qz );
649
+ $ endX = ($ startX + $ width );
650
+ $ endY = ($ startY + $ height );
646
651
647
652
// clear the space
648
- for ($ y = 0 ; $ y < $ this -> moduleCount ; $ y ++){
649
- for ($ x = 0 ; $ x < $ this -> moduleCount ; $ x ++){
653
+ for ($ y = $ startY ; $ y < $ endY ; $ y ++){
654
+ for ($ x = $ startX ; $ x < $ endX ; $ x ++){
650
655
// out of bounds, skip
651
656
if ($ x < $ start || $ y < $ start ||$ x >= $ end || $ y >= $ end ){
652
657
continue ;
653
658
}
654
- // a match
655
- if ($ x >= $ startX && $ x < ($ startX + $ width ) && $ y >= $ startY && $ y < ($ startY + $ height )){
656
- $ this ->set ($ x , $ y , false , $ this ::M_LOGO );
657
- }
659
+
660
+ $ this ->set ($ x , $ y , false , $ this ::M_LOGO );
658
661
}
659
662
}
660
663
0 commit comments