@@ -26,43 +26,43 @@ class QRMatrix{
2626 /** @var int */
2727 public const M_NULL = 0b000000000000 ;
2828 /** @var int */
29- public const M_DARKMODULE = ( 0b000000000001 | self :: IS_DARK ) ;
29+ public const M_DARKMODULE = 0b100000000001 ;
3030 /** @var int */
3131 public const M_DATA = 0b000000000010 ;
3232 /** @var int */
33- public const M_DATA_DARK = ( self :: M_DATA | self :: IS_DARK ) ;
33+ public const M_DATA_DARK = 0b100000000010 ;
3434 /** @var int */
3535 public const M_FINDER = 0b000000000100 ;
3636 /** @var int */
37- public const M_FINDER_DARK = ( self :: M_FINDER | self :: IS_DARK ) ;
37+ public const M_FINDER_DARK = 0b100000000100 ;
3838 /** @var int */
3939 public const M_SEPARATOR = 0b000000001000 ;
4040 /** @var int */
4141 public const M_ALIGNMENT = 0b000000010000 ;
4242 /** @var int */
43- public const M_ALIGNMENT_DARK = ( self :: M_ALIGNMENT | self :: IS_DARK ) ;
43+ public const M_ALIGNMENT_DARK = 0b100000010000 ;
4444 /** @var int */
4545 public const M_TIMING = 0b000000100000 ;
4646 /** @var int */
47- public const M_TIMING_DARK = ( self :: M_TIMING | self :: IS_DARK ) ;
47+ public const M_TIMING_DARK = 0b100000100000 ;
4848 /** @var int */
4949 public const M_FORMAT = 0b000001000000 ;
5050 /** @var int */
51- public const M_FORMAT_DARK = ( self :: M_FORMAT | self :: IS_DARK ) ;
51+ public const M_FORMAT_DARK = 0b100001000000 ;
5252 /** @var int */
5353 public const M_VERSION = 0b000010000000 ;
5454 /** @var int */
55- public const M_VERSION_DARK = ( self :: M_VERSION | self :: IS_DARK ) ;
55+ public const M_VERSION_DARK = 0b100010000000 ;
5656 /** @var int */
5757 public const M_QUIETZONE = 0b000100000000 ;
5858 /** @var int */
5959 public const M_LOGO = 0b001000000000 ;
6060 /** @var int */
61- public const M_FINDER_DOT = ( 0b010000000000 | self :: IS_DARK ) ;
61+ public const M_FINDER_DOT = 0b110000000000 ;
6262 /** @var int */
6363 public const M_TEST = 0b011111111111 ;
6464 /** @var int */
65- public const M_TEST_DARK = ( self :: M_TEST | self :: IS_DARK ) ;
65+ public const M_TEST_DARK = 0b111111111111 ;
6666
6767 /**
6868 * Map of flag => coord
@@ -584,6 +584,9 @@ public function setQuietZone(int $quietZoneSize):self{
584584 * using $startX and $startY. If either of these are null, the logo space will be centered in that direction.
585585 * ECC level "H" (30%) is required.
586586 *
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+ *
587590 * Please note that adding a logo space minimizes the error correction capacity of the QR Code and
588591 * created images may become unreadable, especially when printed with a chance to receive damage.
589592 * Please test thoroughly before using this feature in production.
@@ -643,18 +646,18 @@ public function setLogoSpace(int $width, int $height = null, int $startX = null,
643646 // determine start coordinates
644647 $ startX = ((($ startX !== null ) ? $ startX : ($ length - $ width ) / 2 ) + $ qz );
645648 $ startY = ((($ startY !== null ) ? $ startY : ($ length - $ height ) / 2 ) + $ qz );
649+ $ endX = ($ startX + $ width );
650+ $ endY = ($ startY + $ height );
646651
647652 // 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 ++){
650655 // out of bounds, skip
651656 if ($ x < $ start || $ y < $ start ||$ x >= $ end || $ y >= $ end ){
652657 continue ;
653658 }
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 );
658661 }
659662 }
660663
0 commit comments