finder-pattern.js 593 B

12345678910111213141516171819202122
  1. var getSymbolSize = require('./utils').getSymbolSize
  2. var FINDER_PATTERN_SIZE = 7
  3. /**
  4. * Returns an array containing the positions of each finder pattern.
  5. * Each array's element represent the top-left point of the pattern as (x, y) coordinates
  6. *
  7. * @param {Number} version QR Code version
  8. * @return {Array} Array of coordinates
  9. */
  10. exports.getPositions = function getPositions (version) {
  11. var size = getSymbolSize(version)
  12. return [
  13. // top-left
  14. [0, 0],
  15. // top-right
  16. [size - FINDER_PATTERN_SIZE, 0],
  17. // bottom-left
  18. [0, size - FINDER_PATTERN_SIZE]
  19. ]
  20. }