mirror of
https://github.com/chillerlan/php-qrcode.git
synced 2026-08-30 03:58:28 +00:00
:octocat: added QRMatrix::M* constants for dark values, removed M_TEST
This commit is contained in:
+16
-16
@@ -18,30 +18,30 @@ $options = new QROptions([
|
||||
'imageBase64' => false,
|
||||
'moduleValues' => [
|
||||
// finder
|
||||
(QRMatrix::M_FINDER << 8) => [0, 63, 255], // dark (true)
|
||||
(QRMatrix::M_FINDER_DOT << 8) => [0, 63, 255],
|
||||
QRMatrix::M_FINDER => [255, 255, 255], // light (false), white is the transparency color and is enabled by default
|
||||
QRMatrix::M_FINDER_DARK => [0, 63, 255], // dark (true)
|
||||
QRMatrix::M_FINDER_DOT => [0, 63, 255],
|
||||
QRMatrix::M_FINDER => [255, 255, 255], // light (false), white is the transparency color and is enabled by default
|
||||
// alignment
|
||||
(QRMatrix::M_ALIGNMENT << 8) => [255, 0, 255],
|
||||
QRMatrix::M_ALIGNMENT => [255, 255, 255],
|
||||
QRMatrix::M_ALIGNMENT_DARK => [255, 0, 255],
|
||||
QRMatrix::M_ALIGNMENT => [255, 255, 255],
|
||||
// timing
|
||||
(QRMatrix::M_TIMING << 8) => [255, 0, 0],
|
||||
QRMatrix::M_TIMING => [255, 255, 255],
|
||||
QRMatrix::M_TIMING_DARK => [255, 0, 0],
|
||||
QRMatrix::M_TIMING => [255, 255, 255],
|
||||
// format
|
||||
(QRMatrix::M_FORMAT << 8) => [67, 191, 84],
|
||||
QRMatrix::M_FORMAT => [255, 255, 255],
|
||||
QRMatrix::M_FORMAT_DARK => [67, 191, 84],
|
||||
QRMatrix::M_FORMAT => [255, 255, 255],
|
||||
// version
|
||||
(QRMatrix::M_VERSION << 8) => [62, 174, 190],
|
||||
QRMatrix::M_VERSION => [255, 255, 255],
|
||||
QRMatrix::M_VERSION_DARK => [62, 174, 190],
|
||||
QRMatrix::M_VERSION => [255, 255, 255],
|
||||
// data
|
||||
(QRMatrix::M_DATA << 8) => [0, 0, 0],
|
||||
QRMatrix::M_DATA => [255, 255, 255],
|
||||
QRMatrix::M_DATA_DARK => [0, 0, 0],
|
||||
QRMatrix::M_DATA => [255, 255, 255],
|
||||
// darkmodule
|
||||
(QRMatrix::M_DARKMODULE << 8) => [0, 0, 0],
|
||||
QRMatrix::M_DARKMODULE => [0, 0, 0],
|
||||
// separator
|
||||
QRMatrix::M_SEPARATOR => [255, 255, 255],
|
||||
QRMatrix::M_SEPARATOR => [255, 255, 255],
|
||||
// quietzone
|
||||
QRMatrix::M_QUIETZONE => [255, 255, 255],
|
||||
QRMatrix::M_QUIETZONE => [255, 255, 255],
|
||||
],
|
||||
]);
|
||||
|
||||
|
||||
+16
-16
@@ -18,30 +18,30 @@ $options = new QROptions([
|
||||
'eccLevel' => QRCode::ECC_L,
|
||||
'moduleValues' => [
|
||||
// finder
|
||||
(QRMatrix::M_FINDER << 8) => '#A71111', // dark (true)
|
||||
(QRMatrix::M_FINDER_DOT << 8) => '#A71111',
|
||||
QRMatrix::M_FINDER => '#FFBFBF', // light (false)
|
||||
QRMatrix::M_FINDER_DARK => '#A71111', // dark (true)
|
||||
QRMatrix::M_FINDER_DOT => '#A71111',
|
||||
QRMatrix::M_FINDER => '#FFBFBF', // light (false)
|
||||
// alignment
|
||||
(QRMatrix::M_ALIGNMENT << 8) => '#A70364',
|
||||
QRMatrix::M_ALIGNMENT => '#FFC9C9',
|
||||
QRMatrix::M_ALIGNMENT_DARK => '#A70364',
|
||||
QRMatrix::M_ALIGNMENT => '#FFC9C9',
|
||||
// timing
|
||||
(QRMatrix::M_TIMING << 8) => '#98005D',
|
||||
QRMatrix::M_TIMING => '#FFB8E9',
|
||||
QRMatrix::M_TIMING_DARK => '#98005D',
|
||||
QRMatrix::M_TIMING => '#FFB8E9',
|
||||
// format
|
||||
(QRMatrix::M_FORMAT << 8) => '#003804',
|
||||
QRMatrix::M_FORMAT => '#00FB12',
|
||||
QRMatrix::M_FORMAT_DARK => '#003804',
|
||||
QRMatrix::M_FORMAT => '#00FB12',
|
||||
// version
|
||||
(QRMatrix::M_VERSION << 8) => '#650098',
|
||||
QRMatrix::M_VERSION => '#E0B8FF',
|
||||
QRMatrix::M_VERSION_DARK => '#650098',
|
||||
QRMatrix::M_VERSION => '#E0B8FF',
|
||||
// data
|
||||
(QRMatrix::M_DATA << 8) => '#4A6000',
|
||||
QRMatrix::M_DATA => '#ECF9BE',
|
||||
QRMatrix::M_DATA_DARK => '#4A6000',
|
||||
QRMatrix::M_DATA => '#ECF9BE',
|
||||
// darkmodule
|
||||
(QRMatrix::M_DARKMODULE << 8) => '#080063',
|
||||
QRMatrix::M_DARKMODULE => '#080063',
|
||||
// separator
|
||||
QRMatrix::M_SEPARATOR => '#AFBFBF',
|
||||
QRMatrix::M_SEPARATOR => '#AFBFBF',
|
||||
// quietzone
|
||||
QRMatrix::M_QUIETZONE => '#FFFFFF',
|
||||
QRMatrix::M_QUIETZONE => '#FFFFFF',
|
||||
],
|
||||
]);
|
||||
|
||||
|
||||
+17
-17
@@ -19,32 +19,32 @@ $options = new QROptions([
|
||||
'imageBase64' => false,
|
||||
'moduleValues' => [
|
||||
// finder
|
||||
(QRMatrix::M_FINDER << 8) => [0, 63, 255], // dark (true)
|
||||
(QRMatrix::M_FINDER_DOT << 8) => [241, 28, 163], // finder dot, dark (true)
|
||||
QRMatrix::M_FINDER => [255, 255, 255], // light (false), white is the transparency color and is enabled by default
|
||||
QRMatrix::M_FINDER_DARK => [0, 63, 255], // dark (true)
|
||||
QRMatrix::M_FINDER_DOT => [241, 28, 163], // finder dot, dark (true)
|
||||
QRMatrix::M_FINDER => [255, 255, 255], // light (false), white is the transparency color and is enabled by default
|
||||
// alignment
|
||||
(QRMatrix::M_ALIGNMENT << 8) => [255, 0, 255],
|
||||
QRMatrix::M_ALIGNMENT => [255, 255, 255],
|
||||
QRMatrix::M_ALIGNMENT_DARK => [255, 0, 255],
|
||||
QRMatrix::M_ALIGNMENT => [255, 255, 255],
|
||||
// timing
|
||||
(QRMatrix::M_TIMING << 8) => [255, 0, 0],
|
||||
QRMatrix::M_TIMING => [255, 255, 255],
|
||||
QRMatrix::M_TIMING_DARK => [255, 0, 0],
|
||||
QRMatrix::M_TIMING => [255, 255, 255],
|
||||
// format
|
||||
(QRMatrix::M_FORMAT << 8) => [67, 99, 84],
|
||||
QRMatrix::M_FORMAT => [255, 255, 255],
|
||||
QRMatrix::M_FORMAT_DARK => [67, 99, 84],
|
||||
QRMatrix::M_FORMAT => [255, 255, 255],
|
||||
// version
|
||||
(QRMatrix::M_VERSION << 8) => [62, 174, 190],
|
||||
QRMatrix::M_VERSION => [255, 255, 255],
|
||||
QRMatrix::M_VERSION_DARK => [62, 174, 190],
|
||||
QRMatrix::M_VERSION => [255, 255, 255],
|
||||
// data
|
||||
(QRMatrix::M_DATA << 8) => [0, 0, 0],
|
||||
QRMatrix::M_DATA => [255, 255, 255],
|
||||
QRMatrix::M_DATA_DARK => [0, 0, 0],
|
||||
QRMatrix::M_DATA => [255, 255, 255],
|
||||
// darkmodule
|
||||
(QRMatrix::M_DARKMODULE << 8) => [0, 0, 0],
|
||||
QRMatrix::M_DARKMODULE => [0, 0, 0],
|
||||
// separator
|
||||
QRMatrix::M_SEPARATOR => [255, 255, 255],
|
||||
QRMatrix::M_SEPARATOR => [255, 255, 255],
|
||||
// quietzone
|
||||
QRMatrix::M_QUIETZONE => [255, 255, 255],
|
||||
QRMatrix::M_QUIETZONE => [255, 255, 255],
|
||||
// logo (requires a call to QRMatrix::setLogoSpace())
|
||||
QRMatrix::M_LOGO => [255, 255, 255],
|
||||
QRMatrix::M_LOGO => [255, 255, 255],
|
||||
],
|
||||
]);
|
||||
|
||||
|
||||
+16
-16
@@ -18,30 +18,30 @@ $options = new QROptions([
|
||||
'scale' => 5,
|
||||
'moduleValues' => [
|
||||
// finder
|
||||
(QRMatrix::M_FINDER << 8) => '#A71111', // dark (true)
|
||||
(QRMatrix::M_FINDER_DOT << 8) => '#A71111',
|
||||
QRMatrix::M_FINDER => '#FFBFBF', // light (false)
|
||||
QRMatrix::M_FINDER_DARK => '#A71111', // dark (true)
|
||||
QRMatrix::M_FINDER_DOT => '#A71111',
|
||||
QRMatrix::M_FINDER => '#FFBFBF', // light (false)
|
||||
// alignment
|
||||
(QRMatrix::M_ALIGNMENT << 8) => '#A70364',
|
||||
QRMatrix::M_ALIGNMENT => '#FFC9C9',
|
||||
QRMatrix::M_ALIGNMENT_DARK => '#A70364',
|
||||
QRMatrix::M_ALIGNMENT => '#FFC9C9',
|
||||
// timing
|
||||
(QRMatrix::M_TIMING << 8) => '#98005D',
|
||||
QRMatrix::M_TIMING => '#FFB8E9',
|
||||
QRMatrix::M_TIMING_DARK => '#98005D',
|
||||
QRMatrix::M_TIMING => '#FFB8E9',
|
||||
// format
|
||||
(QRMatrix::M_FORMAT << 8) => '#003804',
|
||||
QRMatrix::M_FORMAT => '#00FB12',
|
||||
QRMatrix::M_FORMAT_DARK => '#003804',
|
||||
QRMatrix::M_FORMAT => '#00FB12',
|
||||
// version
|
||||
(QRMatrix::M_VERSION << 8) => '#650098',
|
||||
QRMatrix::M_VERSION => '#E0B8FF',
|
||||
QRMatrix::M_VERSION_DARK => '#650098',
|
||||
QRMatrix::M_VERSION => '#E0B8FF',
|
||||
// data
|
||||
(QRMatrix::M_DATA << 8) => '#4A6000',
|
||||
QRMatrix::M_DATA => '#ECF9BE',
|
||||
QRMatrix::M_DATA_DARK => '#4A6000',
|
||||
QRMatrix::M_DATA => '#ECF9BE',
|
||||
// darkmodule
|
||||
(QRMatrix::M_DARKMODULE << 8) => '#080063',
|
||||
QRMatrix::M_DARKMODULE => '#080063',
|
||||
// separator
|
||||
QRMatrix::M_SEPARATOR => '#DDDDDD',
|
||||
QRMatrix::M_SEPARATOR => '#DDDDDD',
|
||||
// quietzone
|
||||
QRMatrix::M_QUIETZONE => '#DDDDDD',
|
||||
QRMatrix::M_QUIETZONE => '#DDDDDD',
|
||||
],
|
||||
]);
|
||||
|
||||
|
||||
@@ -17,30 +17,30 @@ try{
|
||||
|
||||
$moduleValues = [
|
||||
// finder
|
||||
(QRMatrix::M_FINDER << 8) => $_POST['m_finder_dark'],
|
||||
(QRMatrix::M_FINDER_DOT << 8) => $_POST['m_finder_dark'],
|
||||
QRMatrix::M_FINDER => $_POST['m_finder_light'],
|
||||
QRMatrix::M_FINDER_DARK => $_POST['m_finder_dark'],
|
||||
QRMatrix::M_FINDER_DOT => $_POST['m_finder_dark'],
|
||||
QRMatrix::M_FINDER => $_POST['m_finder_light'],
|
||||
// alignment
|
||||
(QRMatrix::M_ALIGNMENT << 8) => $_POST['m_alignment_dark'],
|
||||
QRMatrix::M_ALIGNMENT => $_POST['m_alignment_light'],
|
||||
QRMatrix::M_ALIGNMENT_DARK => $_POST['m_alignment_dark'],
|
||||
QRMatrix::M_ALIGNMENT => $_POST['m_alignment_light'],
|
||||
// timing
|
||||
(QRMatrix::M_TIMING << 8) => $_POST['m_timing_dark'],
|
||||
QRMatrix::M_TIMING => $_POST['m_timing_light'],
|
||||
QRMatrix::M_TIMING_DARK => $_POST['m_timing_dark'],
|
||||
QRMatrix::M_TIMING => $_POST['m_timing_light'],
|
||||
// format
|
||||
(QRMatrix::M_FORMAT << 8) => $_POST['m_format_dark'],
|
||||
QRMatrix::M_FORMAT => $_POST['m_format_light'],
|
||||
QRMatrix::M_FORMAT_DARK => $_POST['m_format_dark'],
|
||||
QRMatrix::M_FORMAT => $_POST['m_format_light'],
|
||||
// version
|
||||
(QRMatrix::M_VERSION << 8) => $_POST['m_version_dark'],
|
||||
QRMatrix::M_VERSION => $_POST['m_version_light'],
|
||||
QRMatrix::M_VERSION_DARK => $_POST['m_version_dark'],
|
||||
QRMatrix::M_VERSION => $_POST['m_version_light'],
|
||||
// data
|
||||
(QRMatrix::M_DATA << 8) => $_POST['m_data_dark'],
|
||||
QRMatrix::M_DATA => $_POST['m_data_light'],
|
||||
QRMatrix::M_DATA_DARK => $_POST['m_data_dark'],
|
||||
QRMatrix::M_DATA => $_POST['m_data_light'],
|
||||
// darkmodule
|
||||
(QRMatrix::M_DARKMODULE << 8) => $_POST['m_darkmodule_dark'],
|
||||
QRMatrix::M_DARKMODULE => $_POST['m_darkmodule_dark'],
|
||||
// separator
|
||||
QRMatrix::M_SEPARATOR => $_POST['m_separator_light'],
|
||||
QRMatrix::M_SEPARATOR => $_POST['m_separator_light'],
|
||||
// quietzone
|
||||
QRMatrix::M_QUIETZONE => $_POST['m_quietzone_light'],
|
||||
QRMatrix::M_QUIETZONE => $_POST['m_quietzone_light'],
|
||||
];
|
||||
|
||||
$moduleValues = array_map(function($v){
|
||||
|
||||
+17
-17
@@ -20,7 +20,7 @@ $options = new QROptions([
|
||||
'outputType' => QRCode::OUTPUT_MARKUP_SVG,
|
||||
'imageBase64' => false,
|
||||
'eccLevel' => QRCode::ECC_L,
|
||||
'svgViewBoxSize' => 530,
|
||||
# 'svgViewBoxSize' => 530,
|
||||
'addQuietzone' => true,
|
||||
'svgOpacity' => 1.0,
|
||||
'svgDefs' => '
|
||||
@@ -35,30 +35,30 @@ $options = new QROptions([
|
||||
<style>rect{shape-rendering:crispEdges}</style>',
|
||||
'moduleValues' => [
|
||||
// finder
|
||||
(QRMatrix::M_FINDER << 8) => 'url(#g1)', // dark (true)
|
||||
(QRMatrix::M_FINDER_DOT << 8) => 'url(#g1)',
|
||||
QRMatrix::M_FINDER => '#fff', // light (false)
|
||||
QRMatrix::M_FINDER_DARK => 'url(#g1)', // dark (true)
|
||||
QRMatrix::M_FINDER_DOT => 'url(#g1)',
|
||||
QRMatrix::M_FINDER => '#fff', // light (false)
|
||||
// alignment
|
||||
(QRMatrix::M_ALIGNMENT << 8) => 'url(#g1)',
|
||||
QRMatrix::M_ALIGNMENT => '#fff',
|
||||
QRMatrix::M_ALIGNMENT_DARK => 'url(#g1)',
|
||||
QRMatrix::M_ALIGNMENT => '#fff',
|
||||
// timing
|
||||
(QRMatrix::M_TIMING << 8) => 'url(#g1)',
|
||||
QRMatrix::M_TIMING => '#fff',
|
||||
QRMatrix::M_TIMING_DARK => 'url(#g1)',
|
||||
QRMatrix::M_TIMING => '#fff',
|
||||
// format
|
||||
(QRMatrix::M_FORMAT << 8) => 'url(#g1)',
|
||||
QRMatrix::M_FORMAT => '#fff',
|
||||
QRMatrix::M_FORMAT_DARK => 'url(#g1)',
|
||||
QRMatrix::M_FORMAT => '#fff',
|
||||
// version
|
||||
(QRMatrix::M_VERSION << 8) => 'url(#g1)',
|
||||
QRMatrix::M_VERSION => '#fff',
|
||||
QRMatrix::M_VERSION_DARK => 'url(#g1)',
|
||||
QRMatrix::M_VERSION => '#fff',
|
||||
// data
|
||||
(QRMatrix::M_DATA << 8) => 'url(#g2)',
|
||||
QRMatrix::M_DATA => '#fff',
|
||||
QRMatrix::M_DATA_DARK => 'url(#g2)',
|
||||
QRMatrix::M_DATA => '#fff',
|
||||
// darkmodule
|
||||
(QRMatrix::M_DARKMODULE << 8) => 'url(#g1)',
|
||||
QRMatrix::M_DARKMODULE => 'url(#g1)',
|
||||
// separator
|
||||
QRMatrix::M_SEPARATOR => '#fff',
|
||||
QRMatrix::M_SEPARATOR => '#fff',
|
||||
// quietzone
|
||||
QRMatrix::M_QUIETZONE => '#fff',
|
||||
QRMatrix::M_QUIETZONE => '#fff',
|
||||
],
|
||||
]);
|
||||
|
||||
|
||||
+56
-17
@@ -25,32 +25,71 @@ use function array_fill, array_key_exists, array_push, array_unshift, count, flo
|
||||
*/
|
||||
final class QRMatrix{
|
||||
|
||||
/*
|
||||
* special values
|
||||
*/
|
||||
|
||||
/** @var int */
|
||||
public const M_NULL = 0x00;
|
||||
public const M_NULL = 0x00;
|
||||
/** @var int */
|
||||
public const M_DARKMODULE = 0x02;
|
||||
public const M_LOGO = 0x14;
|
||||
/** @var int */
|
||||
public const M_DATA = 0x04;
|
||||
public const M_LOGO_DARK = self::M_LOGO << 8;
|
||||
|
||||
/*
|
||||
* light values
|
||||
*/
|
||||
|
||||
/** @var int */
|
||||
public const M_FINDER = 0x06;
|
||||
public const M_DATA = 0x04;
|
||||
/** @var int */
|
||||
public const M_SEPARATOR = 0x08;
|
||||
public const M_FINDER = 0x06;
|
||||
/** @var int */
|
||||
public const M_ALIGNMENT = 0x0a;
|
||||
public const M_SEPARATOR = 0x08;
|
||||
/** @var int */
|
||||
public const M_TIMING = 0x0c;
|
||||
public const M_ALIGNMENT = 0x0a;
|
||||
/** @var int */
|
||||
public const M_FORMAT = 0x0e;
|
||||
public const M_TIMING = 0x0c;
|
||||
/** @var int */
|
||||
public const M_VERSION = 0x10;
|
||||
public const M_FORMAT = 0x0e;
|
||||
/** @var int */
|
||||
public const M_QUIETZONE = 0x12;
|
||||
public const M_VERSION = 0x10;
|
||||
/** @var int */
|
||||
public const M_LOGO = 0x14;
|
||||
public const M_QUIETZONE = 0x12;
|
||||
|
||||
/*
|
||||
* dark values
|
||||
*/
|
||||
|
||||
/** @var int */
|
||||
public const M_FINDER_DOT = 0x16;
|
||||
public const M_DARKMODULE = self::M_DARKMODULE_LIGHT << 8;
|
||||
/** @var int */
|
||||
public const M_TEST = 0xff;
|
||||
public const M_DATA_DARK = self::M_DATA << 8;
|
||||
/** @var int */
|
||||
public const M_FINDER_DARK = self::M_FINDER << 8;
|
||||
/** @var int */
|
||||
public const M_ALIGNMENT_DARK = self::M_ALIGNMENT << 8;
|
||||
/** @var int */
|
||||
public const M_TIMING_DARK = self::M_TIMING << 8;
|
||||
/** @var int */
|
||||
public const M_FORMAT_DARK = self::M_FORMAT << 8;
|
||||
/** @var int */
|
||||
public const M_VERSION_DARK = self::M_VERSION << 8;
|
||||
/** @var int */
|
||||
public const M_FINDER_DOT = self::M_FINDER_DOT_LIGHT << 8;
|
||||
|
||||
/*
|
||||
* values used for reversed reflectance
|
||||
*/
|
||||
|
||||
/** @var int */
|
||||
public const M_DARKMODULE_LIGHT = 0x02;
|
||||
/** @var int */
|
||||
public const M_FINDER_DOT_LIGHT = 0x16;
|
||||
/** @var int */
|
||||
public const M_SEPARATOR_DARK = self::M_SEPARATOR << 8;
|
||||
/** @var int */
|
||||
public const M_QUIETZONE_DARK = self::M_QUIETZONE << 8;
|
||||
|
||||
/**
|
||||
* ISO/IEC 18004:2000 Annex E, Table E.1 - Row/column coordinates of center module of Alignment Patterns
|
||||
@@ -350,7 +389,7 @@ final class QRMatrix{
|
||||
* Sets the "dark module", that is always on the same position 1x1px away from the bottom left finder
|
||||
*/
|
||||
public function setDarkModule():QRMatrix{
|
||||
$this->set(8, 4 * $this->version + 9, true, $this::M_DARKMODULE);
|
||||
$this->set(8, 4 * $this->version + 9, true, $this::M_DARKMODULE_LIGHT);
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -364,8 +403,8 @@ final class QRMatrix{
|
||||
|
||||
$pos = [
|
||||
[0, 0], // top left
|
||||
[$this->moduleCount - 7, 0], // bottom left
|
||||
[0, $this->moduleCount - 7], // top right
|
||||
[$this->moduleCount - 7, 0], // top right
|
||||
[0, $this->moduleCount - 7], // bottom left
|
||||
];
|
||||
|
||||
foreach($pos as $c){
|
||||
@@ -381,7 +420,7 @@ final class QRMatrix{
|
||||
}
|
||||
// 3*3 dot
|
||||
else{
|
||||
$this->set($c[0] + $y, $c[1] + $x, true, $this::M_FINDER_DOT);
|
||||
$this->set($c[0] + $y, $c[1] + $x, true, $this::M_FINDER_DOT_LIGHT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,27 +21,30 @@ interface QROutputInterface{
|
||||
|
||||
public const DEFAULT_MODULE_VALUES = [
|
||||
// light
|
||||
QRMatrix::M_NULL => false, // 0
|
||||
QRMatrix::M_DATA => false, // 4
|
||||
QRMatrix::M_FINDER => false, // 6
|
||||
QRMatrix::M_SEPARATOR => false, // 8
|
||||
QRMatrix::M_ALIGNMENT => false, // 10
|
||||
QRMatrix::M_TIMING => false, // 12
|
||||
QRMatrix::M_FORMAT => false, // 14
|
||||
QRMatrix::M_VERSION => false, // 16
|
||||
QRMatrix::M_QUIETZONE => false, // 18
|
||||
QRMatrix::M_LOGO => false, // 20
|
||||
QRMatrix::M_TEST => false, // 255
|
||||
QRMatrix::M_NULL => false,
|
||||
QRMatrix::M_DARKMODULE_LIGHT => false,
|
||||
QRMatrix::M_DATA => false,
|
||||
QRMatrix::M_FINDER => false,
|
||||
QRMatrix::M_SEPARATOR => false,
|
||||
QRMatrix::M_ALIGNMENT => false,
|
||||
QRMatrix::M_TIMING => false,
|
||||
QRMatrix::M_FORMAT => false,
|
||||
QRMatrix::M_VERSION => false,
|
||||
QRMatrix::M_QUIETZONE => false,
|
||||
QRMatrix::M_LOGO => false,
|
||||
QRMatrix::M_FINDER_DOT_LIGHT => false,
|
||||
// dark
|
||||
QRMatrix::M_DARKMODULE << 8 => true, // 512
|
||||
QRMatrix::M_DATA << 8 => true, // 1024
|
||||
QRMatrix::M_FINDER << 8 => true, // 1536
|
||||
QRMatrix::M_ALIGNMENT << 8 => true, // 2560
|
||||
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
|
||||
QRMatrix::M_DARKMODULE => true,
|
||||
QRMatrix::M_DATA_DARK => true,
|
||||
QRMatrix::M_FINDER_DARK => true,
|
||||
QRMatrix::M_SEPARATOR_DARK => true,
|
||||
QRMatrix::M_ALIGNMENT_DARK => true,
|
||||
QRMatrix::M_TIMING_DARK => true,
|
||||
QRMatrix::M_FORMAT_DARK => true,
|
||||
QRMatrix::M_VERSION_DARK => true,
|
||||
QRMatrix::M_QUIETZONE_DARK => true,
|
||||
QRMatrix::M_LOGO_DARK => true,
|
||||
QRMatrix::M_FINDER_DOT => true,
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
+22
-22
@@ -107,12 +107,12 @@ final class QRMatrixTest extends TestCase{
|
||||
* Tests the set(), get() and check() methods
|
||||
*/
|
||||
public function testGetSetCheck():void{
|
||||
$this->matrix->set(10, 10, true, QRMatrix::M_TEST);
|
||||
$this::assertSame(65280, $this->matrix->get(10, 10));
|
||||
$this->matrix->set(10, 10, true, QRMatrix::M_DATA);
|
||||
$this::assertSame(QRMatrix::M_DATA_DARK, $this->matrix->get(10, 10));
|
||||
$this::assertTrue($this->matrix->check(10, 10));
|
||||
|
||||
$this->matrix->set(20, 20, false, QRMatrix::M_TEST);
|
||||
$this::assertSame(255, $this->matrix->get(20, 20));
|
||||
$this->matrix->set(20, 20, false, QRMatrix::M_DATA);
|
||||
$this::assertSame(QRMatrix::M_DATA, $this->matrix->get(20, 20));
|
||||
$this::assertFalse($this->matrix->check(20, 20));
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ final class QRMatrixTest extends TestCase{
|
||||
public function testSetDarkModule(int $version):void{
|
||||
$matrix = $this->getMatrix($version)->setDarkModule();
|
||||
|
||||
$this::assertSame(QRMatrix::M_DARKMODULE << 8, $matrix->get(8, $matrix->size() - 8));
|
||||
$this::assertSame(QRMatrix::M_DARKMODULE, $matrix->get(8, $matrix->size() - 8));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -151,9 +151,9 @@ final class QRMatrixTest extends TestCase{
|
||||
public function testSetFinderPattern(int $version):void{
|
||||
$matrix = $this->getMatrix($version)->setFinderPattern();
|
||||
|
||||
$this::assertSame(QRMatrix::M_FINDER << 8, $matrix->get(0, 0));
|
||||
$this::assertSame(QRMatrix::M_FINDER << 8, $matrix->get(0, $matrix->size() - 1));
|
||||
$this::assertSame(QRMatrix::M_FINDER << 8, $matrix->get($matrix->size() - 1, 0));
|
||||
$this::assertSame(QRMatrix::M_FINDER_DARK, $matrix->get(0, 0));
|
||||
$this::assertSame(QRMatrix::M_FINDER_DARK, $matrix->get(0, $matrix->size() - 1));
|
||||
$this::assertSame(QRMatrix::M_FINDER_DARK, $matrix->get($matrix->size() - 1, 0));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -195,12 +195,12 @@ final class QRMatrixTest extends TestCase{
|
||||
foreach($alignmentPattern as $py){
|
||||
foreach($alignmentPattern as $px){
|
||||
|
||||
if($matrix->get($px, $py) === QRMatrix::M_FINDER << 8){
|
||||
$this::assertSame(QRMatrix::M_FINDER << 8, $matrix->get($px, $py), 'skipped finder pattern');
|
||||
if($matrix->get($px, $py) === QRMatrix::M_FINDER_DARK){
|
||||
$this::assertSame(QRMatrix::M_FINDER_DARK, $matrix->get($px, $py), 'skipped finder pattern');
|
||||
continue;
|
||||
}
|
||||
|
||||
$this::assertSame(QRMatrix::M_ALIGNMENT << 8, $matrix->get($px, $py));
|
||||
$this::assertSame(QRMatrix::M_ALIGNMENT_DARK, $matrix->get($px, $py));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -225,13 +225,13 @@ final class QRMatrixTest extends TestCase{
|
||||
if($i % 2 === 0){
|
||||
$p1 = $matrix->get(6, $i);
|
||||
|
||||
if($p1 === QRMatrix::M_ALIGNMENT << 8){
|
||||
$this::assertSame(QRMatrix::M_ALIGNMENT << 8, $p1, 'skipped alignment pattern');
|
||||
if($p1 === QRMatrix::M_ALIGNMENT_DARK){
|
||||
$this::assertSame(QRMatrix::M_ALIGNMENT_DARK, $p1, 'skipped alignment pattern');
|
||||
continue;
|
||||
}
|
||||
|
||||
$this::assertSame(QRMatrix::M_TIMING << 8, $p1);
|
||||
$this::assertSame(QRMatrix::M_TIMING << 8, $matrix->get($i, 6));
|
||||
$this::assertSame(QRMatrix::M_TIMING_DARK, $p1);
|
||||
$this::assertSame(QRMatrix::M_TIMING_DARK, $matrix->get($i, 6));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -283,8 +283,8 @@ final class QRMatrixTest extends TestCase{
|
||||
$size = $matrix->size();
|
||||
$q = 5;
|
||||
|
||||
$matrix->set(0, 0, true, QRMatrix::M_TEST);
|
||||
$matrix->set($size - 1, $size - 1, true, QRMatrix::M_TEST);
|
||||
$matrix->set(0, 0, true, QRMatrix::M_DATA);
|
||||
$matrix->set($size - 1, $size - 1, true, QRMatrix::M_DATA);
|
||||
|
||||
$matrix->setQuietZone($q);
|
||||
|
||||
@@ -295,8 +295,8 @@ final class QRMatrixTest extends TestCase{
|
||||
$this::assertSame(QRMatrix::M_QUIETZONE, $matrix->get(0, 0));
|
||||
$this::assertSame(QRMatrix::M_QUIETZONE, $matrix->get($size - 1, $size - 1));
|
||||
|
||||
$this::assertSame(QRMatrix::M_TEST << 8, $matrix->get($q, $q));
|
||||
$this::assertSame(QRMatrix::M_TEST << 8, $matrix->get($size - 1 - $q, $size - 1 - $q));
|
||||
$this::assertSame(QRMatrix::M_DATA_DARK, $matrix->get($q, $q));
|
||||
$this::assertSame(QRMatrix::M_DATA_DARK, $matrix->get($size - 1 - $q, $size - 1 - $q));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -340,10 +340,10 @@ final class QRMatrixTest extends TestCase{
|
||||
// logo space should not overwrite quiet zone & function patterns
|
||||
$m->setLogoSpace(21, 21, -10, -10);
|
||||
$this::assertSame(QRMatrix::M_QUIETZONE, $m->get(9, 9));
|
||||
$this::assertSame(QRMatrix::M_FINDER << 8, $m->get(10, 10));
|
||||
$this::assertSame(QRMatrix::M_FINDER << 8, $m->get(16, 16));
|
||||
$this::assertSame(QRMatrix::M_FINDER_DARK, $m->get(10, 10));
|
||||
$this::assertSame(QRMatrix::M_FINDER_DARK, $m->get(16, 16));
|
||||
$this::assertSame(QRMatrix::M_SEPARATOR, $m->get(17, 17));
|
||||
$this::assertSame(QRMatrix::M_FORMAT << 8, $m->get(18, 18));
|
||||
$this::assertSame(QRMatrix::M_FORMAT_DARK, $m->get(18, 18));
|
||||
$this::assertSame(QRMatrix::M_LOGO, $m->get(19, 19));
|
||||
$this::assertSame(QRMatrix::M_LOGO, $m->get(20, 20));
|
||||
$this::assertNotSame(QRMatrix::M_LOGO, $m->get(21, 21));
|
||||
|
||||
@@ -13,8 +13,9 @@
|
||||
namespace chillerlan\QRCodeTest\Output;
|
||||
|
||||
use FPDF;
|
||||
use chillerlan\QRCode\Output\{QRFpdf, QROutputInterface};
|
||||
use chillerlan\QRCode\{QRCode, QROptions};
|
||||
use chillerlan\QRCode\Data\QRMatrix;
|
||||
use chillerlan\QRCode\Output\{QRFpdf, QROutputInterface};
|
||||
|
||||
use function class_exists, substr;
|
||||
|
||||
@@ -64,8 +65,8 @@ class QRFpdfTest extends QROutputTestAbstract{
|
||||
|
||||
$this->options->moduleValues = [
|
||||
// data
|
||||
1024 => [0, 0, 0],
|
||||
4 => [255, 255, 255],
|
||||
QRMatrix::M_DATA_DARK => [0, 0, 0],
|
||||
QRMatrix::M_DATA => [255, 255, 255],
|
||||
];
|
||||
|
||||
$this->outputInterface = $this->getOutputInterface($this->options);
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
namespace chillerlan\QRCodeTest\Output;
|
||||
|
||||
use chillerlan\QRCode\{QRCode, QROptions};
|
||||
use chillerlan\QRCode\Data\QRMatrix;
|
||||
use chillerlan\QRCode\Output\{QROutputInterface, QRImage};
|
||||
|
||||
/**
|
||||
@@ -61,8 +62,8 @@ class QRImageTest extends QROutputTestAbstract{
|
||||
|
||||
$this->options->moduleValues = [
|
||||
// data
|
||||
1024 => [0, 0, 0],
|
||||
4 => [255, 255, 255],
|
||||
QRMatrix::M_DATA_DARK => [0, 0, 0],
|
||||
QRMatrix::M_DATA => [255, 255, 255],
|
||||
];
|
||||
|
||||
$this->outputInterface = $this->getOutputInterface($this->options);
|
||||
|
||||
@@ -17,6 +17,7 @@ namespace chillerlan\QRCodeTest\Output;
|
||||
|
||||
use Imagick;
|
||||
use chillerlan\QRCode\{QRCode, QROptions};
|
||||
use chillerlan\QRCode\Data\QRMatrix;
|
||||
use chillerlan\QRCode\Output\{QROutputInterface, QRImagick};
|
||||
|
||||
/**
|
||||
@@ -65,8 +66,8 @@ class QRImagickTest extends QROutputTestAbstract{
|
||||
|
||||
$this->options->moduleValues = [
|
||||
// data
|
||||
1024 => '#4A6000',
|
||||
4 => '#ECF9BE',
|
||||
QRMatrix::M_DATA_DARK => '#4A6000',
|
||||
QRMatrix::M_DATA => '#ECF9BE',
|
||||
];
|
||||
|
||||
$this->outputInterface = $this->getOutputInterface($this->options);
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
namespace chillerlan\QRCodeTest\Output;
|
||||
|
||||
use chillerlan\QRCode\{QRCode, QROptions};
|
||||
use chillerlan\QRCode\Data\QRMatrix;
|
||||
use chillerlan\QRCode\Output\{QROutputInterface, QRMarkup};
|
||||
|
||||
/**
|
||||
@@ -46,8 +47,8 @@ class QRMarkupTest extends QROutputTestAbstract{
|
||||
$this->options->imageBase64 = false;
|
||||
$this->options->moduleValues = [
|
||||
// data
|
||||
1024 => '#4A6000',
|
||||
4 => '#ECF9BE',
|
||||
QRMatrix::M_DATA_DARK => '#4A6000',
|
||||
QRMatrix::M_DATA => '#ECF9BE',
|
||||
];
|
||||
|
||||
$this->outputInterface = $this->getOutputInterface($this->options);
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
namespace chillerlan\QRCodeTest\Output;
|
||||
|
||||
use chillerlan\QRCode\{QRCode, QROptions};
|
||||
use chillerlan\QRCode\Data\QRMatrix;
|
||||
use chillerlan\QRCode\Output\{QROutputInterface, QRString};
|
||||
|
||||
/**
|
||||
@@ -46,8 +47,8 @@ class QRStringTest extends QROutputTestAbstract{
|
||||
|
||||
$this->options->moduleValues = [
|
||||
// data
|
||||
1024 => 'A',
|
||||
4 => 'B',
|
||||
QRMatrix::M_DATA_DARK => 'A',
|
||||
QRMatrix::M_DATA => 'B',
|
||||
];
|
||||
|
||||
$this->outputInterface = $this->getOutputInterface($this->options);
|
||||
|
||||
Reference in New Issue
Block a user