Documentation

QRMatrix
in package

Holds an array representation of the final QR Code that contains numerical values for later output modifications; maps the ECC coded binary data and applies the mask pattern

Tags
see
http://www.thonky.com/qr-code-tutorial/format-version-information

Table of Contents

Constants

IS_DARK  = 0b100000000000
M_ALIGNMENT  = 0b10000
M_ALIGNMENT_DARK  = 0b100000010000
M_DARKMODULE  = 0b100000000001
M_DARKMODULE_LIGHT  = 0b1
M_DATA  = 0b10
M_DATA_DARK  = 0b100000000010
M_FINDER  = 0b100
M_FINDER_DARK  = 0b100000000100
M_FINDER_DOT  = 0b110000000000
M_FINDER_DOT_LIGHT  = 0b10000000000
M_FORMAT  = 0b1000000
M_FORMAT_DARK  = 0b100001000000
M_LOGO  = 0b1000000000
M_LOGO_DARK  = 0b101000000000
M_NULL  = 0b0
M_QUIETZONE  = 0b100000000
M_QUIETZONE_DARK  = 0b100100000000
M_SEPARATOR  = 0b1000
M_SEPARATOR_DARK  = 0b100000001000
M_TIMING  = 0b100000
M_TIMING_DARK  = 0b100000100000
M_VERSION  = 0b10000000
M_VERSION_DARK  = 0b100010000000
neighbours  = [0b1 => [-1, -1], 0b10 => [0, -1], 0b100 => [1, -1], 0b1000 => [1, 0], 0b10000 => [1, 1], 0b100000 => [0, 1], 0b1000000 => [-1, 1], 0b10000000 => [-1, 0]]
Map of flag => coord

Properties

$eccLevel  : EccLevel|null
the current ECC level - always set in QRMatrix, may be null in BitMatrix
$maskPattern  : MaskPattern|null
the mask pattern that was used in the most recent operation, set via:
$matrix  : array<string|int, array<string|int, int>>
the actual matrix data array
$moduleCount  : int
the size (side length) of the matrix, including quiet zone (if created)
$version  : Version|null
the matrix version - always set in QRMatrix, may be null in BitMatrix

Methods

__construct()  : mixed
QRMatrix constructor.
check()  : bool
Checks whether the module at ($x, $y) is true (dark) or false (light)
checkNeighbours()  : int
Checks the status of the neighbouring modules for the module at ($x, $y) and returns a bitmask with the results.
checkType()  : bool
Checks whether the module at ($x, $y) is of the given $M_TYPE
checkTypeIn()  : bool
Checks whether the module at ($x, $y) is in the given array of $M_TYPES, returns true if a match is found, otherwise false.
flip()  : static
Flips the value of the module at ($x, $y)
get()  : int
Returns the value of the module at position [$x, $y] or -1 if the coordinate is outside the matrix
getEccLevel()  : EccLevel|null
Returns the current ECC level
getMaskPattern()  : MaskPattern|null
Returns the current mask pattern
getMatrix()  : array<string|int, array<string|int, int>>
Returns the data matrix, returns a pure boolean representation if $boolean is set to true
getSize()  : int
Returns the absoulute size of the matrix, including quiet zone (after setting it).
getVersion()  : Version|null
Returns the current version number
initFunctionalPatterns()  : static
shortcut to initialize the functional patterns
invert()  : static
Inverts the values of the whole matrix
isDark()  : bool
Checks whether the given $M_TYPE is a dark value
mask()  : static
Applies/reverses the mask pattern
rotate90()  : static
Rotates the matrix by 90 degrees clock wise
set()  : static
Sets the $M_TYPE value for the module at position [$x, $y]
setAlignmentPattern()  : static
Draws the 5x5 alignment patterns
setArea()  : static
Fills an area of $width * $height, from the given starting point [$startX, $startY] (top left) with $value for $M_TYPE.
setDarkModule()  : static
Sets the "dark module", that is always on the same position 1x1px away from the bottom left finder
setFinderPattern()  : static
Draws the 7x7 finder patterns in the corners top left/right and bottom left
setFormatInfo()  : static
Draws the format info along the finder patterns. If no $maskPattern, all format info modules will be set to false.
setLogoSpace()  : static
Clears a space of $width * $height in order to add a logo or text.
setQuietZone()  : static
Draws the "quiet zone" of $size around the matrix
setSeparators()  : static
Draws the separator lines around the finder patterns
setTimingPattern()  : static
Draws the timing pattern (h/v checkered line between the finder patterns)
setVersionNumber()  : static
Draws the version information, 2x 3x6 pixel
writeCodewords()  : static
Maps the interleaved binary $data on the matrix
createMatrix()  : array<string|int, array<string|int, int>>
Creates a 2-dimensional array (square) of the given $size

