lib/matrix.js
function fillAlignAndTiming(matrix) {
    var N = matrix.length;
    if (N > 21) {
        var len = N - 13;
        var delta = Math.round(len / Math.ceil(len / 28));
        if (delta % 2) delta++;
        var res = [];
        for (var p = len + 6; p > 10; p -= delta) {
            res.unshift(p);
        }
        res.unshift(6);
        for (var i = 0; i < res.length; i++) {
            for (var j = 0; j < res.length; j++) {
                var x = res[i], y = res[j];
                if (matrix[x][y]) continue;
                for (var r = -2; r <=2 ; r++) {
                    for (var c = -2; c <=2 ; c++) {
                        var max = Math.max(r, c);
                        var min = Math.min(r, c);
                        var pixel = (max == 1 && min >= -1) || (min == -1 && max <= 1) ? 0x80 : 0x81;
                        matrix[x + r][y + c] = pixel;
                    }
                }
            }
        }
    }
    for (var i = 8; i < N - 8; i++) {
        matrix[6][i] = matrix[i][6] = i % 2 ? 0x80 : 0x81;
    }
}
function fillAlignAndTiming(matrix) {
    var N = matrix.length;
    if (N > 21) {
        var len = N - 13;
        var delta = Math.round(len / Math.ceil(len / 28));
        if (delta % 2) delta++;
        var res = [];
        for (var p = len + 6; p > 10; p -= delta) {
            res.unshift(p);
        }
        res.unshift(6);
        for (var i = 0; i < res.length; i++) {
            for (var j = 0; j < res.length; j++) {
                var x = res[i], y = res[j];
                if (matrix[x][y]) continue;
                for (var r = -2; r <=2 ; r++) {
                    for (var c = -2; c <=2 ; c++) {
                        var max = Math.max(r, c);
                        var min = Math.min(r, c);
                        var pixel = (max == 1 && min >= -1) || (min == -1 && max <= 1) ? 0x80 : 0x81;
                        matrix[x + r][y + c] = pixel;
                    }
                }
            }
        }
    }
    for (var i = 8; i < N - 8; i++) {
        matrix[6][i] = matrix[i][6] = i % 2 ? 0x80 : 0x81;
    }
}
function fillAlignAndTiming ( matrix ) { var N = matrix . length ; if ( N > 21 ) { var len = N - 13 ; var delta = Math . round ( len / Math . ceil ( len / 28 ) ) ; if ( delta % 2 ) delta ++ ; var res = [ ] ; for ( var p = len + 6 ; p > 10 ; p -= delta ) { res . unshift ( p ) ; } res . unshift ( 6 ) ; for ( var i = 0 ; i < res . length ; i ++ ) { for ( var j = 0 ; j < res . length ; j ++ ) { var x = res [ i ] , y = res [ j ] ; if ( matrix [ x ] [ y ] ) continue ; for ( var r = - 2 ; r <= 2 ; r ++ ) { for ( var c = - 2 ; c <= 2 ; c ++ ) { var max = Math . max ( r , c ) ; var min = Math . min ( r , c ) ; var pixel = ( max == 1 && min >= - 1 ) || ( min == - 1 && max <= 1 ) ? 0x80 : 0x81 ; matrix [ x + r ] [ y + c ] = pixel ; } } } } } for ( var i = 8 ; i < N - 8 ; i ++ ) { matrix [ 6 ] [ i ] = matrix [ i ] [ 6 ] = i % 2 ? 0x80 : 0x81 ; } }
{{{1 Put align and timinig
{{{ 1 Put align and timinig