Libraryless. Click here for Pure Java version (9439L/52K).
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] }
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1034808 |
Snippet name: | SinglePixelPosterizer |
Eternal ID of this version: | #1034808/11 |
Text MD5: | 2a05c9756ff4e81936c405cea005886a |
Transpilation MD5: | 83e427ef459d19f8c860df89d2937a63 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-08-21 12:45:58 |
Source code size: | 575 bytes / 20 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 184 / 323 |
Version history: | 10 change(s) |
Referenced in: | #1003674 - Standard Classes + Interfaces (LIVE continued in #1034167) #1035736 - CachedPosterizer #1035739 - DummyPosterizer - does nothing |