Constants

IS_DARK

public int IS_DARK = 0b100000000000

M_ALIGNMENT

public int M_ALIGNMENT = 0b10000

M_ALIGNMENT_DARK

public int M_ALIGNMENT_DARK = 0b100000010000

M_DARKMODULE

public int M_DARKMODULE = 0b100000000001

M_DARKMODULE_LIGHT

public int M_DARKMODULE_LIGHT = 0b1

M_DATA_DARK

public int M_DATA_DARK = 0b100000000010

M_FINDER_DARK

public int M_FINDER_DARK = 0b100000000100

M_FINDER_DOT

public int M_FINDER_DOT = 0b110000000000

M_FINDER_DOT_LIGHT

public int M_FINDER_DOT_LIGHT = 0b10000000000

M_FORMAT

public int M_FORMAT = 0b1000000

M_FORMAT_DARK

public int M_FORMAT_DARK = 0b100001000000

M_LOGO_DARK

public int M_LOGO_DARK = 0b101000000000

M_QUIETZONE

public int M_QUIETZONE = 0b100000000

M_QUIETZONE_DARK

public int M_QUIETZONE_DARK = 0b100100000000

M_SEPARATOR

public int M_SEPARATOR = 0b1000

M_SEPARATOR_DARK

public int M_SEPARATOR_DARK = 0b100000001000

M_TIMING_DARK

public int M_TIMING_DARK = 0b100000100000

M_VERSION

public int M_VERSION = 0b10000000

M_VERSION_DARK

public int M_VERSION_DARK = 0b100010000000

neighbours

Map of flag => coord

protected array<string|int, array<string|int, int>> neighbours = [0b1 => [-1, -1], 0b10 => [0, -1], 0b100 => [1, -1], 0b1000 => [1, 0], 0b10000 => [1, 1], 0b100000 => [0, 1], 0b1000000 => [-1, 1], 0b10000000 => [-1, 0]]
Tags
see
QRMatrix::checkNeighbours()

Properties

$eccLevel

the current ECC level - always set in QRMatrix, may be null in BitMatrix

protected EccLevel|null $eccLevel = null

$maskPattern

the mask pattern that was used in the most recent operation, set via:

protected MaskPattern|null $maskPattern = null
  • QRMatrix::setFormatInfo()
  • QRMatrix::mask()
  • BitMatrix::readFormatInformation()

$matrix

the actual matrix data array

protected array<string|int, array<string|int, int>> $matrix

$moduleCount

the size (side length) of the matrix, including quiet zone (if created)

protected int $moduleCount

$version

the matrix version - always set in QRMatrix, may be null in BitMatrix

protected Version|null $version = null

Methods

check()

Checks whether the module at ($x, $y) is true (dark) or false (light)

public check(int $x, int $y) : bool

Also, returns false if the given coordinates are out of range.

Parameters
$x : int
$y : int
Return values
bool

checkNeighbours()

Checks the status of the neighbouring modules for the module at ($x, $y) and returns a bitmask with the results.

public checkNeighbours(int $x, int $y[, int|null $M_TYPE = null ]) : int

The 8 flags of the bitmask represent the status of each of the neighbouring fields, starting with the lowest bit for top left, going clockwise:

0 1 2 7 # 3 6 5 4

Parameters
$x : int
$y : int
$M_TYPE : int|null = null
Return values
int

checkType()

Checks whether the module at ($x, $y) is of the given $M_TYPE

public checkType(int $x, int $y, int $M_TYPE) : bool

true => $value & $M_TYPE === $M_TYPE

Also, returns false if the given coordinates are out of range.

Parameters
$x : int
$y : int
$M_TYPE : int
Return values
bool

checkTypeIn()

Checks whether the module at ($x, $y) is in the given array of $M_TYPES, returns true if a match is found, otherwise false.

public checkTypeIn(int $x, int $y, array<string|int, int> $M_TYPES) : bool
Parameters
$x : int
$y : int
$M_TYPES : array<string|int, int>
Return values
bool

flip()

Flips the value of the module at ($x, $y)

public flip(int $x, int $y) : static
Parameters
$x : int
$y : int
Return values
static

get()

Returns the value of the module at position [$x, $y] or -1 if the coordinate is outside the matrix

public get(int $x, int $y) : int
Parameters
$x : int
$y : int
Return values
int

getMatrix()

Returns the data matrix, returns a pure boolean representation if $boolean is set to true

public getMatrix([bool|null $boolean = null ]) : array<string|int, array<string|int, int>>
Parameters
$boolean : bool|null = null
Return values
array<string|int, array<string|int, int>>

getSize()

Returns the absoulute size of the matrix, including quiet zone (after setting it).

public getSize() : int

