(mask: int)
| 260 | // Draws two copies of the format bits (with its own error correction code) |
| 261 | // based on the given mask and this object's error correction level field. |
| 262 | private drawFormatBits(mask: int): void { |
| 263 | // Calculate error correction code and pack bits |
| 264 | const data: int = this.errorCorrectionLevel.formatBits << 3 | mask; // errCorrLvl is uint2, mask is uint3 |
| 265 | let rem: int = data; |
| 266 | for (let i = 0; i < 10; i++) |
| 267 | rem = (rem << 1) ^ ((rem >>> 9) * 0x537); |
| 268 | const bits = (data << 10 | rem) ^ 0x5412; // uint15 |
| 269 | assert(bits >>> 15 == 0); |
| 270 | |
| 271 | // Draw first copy |
| 272 | for (let i = 0; i <= 5; i++) |
| 273 | this.setFunctionModule(8, i, getBit(bits, i)); |
| 274 | this.setFunctionModule(8, 7, getBit(bits, 6)); |
| 275 | this.setFunctionModule(8, 8, getBit(bits, 7)); |
| 276 | this.setFunctionModule(7, 8, getBit(bits, 8)); |
| 277 | for (let i = 9; i < 15; i++) |
| 278 | this.setFunctionModule(14 - i, 8, getBit(bits, i)); |
| 279 | |
| 280 | // Draw second copy |
| 281 | for (let i = 0; i < 8; i++) |
| 282 | this.setFunctionModule(this.size - 1 - i, 8, getBit(bits, i)); |
| 283 | for (let i = 8; i < 15; i++) |
| 284 | this.setFunctionModule(8, this.size - 15 + i, getBit(bits, i)); |
| 285 | this.setFunctionModule(8, this.size - 8, true); // Always dark |
| 286 | } |
| 287 | |
| 288 | |
| 289 | // Draws two copies of the version bits (with its own error correction code), |
no test coverage detected