src/lib/QrScannerWorker.js
function countBlackWhiteRun(origin, end, matrix, length) {
        const rise = end.y - origin.y;
        const run = end.x - origin.x;
        const towardsEnd = countBlackWhiteRunTowardsPoint(origin, end, matrix, Math.ceil(length / 2));
        const awayFromEnd = countBlackWhiteRunTowardsPoint(origin, { x: origin.x - run, y: origin.y - rise }, matrix, Math.ceil(length / 2));
        const middleValue = towardsEnd.shift() + awayFromEnd.shift() - 1; // Substract one so we don't double count a pixel
        return awayFromEnd.concat(middleValue).concat(...towardsEnd);
    }
function countBlackWhiteRun(origin, end, matrix, length) {
        const rise = end.y - origin.y;
        const run = end.x - origin.x;
        const towardsEnd = countBlackWhiteRunTowardsPoint(origin, end, matrix, Math.ceil(length / 2));
        const awayFromEnd = countBlackWhiteRunTowardsPoint(origin, { x: origin.x - run, y: origin.y - rise }, matrix, Math.ceil(length / 2));
        const middleValue = towardsEnd.shift() + awayFromEnd.shift() - 1; // Substract one so we don't double count a pixel
        return awayFromEnd.concat(middleValue).concat(...towardsEnd);
    }
function countBlackWhiteRun ( origin , end , matrix , length ) { const rise = end . y - origin . y ; const run = end . x - origin . x ; const towardsEnd = countBlackWhiteRunTowardsPoint ( origin , end , matrix , Math . ceil ( length / 2 ) ) ; const awayFromEnd = countBlackWhiteRunTowardsPoint ( origin , { x : origin . x - run , y : origin . y - rise } , matrix , Math . ceil ( length / 2 ) ) ; const middleValue = towardsEnd . shift ( ) + awayFromEnd . shift ( ) - 1 ; // Substract one so we don't double count a pixel return awayFromEnd . concat ( middleValue ) . concat ( ... towardsEnd ) ; }
Takes an origin point and an end point and counts the sizes of the black white run in the origin point along the line that intersects with the end point. Returns an array of elements, representing the pixel sizes of the black white run. Takes a length which represents the number of switches from black to white to look for.
Takes an origin point and an end point and counts the sizes of the black white run in the origin point along the line that intersects with the end point . Returns an array of elements representing the pixel sizes of the black white run . Takes a length which represents the number of switches from black to white to look for .