Skip to content

Commit 8650ed2

Browse files
committed
Added gradient example
1 parent 318b314 commit 8650ed2

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

Design/Gradient/Gradient.pde

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
2+
/*
3+
GRADIENT
4+
Jeff Thompson | 2015 | www.jeffreythompson.org
5+
6+
Draws a gradient between two colors using a series
7+
of 1px-thick lines. The color is changed gradually
8+
using lerpColor(), which takes two colors and a
9+
value between 0-1 to set an intermediate color.
10+
11+
*/
12+
13+
color start = color(25,180,255);
14+
color end = color(215,150,0);
15+
16+
17+
void setup() {
18+
size(800,800);
19+
20+
// no background() command - gradient instead!
21+
for (int y=0; y<height; y++) {
22+
23+
// we need a value between 0-1 for lerpColor()
24+
// here we use map() to convert y into the right range
25+
float interval = map(y, 0,height, 0,1);
26+
27+
// set the color and draw a horizontal line
28+
color c = lerpColor(start, end, interval);
29+
stroke(c);
30+
line(0,y, width,y);
31+
}
32+
}
33+
34+

Design/Gradient/sketch.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
mode.id=processing.mode.java.JavaMode
2+
mode=Java (2.0)

0 commit comments

Comments
 (0)