MCPcopy Create free account
hub / github.com/cozmo/jsQR / buildFunctionPatternMask

Function buildFunctionPatternMask

src/decoder/decoder.ts:74–100  ·  view source on GitHub ↗
(version: Version)

Source from the content-addressed store, hash-verified

72}
73
74function buildFunctionPatternMask(version: Version): BitMatrix {
75 const dimension = 17 + 4 * version.versionNumber;
76 const matrix = BitMatrix.createEmpty(dimension, dimension);
77
78 matrix.setRegion(0, 0, 9, 9, true); // Top left finder pattern + separator + format
79 matrix.setRegion(dimension - 8, 0, 8, 9, true); // Top right finder pattern + separator + format
80 matrix.setRegion(0, dimension - 8, 9, 8, true); // Bottom left finder pattern + separator + format
81
82 // Alignment patterns
83 for (const x of version.alignmentPatternCenters) {
84 for (const y of version.alignmentPatternCenters) {
85 if (!(x === 6 && y === 6 || x === 6 && y === dimension - 7 || x === dimension - 7 && y === 6)) {
86 matrix.setRegion(x - 2, y - 2, 5, 5, true);
87 }
88 }
89 }
90
91 matrix.setRegion(6, 9, 1, dimension - 17, true); // Vertical timing pattern
92 matrix.setRegion(9, 6, dimension - 17, 1, true); // Horizontal timing pattern
93
94 if (version.versionNumber > 6) {
95 matrix.setRegion(dimension - 11, 0, 3, 6, true); // Version info, top right
96 matrix.setRegion(0, dimension - 11, 6, 3, true); // Version info, bottom left
97 }
98
99 return matrix;
100}
101
102function readCodewords(matrix: BitMatrix, version: Version, formatInfo: FormatInformation) {
103 const dataMask = DATA_MASKS[formatInfo.dataMask];

Callers 1

readCodewordsFunction · 0.70

Calls 2

createEmptyMethod · 0.80
setRegionMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…