MCPcopy Create free account
hub / github.com/codemistic/Web-Development / createFrame

Method createFrame

text-to-qr/lib/phpqrcode/qrspec.php:410–485  ·  view source on GitHub ↗

----------------------------------------------------------------------

($version)

Source from the content-addressed store, hash-verified

408
409 //----------------------------------------------------------------------
410 public static function createFrame($version)
411 {
412 $width = self::$capacity[$version][QRCAP_WIDTH];
413 $frameLine = str_repeat ("\0", $width);
414 $frame = array_fill(0, $width, $frameLine);
415
416 // Finder pattern
417 self::putFinderPattern($frame, 0, 0);
418 self::putFinderPattern($frame, $width - 7, 0);
419 self::putFinderPattern($frame, 0, $width - 7);
420
421 // Separator
422 $yOffset = $width - 7;
423
424 for($y=0; $y<7; $y++) {
425 $frame[$y][7] = "\xc0";
426 $frame[$y][$width - 8] = "\xc0";
427 $frame[$yOffset][7] = "\xc0";
428 $yOffset++;
429 }
430
431 $setPattern = str_repeat("\xc0", 8);
432
433 QRstr::set($frame, 0, 7, $setPattern);
434 QRstr::set($frame, $width-8, 7, $setPattern);
435 QRstr::set($frame, 0, $width - 8, $setPattern);
436
437 // Format info
438 $setPattern = str_repeat("\x84", 9);
439 QRstr::set($frame, 0, 8, $setPattern);
440 QRstr::set($frame, $width - 8, 8, $setPattern, 8);
441
442 $yOffset = $width - 8;
443
444 for($y=0; $y<8; $y++,$yOffset++) {
445 $frame[$y][8] = "\x84";
446 $frame[$yOffset][8] = "\x84";
447 }
448
449 // Timing pattern
450
451 for($i=1; $i<$width-15; $i++) {
452 $frame[6][7+$i] = chr(0x90 | ($i & 1));
453 $frame[7+$i][6] = chr(0x90 | ($i & 1));
454 }
455
456 // Alignment pattern
457 self::putAlignmentPattern($version, $frame, $width);
458
459 // Version information
460 if($version >= 7) {
461 $vinf = self::getVersionPattern($version);
462
463 $v = $vinf;
464
465 for($x=0; $x<6; $x++) {
466 for($y=0; $y<3; $y++) {
467 $frame[($width - 11)+$y][$x] = chr(0x88 | ($v & 1));

Callers 1

newFrameMethod · 0.95

Calls 4

putFinderPatternMethod · 0.95
putAlignmentPatternMethod · 0.95
getVersionPatternMethod · 0.95
setMethod · 0.45

Tested by

no test coverage detected