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

Method evaluateSymbol

text-to-qr/lib/phpqrcode/phpqrcode.php:2690–2753  ·  view source on GitHub ↗

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

($width, $frame)

Source from the content-addressed store, hash-verified

2688
2689 //----------------------------------------------------------------------
2690 public function evaluateSymbol($width, $frame)
2691 {
2692 $head = 0;
2693 $demerit = 0;
2694
2695 for($y=0; $y<$width; $y++) {
2696 $head = 0;
2697 $this->runLength[0] = 1;
2698
2699 $frameY = $frame[$y];
2700
2701 if ($y>0)
2702 $frameYM = $frame[$y-1];
2703
2704 for($x=0; $x<$width; $x++) {
2705 if(($x > 0) && ($y > 0)) {
2706 $b22 = ord($frameY[$x]) & ord($frameY[$x-1]) & ord($frameYM[$x]) & ord($frameYM[$x-1]);
2707 $w22 = ord($frameY[$x]) | ord($frameY[$x-1]) | ord($frameYM[$x]) | ord($frameYM[$x-1]);
2708
2709 if(($b22 | ($w22 ^ 1))&1) {
2710 $demerit += N2;
2711 }
2712 }
2713 if(($x == 0) && (ord($frameY[$x]) & 1)) {
2714 $this->runLength[0] = -1;
2715 $head = 1;
2716 $this->runLength[$head] = 1;
2717 } else if($x > 0) {
2718 if((ord($frameY[$x]) ^ ord($frameY[$x-1])) & 1) {
2719 $head++;
2720 $this->runLength[$head] = 1;
2721 } else {
2722 $this->runLength[$head]++;
2723 }
2724 }
2725 }
2726
2727 $demerit += $this->calcN1N3($head+1);
2728 }
2729
2730 for($x=0; $x<$width; $x++) {
2731 $head = 0;
2732 $this->runLength[0] = 1;
2733
2734 for($y=0; $y<$width; $y++) {
2735 if($y == 0 && (ord($frame[$y][$x]) & 1)) {
2736 $this->runLength[0] = -1;
2737 $head = 1;
2738 $this->runLength[$head] = 1;
2739 } else if($y > 0) {
2740 if((ord($frame[$y][$x]) ^ ord($frame[$y-1][$x])) & 1) {
2741 $head++;
2742 $this->runLength[$head] = 1;
2743 } else {
2744 $this->runLength[$head]++;
2745 }
2746 }
2747 }

Callers 1

maskMethod · 0.95

Calls 1

calcN1N3Method · 0.95

Tested by

no test coverage detected