preserve import { PointRGBA } from '../utils/point' ; export abstract class AbstractDistanceCalculator { protected _maxDistance ! : number ; protected _whitePoint ! : { r : number ; g : number ; b : number ; a : number ; } ; constructor ( ) { this . _setDefaults ( ) ; this . setWhitePoint ( 255 , 255 , 255 , 255 ) ; } setWhitePoint ( r , g , b , a ) { this . _whitePoint = { r : r > 0 ? 255 / r : 0 , g : g > 0 ? 255 / g : 0 , b : b > 0 ? 255 / b : 0 , a : a > 0 ? 255 / a : 0 , } ; this . _maxDistance = this . calculateRaw ( r , g , b , a , 0 , 0 , 0 , 0 ) ; } calculateNormalized ( colorA , colorB ) { return ( this . calculateRaw ( colorA . r , colorA . g , colorA . b , colorA . a , colorB . r , colorB . g , colorB . b , colorB . a ) / this . _maxDistance ) ; } /**
     * Calculate raw distance (non-normalized)
     */ abstract calculateRaw ( r1 , g1 , b1 , a1 , r2 , g2 , b2 , a2 ) ; protected abstract _setDefaults ( ) ; }