MCPcopy Create free account
hub / github.com/benfry/processing4 / makeGradientLab

Method makeGradientLab

app/src/processing/app/ui/Theme.java:230–252  ·  view source on GitHub ↗
(String attribute, int wide, int high)

Source from the content-addressed store, hash-verified

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

Callers 1

makeGradientMethod · 0.95

Calls 8

xyzToLabMethod · 0.95
rgbToXyzMethod · 0.95
getColorMethod · 0.95
argbMethod · 0.95
xzyToRgbMethod · 0.95
labToXyzMethod · 0.95
getRasterMethod · 0.45
fillMethod · 0.45

Tested by

no test coverage detected