MCPcopy Create free account
hub / github.com/TactilityProject/Tactility / drawFunctionPatterns

Function drawFunctionPatterns

Libraries/QRCode/src/qrcode.c:380–435  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

378}
379
380static void drawFunctionPatterns(BitBucket *modules, BitBucket *isFunction, uint8_t version, uint8_t ecc) {
381
382 uint8_t size = modules->bitOffsetOrWidth;
383
384 // Draw the horizontal and vertical timing patterns
385 for (uint8_t i = 0; i < size; i++) {
386 setFunctionModule(modules, isFunction, 6, i, i % 2 == 0);
387 setFunctionModule(modules, isFunction, i, 6, i % 2 == 0);
388 }
389
390 // Draw 3 finder patterns (all corners except bottom right; overwrites some timing modules)
391 drawFinderPattern(modules, isFunction, 3, 3);
392 drawFinderPattern(modules, isFunction, size - 4, 3);
393 drawFinderPattern(modules, isFunction, 3, size - 4);
394
395#if LOCK_VERSION == 0 || LOCK_VERSION > 1
396
397 if (version > 1) {
398
399 // Draw the numerous alignment patterns
400
401 uint8_t alignCount = version / 7 + 2;
402 uint8_t step;
403 if (version != 32) {
404 step = (version * 4 + alignCount * 2 + 1) / (2 * alignCount - 2) * 2; // ceil((size - 13) / (2*numAlign - 2)) * 2
405 } else { // C-C-C-Combo breaker!
406 step = 26;
407 }
408
409 uint8_t alignPositionIndex = alignCount - 1;
410 uint8_t alignPosition[alignCount];
411
412 alignPosition[0] = 6;
413
414 uint8_t size = version * 4 + 17;
415 for (uint8_t i = 0, pos = size - 7; i < alignCount - 1; i++, pos -= step) {
416 alignPosition[alignPositionIndex--] = pos;
417 }
418
419 for (uint8_t i = 0; i < alignCount; i++) {
420 for (uint8_t j = 0; j < alignCount; j++) {
421 if ((i == 0 && j == 0) || (i == 0 && j == alignCount - 1) || (i == alignCount - 1 && j == 0)) {
422 continue; // Skip the three finder corners
423 } else {
424 drawAlignmentPattern(modules, isFunction, alignPosition[i], alignPosition[j]);
425 }
426 }
427 }
428 }
429
430#endif
431
432 // Draw configuration data
433 drawFormatBits(modules, isFunction, ecc, 0); // Dummy mask value; overwritten later in the constructor
434 drawVersion(modules, isFunction, version);
435}
436
437

Callers 2

qrcode_initBytesFunction · 0.85
QrCodeMethod · 0.85

Calls 5

setFunctionModuleFunction · 0.85
drawFinderPatternFunction · 0.85
drawAlignmentPatternFunction · 0.85
drawFormatBitsFunction · 0.85
drawVersionFunction · 0.85

Tested by 1

QrCodeMethod · 0.68