mirror of
https://github.com/chillerlan/php-qrcode.git
synced 2026-10-10 22:06:01 +00:00
:octocat: allow coloring the finder pattern dot individually (#52)
This commit is contained in:
+14
-6
@@ -48,6 +48,8 @@ final class QRMatrix{
|
||||
/** @var int */
|
||||
public const M_LOGO = 0x14;
|
||||
/** @var int */
|
||||
public const M_FINDER_DOT = 0x16;
|
||||
/** @var int */
|
||||
public const M_TEST = 0xff;
|
||||
|
||||
/**
|
||||
@@ -369,12 +371,18 @@ final class QRMatrix{
|
||||
foreach($pos as $c){
|
||||
for($y = 0; $y < 7; $y++){
|
||||
for($x = 0; $x < 7; $x++){
|
||||
$this->set(
|
||||
$c[0] + $y,
|
||||
$c[1] + $x,
|
||||
!(($x > 0 && $x < 6 && ($y === 1 || $y === 5)) || ($y > 0 && $y < 6 && ($x === 1 || $x === 5))),
|
||||
$this::M_FINDER
|
||||
);
|
||||
// outer (dark) 7*7 square
|
||||
if($x === 0 || $x === 6 || $y === 0 || $y === 6){
|
||||
$this->set($c[0] + $y, $c[1] + $x, true, $this::M_FINDER);
|
||||
}
|
||||
// inner (light) 5*5 square
|
||||
elseif($x === 1 || $x === 5 || $y === 1 || $y === 5){
|
||||
$this->set($c[0] + $y, $c[1] + $x, false, $this::M_FINDER);
|
||||
}
|
||||
// 3*3 dot
|
||||
else{
|
||||
$this->set($c[0] + $y, $c[1] + $x, true, $this::M_FINDER_DOT);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ interface QROutputInterface{
|
||||
QRMatrix::M_TIMING << 8 => true, // 3072
|
||||
QRMatrix::M_FORMAT << 8 => true, // 3584
|
||||
QRMatrix::M_VERSION << 8 => true, // 4096
|
||||
QRMatrix::M_FINDER_DOT << 8 => true, // 5632
|
||||
QRMatrix::M_TEST << 8 => true, // 65280
|
||||
];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user