vendor/bacon/bacon-qr-code/src/BaconQrCode/Encoder/MaskUtil.php

(开头部分) 1KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

<?php
/**
 * BaconQrCode
 *
 * @link      http://github.com/Bacon/BaconQrCode For the canonical source repository
 * @copyright 2013 Ben 'DASPRiD' Scholzen
 * @license   http://opensource.org/licenses/BSD-2-Clause Simplified BSD License
 */

namespace BaconQrCode\Encoder;

use BaconQrCode\Common\BitUtils;

/**
 * Mask utility.
 */
class MaskUtil
{
    /**#@+
     * Penalty weights from section 6.8.2.1
     */
    const N1 = 3;
    const N2 = 3;
    const N3 = 40;
    const N4 = 10;
    /**#@-*/

    /**
     * Applies mask penalty rule 1 and returns the penalty.
     *
     * Finds repetitive cells with the same color and gives penalty to them.
     * Example: 00000 or 11111.
     *
     * @param  ByteMatrix $matrix
     * @return integer
     */
    public static function applyMaskPenaltyRule1(ByteMatrix $matrix)
    {
        return (
            self::applyMaskPenaltyRule1Internal($matrix, true)
            + self::applyMaskPenaltyRule1Internal($matrix, false)
        );
    }

    /**
     * Applies mask penalty rule 2 and returns the penalty.
     *
     * Finds 2x2 blocks with the same color and gives penalty to them. This is
     * actually equivalent to the spec's rule, which is to find MxN blocks and
     * give a penalty proportional to (M-1)x(N-1), because this is the number of
     * 2x2 blocks inside such a block.
     *
     * @param  ByteMatrix $matrix
     * @return integer
     */
    public static function applyMaskPenaltyRule2(ByteMatrix $matrix)
    {
        $penalty = 0;
        $array   = $matrix->getArray();
        $width   = $matrix->getWidth();

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。