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

Method mask

text-to-qr/lib/phpqrcode/bindings/tcpdf/qrcode.php:1233–1263  ·  view source on GitHub ↗

* mask * @param int $width * @param array $frame * @param int $level * @return array best mask */

($width, $frame, $level)

Source from the content-addressed store, hash-verified

1231 * @return array best mask
1232 */
1233 protected function mask($width, $frame, $level) {
1234 $minDemerit = PHP_INT_MAX;
1235 $bestMaskNum = 0;
1236 $bestMask = array();
1237 $checked_masks = array(0, 1, 2, 3, 4, 5, 6, 7);
1238 if (QR_FIND_FROM_RANDOM !== false) {
1239 $howManuOut = 8 - (QR_FIND_FROM_RANDOM % 9);
1240 for ($i = 0; $i < $howManuOut; ++$i) {
1241 $remPos = rand (0, count($checked_masks)-1);
1242 unset($checked_masks[$remPos]);
1243 $checked_masks = array_values($checked_masks);
1244 }
1245 }
1246 $bestMask = $frame;
1247 foreach ($checked_masks as $i) {
1248 $mask = array_fill(0, $width, str_repeat("\0", $width));
1249 $demerit = 0;
1250 $blacks = 0;
1251 $blacks = $this->makeMaskNo($i, $width, $frame, $mask);
1252 $blacks += $this->writeFormatInformation($width, $mask, $i, $level);
1253 $blacks = (int)(100 * $blacks / ($width * $width));
1254 $demerit = (int)((int)(abs($blacks - 50) / 5) * N4);
1255 $demerit += $this->evaluateSymbol($width, $mask);
1256 if ($demerit < $minDemerit) {
1257 $minDemerit = $demerit;
1258 $bestMask = $mask;
1259 $bestMaskNum = $i;
1260 }
1261 }
1262 return $bestMask;
1263 }
1264
1265 // - - - - - - - - - - - - - - - - - - - - - - - - -
1266

Callers 1

encodeMaskMethod · 0.95

Calls 4

makeMaskNoMethod · 0.95
evaluateSymbolMethod · 0.95
countFunction · 0.85

Tested by

no test coverage detected