function computeDimension(topLeft, topRight, bottomLeft, matrix) {
                        var moduleSize = (sum(countBlackWhiteRun(topLeft, bottomLeft, matrix, 5)) / 7 + // Divide by 7 since the ratio is 1:1:3:1:1
                            sum(countBlackWhiteRun(topLeft, topRight, matrix, 5)) / 7 +
                            sum(countBlackWhiteRun(bottomLeft, topLeft, matrix, 5)) / 7 +
                            sum(countBlackWhiteRun(topRight, topLeft, matrix, 5)) / 7) / 4;
                        if (moduleSize < 1) {
                            throw new Error("Invalid module size");
                        }
                        var topDimension = Math.round(distance(topLeft, topRight) / moduleSize);
                        var sideDimension = Math.round(distance(topLeft, bottomLeft) / moduleSize);
                        var dimension = Math.floor((topDimension + sideDimension) / 2) + 7;
                        switch (dimension % 4) {
                            case 0:
                                dimension++;
                                break;
                            case 2:
                                dimension--;
                                break;
                        }
                        return {
                            dimension: dimension,
                            moduleSize: moduleSize
                        };
                    }
// Computes the dimension (number of modules on a side) of the QR Code based on the position of the finder patterns
Computes the dimension (number of modules on a side) of the QR Code based on the position of the finder patterns
Computes the dimension ( number of modules on a side ) of the QR Code based on the position of the finder patterns
function computeDimension(topLeft, topRight, bottomLeft, matrix) {
                        var moduleSize = (sum(countBlackWhiteRun(topLeft, bottomLeft, matrix, 5)) / 7 + 
                            sum(countBlackWhiteRun(topLeft, topRight, matrix, 5)) / 7 +
                            sum(countBlackWhiteRun(bottomLeft, topLeft, matrix, 5)) / 7 +
                            sum(countBlackWhiteRun(topRight, topLeft, matrix, 5)) / 7) / 4;
                        if (moduleSize < 1) {
                            throw new Error("Invalid module size");
                        }
                        var topDimension = Math.round(distance(topLeft, topRight) / moduleSize);
                        var sideDimension = Math.round(distance(topLeft, bottomLeft) / moduleSize);
                        var dimension = Math.floor((topDimension + sideDimension) / 2) + 7;
                        switch (dimension % 4) {
                            case 0:
                                dimension++;
                                break;
                            case 2:
                                dimension--;
                                break;
                        }
                        return {
                            dimension: dimension,
                            moduleSize: moduleSize
                        };
                    }
function computeDimension ( topLeft , topRight , bottomLeft , matrix ) { var moduleSize = ( sum ( countBlackWhiteRun ( topLeft , bottomLeft , matrix , 5 ) ) / 7 + sum ( countBlackWhiteRun ( topLeft , topRight , matrix , 5 ) ) / 7 + sum ( countBlackWhiteRun ( bottomLeft , topLeft , matrix , 5 ) ) / 7 + sum ( countBlackWhiteRun ( topRight , topLeft , matrix , 5 ) ) / 7 ) / 4 ; if ( moduleSize < 1 ) { throw new Error ( "Invalid module size" ) ; } var topDimension = Math . round ( distance ( topLeft , topRight ) / moduleSize ) ; var sideDimension = Math . round ( distance ( topLeft , bottomLeft ) / moduleSize ) ; var dimension = Math . floor ( ( topDimension + sideDimension ) / 2 ) + 7 ; switch ( dimension % 4 ) { case 0 : dimension ++ ; break ; case 2 : dimension -- ; break ; } return { dimension : dimension , moduleSize : moduleSize } ; }
Computes the dimension (number of modules on a side) of the QR Code based on the position of the finder patterns
Computes the dimension ( number of modules on a side ) of the QR Code based on the position of the finder patterns
// Divide by 7 since the ratio is 1:1:3:1:1