Beginner: Drawing gradients
in
Programming Questions
•
1 year ago
Hello everyone, first time here. I'm just working through Processing: A programming handbook and am getting a bit confused.
I'm drawing gradients using lines, and I'd like to draw a gradient from one colour to another. I can do this if I just want the gradient to be as large as the "rectangle" I'm drawing e.g.
- colorMode(HSB, 360, 100, 100);
- for (int i = 0; i <= 100; i++) {
- stroke(i+200, 100, 100);
- line(0, 200 + i, 200, 200 + i);
- }
But if I wanted my "rectangle" to be say 200px in height changing it will change my gradient shift too. I'm having a hard time understanding what I'd have to do to create a rectangle and set a gradient from one value to another inside it which isn't dependant on the size.
Sorry if the question seems so simple, as I am new to all of this. Hope it all makes sense, thanks!
1