size = version * 4 + 17 [ + 2 * quietzone size]

Return values
int

getVersion()

Returns the current version number

public getVersion() : Version|null
Return values
Version|null

initFunctionalPatterns()

shortcut to initialize the functional patterns

public initFunctionalPatterns() : static
Return values
static

invert()

Inverts the values of the whole matrix

public invert() : static

ISO/IEC 18004:2015 Section 6.2 - Reflectance reversal

Return values
static

isDark()

Checks whether the given $M_TYPE is a dark value

public isDark(int $M_TYPE) : bool
Parameters
$M_TYPE : int
Return values
bool

mask()

Applies/reverses the mask pattern

public mask(MaskPattern $maskPattern) : static

ISO/IEC 18004:2000 Section 8.8.1

Parameters
$maskPattern : MaskPattern
Return values
static

rotate90()

Rotates the matrix by 90 degrees clock wise

public rotate90() : static
Return values
static

set()

Sets the $M_TYPE value for the module at position [$x, $y]

public set(int $x, int $y, bool $value, int $M_TYPE) : static

true => $M_TYPE | 0x800 false => $M_TYPE

Parameters
$x : int
$y : int
$value : bool
$M_TYPE : int
Return values
static

setAlignmentPattern()

Draws the 5x5 alignment patterns

public setAlignmentPattern() : static

ISO/IEC 18004:2000 Section 7.3.5

Return values
static

setArea()

Fills an area of $width * $height, from the given starting point [$startX, $startY] (top left) with $value for $M_TYPE.

public setArea(int $startX, int $startY, int $width, int $height, bool $value, int $M_TYPE) : static
Parameters
$startX : int
$startY : int
$width : int
$height : int
$value : bool
$M_TYPE : int
Return values
static

setDarkModule()

Sets the "dark module", that is always on the same position 1x1px away from the bottom left finder

public setDarkModule() : static

4 * version + 9 or moduleCount - 8

Return values
static

setFinderPattern()

Draws the 7x7 finder patterns in the corners top left/right and bottom left

public setFinderPattern() : static

ISO/IEC 18004:2000 Section 7.3.2

Return values
static

setFormatInfo()

Draws the format info along the finder patterns. If no $maskPattern, all format info modules will be set to false.

public setFormatInfo([MaskPattern|null $maskPattern = null ]) : static

ISO/IEC 18004:2000 Section 8.9

Parameters
$maskPattern : MaskPattern|null = null
Return values
static

setLogoSpace()

Clears a space of $width * $height in order to add a logo or text.

public setLogoSpace(int $width[, int|null $height = null ][, int|null $startX = null ][, int|null $startY = null ]) : static

If no $height is given, the space will be assumed a square of $width.

Additionally, the logo space can be positioned within the QR Code using $startX and $startY. If either of these are null, the logo space will be centered in that direction. ECC level "H" (30%) is required.

The coordinates of $startX and $startY do not include the quiet zone: [0, 0] is always the top left module of the top left finder pattern, negative values go into the quiet zone top and left.

Please note that adding a logo space minimizes the error correction capacity of the QR Code and created images may become unreadable, especially when printed with a chance to receive damage. Please test thoroughly before using this feature in production.

This method should be called from within an output module (after the matrix has been filled with data). Note that there is no restiction on how many times this method could be called on the same matrix instance.

Parameters
$width : int
$height : int|null = null
$startX : int|null = null
$startY : int|null = null
Tags
link
https://github.com/chillerlan/php-qrcode/issues/52
throws
QRCodeDataException
Return values
static

setQuietZone()

Draws the "quiet zone" of $size around the matrix

public setQuietZone(int $quietZoneSize) : static

ISO/IEC 18004:2000 Section 7.3.7

Parameters
$quietZoneSize : int
Tags
throws
QRCodeDataException
Return values
static

setSeparators()

Draws the separator lines around the finder patterns

public setSeparators() : static

ISO/IEC 18004:2000 Section 7.3.3

Return values
static

setTimingPattern()

Draws the timing pattern (h/v checkered line between the finder patterns)

public setTimingPattern() : static

ISO/IEC 18004:2000 Section 7.3.4

Return values
static

setVersionNumber()

Draws the version information, 2x 3x6 pixel

public setVersionNumber() : static

ISO/IEC 18004:2000 Section 8.10

Return values
static

writeCodewords()

Maps the interleaved binary $data on the matrix

public writeCodewords(BitBuffer $bitBuffer) : static
Parameters
$bitBuffer : BitBuffer
Return values
static

createMatrix()

Creates a 2-dimensional array (square) of the given $size

protected createMatrix(int $size, int $value) : array<string|int, array<string|int, int>>
Parameters
$size : int
$value : int
Return values
array<string|int, array<string|int, int>>

        
On this page

Search results