public float patternSquareness ( ) { int patternStart = patternStart ( ) ; int patternEnd = patternEnd ( ) ; int sy = line ( patternStart ) ; int ey = line ( patternEnd ) ; int sx = column ( patternStart ) ; int ex = column ( patternEnd ) ; float actCnt = 0 ; int w = ex - sx + 1 ; int h = ey - sy + 1 ; for ( int ii = 0 ; ii < h ; ii ++ ) { for ( int jj = 0 ; jj < w ; jj ++ ) { if ( getColor ( sx + jj , sy + ii ) ) { actCnt ++ ; } } } float allCnt = getSetCount ( ) ; return actCnt / allCnt ; }
Returns 1 . 0 if pattern is square or less if not .