We are about to switch to a new forum software. Until then we have removed the registration on this forum.
i can make gray gradation ellipse using this way
int x;
int y;
int gray;
void setup() {
size(500, 500);
x = width / 2;
y = height / 2;
noStroke();
}
void draw() {
gray = 0;
for(int d = 100; d >= 10; d -= 10) {
fill(gray);
ellipse(x, y, d, d);
gray += 25;
}
}
but how to make gradation ellipse using 3 color (r,g,b)?
i mean, one ellipse with three color gradation
Answers
fill(r, g, b)
. Use three variables, r, g, and b.this way can't make one ellipse with three gradation ;(
@JJJJJJ
If I understand you correctly you wan't it to look like this?
oh!!!!!!!!!!! it looks similar!!!! but is this three color ? it looks like two color ellipse to me,. if you have any other way , plz teach me :) thank you so much X)!!
cab you draw what you want with photoshop?
@JJJJJJ
Yes and I was going to ask you to show a picture how you wanted it like koogs, but then I ran your sketch and figured you wanted it like that but with colors.
Do you want it like A, B or something else?
A
B
@prince_polka @koogs i want like this! one ellipse with three gradation!
as per prince_polka's post but changing the colours halfway through
I took some time as I rewrote it taking a different approach
@koogs @prince_polka thank you sooooo much!!!!! XD !!!!!!!
@JJJJJJJ --
Notice that the built-in function
lerpColor()
takes an amt from 0-1.0 and interpolates a color between them.Here I've written a new function
lerpColors()
that takes any number of colors (2, 3, 4... 10 etc.) and then uses lerpColor to interpolate a color that appears somewhere between any two items in the list.This function solves the "3 color" problem, but also the "n color" problem.
Here is a simple demo sketch showing how
lerpColors()
can be used -- either with any number of arguments, or by passing an array of colors as a single argument.@Jeremydouglas, that's very cool and easy to use, I made some disco stuff with it
@prince_polka -- Nice use of random color generation, transparency, and noise.
I particularly enjoyed playing with the noise mode.
Impressive! Great work you two \m/
Kf
Beautiful. Some lines of code can produce wonderful effects. ^:)^
@jeremydouglas I made a "recolouring" shader that can do gradients (or other patterns) using a spritesheet of grayscale images, instead of switch/case. Transparency needs adjusting though gradients.zip