API-QRMatrix.md.txt 11 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. # QRMatrix
  2. The full phpDocumentor API documentation can be found at [chillerlan.github.io/php-qrcode](https://chillerlan.github.io/php-qrcode/classes/chillerlan-QRCode-Data-QRMatrix.html).
  3. ## Methods
  4. <!-- using non-breaking spaces chr(255) in the longest method signature to force the silly table to stretch -->
  5. | method | return | description |
  6. |----------------------------------------------------------------------------------------|---------------------|----------------------------------------------------------------------------------------------------------------------------|
  7. | `__construct(Version $version, EccLevel $eccLevel)` | - | |
  8. | `initFunctionalPatterns()` | `self` | shortcut to initialize the functional patterns |
  9. | `getMatrix()` | `array` | the internal matrix representation as a 2 dimensional array |
  10. | `getVersion()` | `Version\|null` | the current QR Code version instance |
  11. | `getEccLevel()` | `EccLevel\|null` | the current ECC level instance |
  12. | `getMaskPattern()` | `MaskPattern\|null` | the used mask pattern instance |
  13. | `getSize()` | `int` | the absoulute size of the matrix, including quiet zone (if set). `$version * 4 + 17 + 2 * $quietzone` |
  14. | `get(int $x, int $y)` | `int` | returns the value of the module |
  15. | `set(int $x, int $y, bool $value, int $M_TYPE)` | `self` | sets the `$M_TYPE` value for the module |
  16. | `setArea(int $startX, int $startY, int $width, int $height, bool $value, int $M_TYPE)` | `self` | Fills an area of $width * $height, from the given starting point $startX, $startY (top left) with $value for $M_TYPE |
  17. | `checkType(int $x, int $y, int $M_TYPE)` | `bool` | Checks whether a module is of the given $M_TYPE |
  18. | `checkTypeIn(int $x, int $y, array $M_TYPES)` | `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 |
  19. | `check(int $x, int $y)` | `bool` | checks whether a module is true (dark) or false (light) |
  20. | `checkNeighbours(int $x, int $y, int $M_TYPE = null)` | `int` | Checks the status neighbouring modules of the given module at ($x, $y) and returns a bitmask with the results. |
  21. | `setDarkModule()` | `self` | |
  22. | `setFinderPattern()` | `self` | |
  23. | `setSeparators()` | `self` | |
  24. | `setAlignmentPattern()` | `self` | |
  25. | `setTimingPattern()` | `self` | |
  26. | `setVersionNumber()` | `self` | |
  27. | `setFormatInfo(MaskPattern $maskPattern = null)` | `self` | |
  28. | `setQuietZone(int $quietZoneSize)` | `self` | Draws the "quiet zone" of $quietZoneSize around the matrix |
  29. | `rotate90()` | `self` | Rotates the matrix by 90 degrees clock wise |
  30. | `setLogoSpace(int $width, int $height = null, int $startX = null, int $startY = null)` | `self` | Clears a space of $width * $height in order to add a logo or text. |
  31. | `writeCodewords(BitBuffer $bitBuffer)` | `self` | Maps the interleaved binary data on the matrix |
  32. | `mask(MaskPattern $maskPattern)` | `self` | Applies/reverses the mask pattern |
  33. ### Deprecated methods
  34. | method | since | replacement |
  35. |-----------------|---------|------------------------------|
  36. | `matrix()` | `5.0.0` | `QRMatrix::getMatrix()` |
  37. | `eccLevel()` | `5.0.0` | `QRMatrix::getEccLevel()` |
  38. | `version()` | `5.0.0` | `QRMatrix::getVersion()` |
  39. | `maskPattern()` | `5.0.0` | `QRMatrix::getMaskPattern()` |
  40. | `size()` | `5.0.0` | `QRMatrix::getSize()` |
  41. ## Constants
  42. The `_DARK` and `_LIGHT` postfixed constans exist purely for convenience - their value is the same as
  43. `QRMatrix::M_XXX | QRMatrix::IS_DARK` and `QRMatrix::M_XXX ^ QRMatrix::IS_DARK` respectively,
  44. see [`QROutputInterface`](./API-QROutputInterface.md).
  45. | name | description |
  46. |----------------------|-----------------------------------------------------------------------------------|
  47. | `IS_DARK` | sets the "dark" flag for the given value: `QRMatrix::M_DATA \| QRMatrix::IS_DARK` |
  48. | `M_NULL` | module not set |
  49. | `M_DARKMODULE_LIGHT` | convenience (reversed reflectance) |
  50. | `M_DARKMODULE` | once per matrix at `$xy = [8, 4 * $version + 9]` |
  51. | `M_DATA` | the actual encoded data |
  52. | `M_DATA_DARK` | convenience |
  53. | `M_FINDER` | the 7x7 finder patterns |
  54. | `M_FINDER_DARK` | convenience |
  55. | `M_FINDER_DOT_LIGHT` | convenience (reversed reflectance) |
  56. | `M_FINDER_DOT` | the inner 3x3 block of the finder pattern |
  57. | `M_SEPARATOR` | separator lines along the finder patterns |
  58. | `M_SEPARATOR_DARK` | convenience |
  59. | `M_ALIGNMENT` | the 5x5 alignment patterns |
  60. | `M_ALIGNMENT_DARK` | convenience |
  61. | `M_TIMING` | the timing pattern lines |
  62. | `M_TIMING_DARK` | convenience |
  63. | `M_FORMAT` | format information pattern |
  64. | `M_FORMAT_DARK` | convenience |
  65. | `M_VERSION` | version information pattern |
  66. | `M_VERSION_DARK` | convenience |
  67. | `M_QUIETZONE` | margin around the QR Code |
  68. | `M_QUIETZONE_DARK` | convenience |
  69. | `M_LOGO` | space for a logo image (not used yet) |
  70. | `M_LOGO_DARK` | convenience |
  71. | `M_TEST` | test value |
  72. | `M_TEST_DARK` | convenience |