MCPcopy Index your code
hub / github.com/processing/processing / makeGradient

Method makeGradient

app/src/processing/app/Mode.java:875–905  ·  view source on GitHub ↗
(String attribute, int wide, int high)

Source from the content-addressed store, hash-verified

873
874
875 public Image makeGradient(String attribute, int wide, int high) {
876 int top = getColor(attribute + ".gradient.top").getRGB();
877 int bot = getColor(attribute + ".gradient.bottom").getRGB();
878
879// float r1 = (top >> 16) & 0xff;
880// float g1 = (top >> 8) & 0xff;
881// float b1 = top & 0xff;
882// float r2 = (bot >> 16) & 0xff;
883// float g2 = (bot >> 8) & 0xff;
884// float b2 = bot & 0xff;
885
886 BufferedImage outgoing =
887 new BufferedImage(wide, high, BufferedImage.TYPE_INT_RGB);
888 int[] row = new int[wide];
889 WritableRaster wr = outgoing.getRaster();
890 for (int i = 0; i < high; i++) {
891// Arrays.fill(row, (255 - (i + GRADIENT_TOP)) << 24);
892// int r = (int) PApplet.map(i, 0, high-1, r1, r2);
893 int rgb = PApplet.lerpColor(top, bot, i / (float)(high-1), PConstants.RGB);
894 Arrays.fill(row, rgb);
895// System.out.println(PApplet.hex(row[0]));
896 wr.setDataElements(0, i, wide, 1, row);
897 }
898// Graphics g = outgoing.getGraphics();
899// for (int i = 0; i < steps; i++) {
900// g.setColor(new Color(1, 1, 1, 255 - (i + GRADIENT_TOP)));
901// //g.fillRect(0, i, EditorButton.DIM, 10);
902// g.drawLine(0, i, EditorButton.DIM, i);
903// }
904 return outgoing;
905 }
906
907
908 // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Callers 5

PdeTextAreaMethod · 0.95
updateModeMethod · 0.95
updateModeMethod · 0.95
ManagerTabsMethod · 0.80
EditorToolbarMethod · 0.80

Calls 4

getColorMethod · 0.95
lerpColorMethod · 0.95
getRasterMethod · 0.45
fillMethod · 0.45

Tested by

no test coverage detected