Draws a 9*9 finder pattern including the border separator, with the center module at (x, y).
| 282 | |
| 283 | // Draws a 9*9 finder pattern including the border separator, with the center module at (x, y). |
| 284 | static void drawFinderPattern(BitBucket *modules, BitBucket *isFunction, uint8_t x, uint8_t y) { |
| 285 | uint8_t size = modules->bitOffsetOrWidth; |
| 286 | |
| 287 | for (int8_t i = -4; i <= 4; i++) { |
| 288 | for (int8_t j = -4; j <= 4; j++) { |
| 289 | uint8_t dist = max(abs(i), abs(j)); // Chebyshev/infinity norm |
| 290 | int16_t xx = x + j, yy = y + i; |
| 291 | if (0 <= xx && xx < size && 0 <= yy && yy < size) { |
| 292 | setFunctionModule(modules, isFunction, xx, yy, dist != 2 && dist != 4); |
| 293 | } |
| 294 | } |
| 295 | } |
| 296 | } |
| 297 | |
| 298 | // Draws a 5*5 alignment pattern, with the center module at (x, y). |
| 299 | static void drawAlignmentPattern(BitBucket *modules, BitBucket *isFunction, uint8_t x, uint8_t y) { |