sclass SinglePixelPosterizer is IPosterizer { int brightnessLevels; double factor1, factor2; settable double drift; // between -1 and 1, normally settable double antiDrift; // between -1 and 1 *(int *brightnessLevels) { factor1 = doubleRatio(brightnessLevels, 256); factor2 = doubleRatio(255, brightnessLevels-1); } // 0..255 to 0..255 public int get(int brightness) { var inner = brightness*factor1+drift; var posterized = ifloor(inner)+antiDrift; ret clampUByteInt(iround(posterized*factor2)); } [stdEq] }