import { PixelData } from './types' ; function between ( n , min , max ) { return n >= min && n <= max ; } param i param j param minI param maxI param minJ param maxJ function isOnPosition ( i , j , minI , maxI , minJ , maxJ , includeAll = false ) { if ( includeAll ) { return between ( i , minI , maxI ) && between ( j , minJ , maxJ ) ; } return ( ( i === minI && between ( j , minJ , maxJ ) ) || ( i === maxI && between ( j , minJ , maxJ ) ) || ( j === minJ && between ( i , minI , maxI ) ) || ( j === maxJ && between ( i , minI , maxI ) ) ) ; } param i param j param size return export function getPositionDetection ( i , j , size ) { if ( isOnPosition ( i , j , 0 , 6 , 0 , 6 ) ) { return { detection : 'outer' , detectionPosition : 'tl' , } ; } if ( isOnPosition ( i , j , 1 , 5 , 1 , 5 ) ) { return { detection : 'middle' , detectionPosition : 'tl' , } ; } if ( isOnPosition ( i , j , 2 , 4 , 2 , 4 , true ) ) { return { detection : 'inner' , detectionPosition : 'tl' , } ; } if ( isOnPosition ( i , j , size - 7 , size - 1 , 0 , 6 ) ) { return { detection : 'outer' , detectionPosition : 'tr' , } ; } if ( isOnPosition ( i , j , size - 6 , size - 2 , 1 , 5 ) ) { return { detection : 'middle' , detectionPosition : 'tr' , } ; } if ( isOnPosition ( i , j , size - 5 , size - 3 , 2 , 4 , true ) ) { return { detection : 'inner' , detectionPosition : 'tr' , } ; } if ( isOnPosition ( i , j , 0 , 6 , size - 7 , size - 1 ) ) { return { detection : 'outer' , detectionPosition : 'bl' , } ; } if ( isOnPosition ( i , j , 1 , 5 , size - 6 , size - 2 ) ) { return { detection : 'middle' , detectionPosition : 'bl' , } ; } if ( isOnPosition ( i , j , 2 , 4 , size - 5 , size - 3 , true ) ) { return { detection : 'inner' , detectionPosition : 'bl' , } ; } return { detection : null , detectionPosition : null , } ; }