| 228 | |
| 229 | |
| 230 | static private Image makeGradientLab(String attribute, int wide, int high) { |
| 231 | double[] top = xyzToLab(rgbToXyz(getColor(attribute + ".gradient.top"))); |
| 232 | double[] bot = xyzToLab(rgbToXyz(getColor(attribute + ".gradient.bottom"))); |
| 233 | |
| 234 | double diffL = bot[0] - top[0]; |
| 235 | double diffA = bot[1] - top[1]; |
| 236 | double diffB = bot[2] - top[2]; |
| 237 | |
| 238 | BufferedImage outgoing = |
| 239 | new BufferedImage(wide, high, BufferedImage.TYPE_INT_RGB); |
| 240 | int[] row = new int[wide]; |
| 241 | WritableRaster wr = outgoing.getRaster(); |
| 242 | for (int i = 0; i < high; i++) { |
| 243 | double amt = i / (high - 1.0); |
| 244 | double el = top[0] + amt * diffL; |
| 245 | double ay = top[1] + amt * diffA; |
| 246 | double be = top[2] + amt * diffB; |
| 247 | int rgb = argb(xzyToRgb(labToXyz(el, ay, be))); |
| 248 | Arrays.fill(row, rgb); |
| 249 | wr.setDataElements(0, i, wide, 1, row); |
| 250 | } |
| 251 | return outgoing; |
| 252 | } |
| 253 | |
| 254 | |
| 255 | // https://web.archive.org/web/20060213080500/http://www.easyrgb.com/math.php?MATH=M2#text2 |