We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello Processing Community, I have created a sketch ,But in the Beziercurve, how to make it from the center point to the surrounding color gradient? Until fill the entire graph.how to use Processing to achieve it? waiting for your suggestions and trying my best for this... regards ...
//color from = color (232, 255, 62);
//color to = color (255, 62, 143);
//int j=4;
void setup(){
size(300, 300);
background(50);
smooth();
}
void draw(){
//for (int i=1;i<j;i++) {
// color interA=lerpColor(from, to, (float(i)/j));
// fill(interA);
fill(255);
beginShape();
vertex(50, 180);
bezierVertex(50, 150, 80, 120, 132, 150);
bezierVertex(150, 115, 210, 135, 200, 160);
bezierVertex(270, 175, 230, 235, 170, 220);
bezierVertex(170, 250, 80, 255, 70, 220);
bezierVertex(20, 240, 25, 170, 50, 180);
endShape();
//center
stroke(#ff5060);
strokeWeight(6);
point(130,190);
noLoop();
}
Answers
ok, so currently it looks like this:
what do you want it to look like?
Do you want a radial color gradient?
Do you want the gradient to be on the background, or on the cloud?
I want it to change from the center of the circle to the color of the cloud,a radial color gradient.
Demo below. I demo how to draw points on a curve and then a second demo how to color from the center to any of those points.
A second approach is to create the radial color in the background and use the cloud shape as a mask, similar to a cookie-cutter.
Kf
draw us a picture
I want to be like this, this circle is the cloud, fill the radial gradient color outward from the center point of the cloud, the color is given in the above code.
One way to do it is to modify the data so that the cloud data is centred about the point [0,0] you can then draw the shape many times with different colours at different scales to give the illusion of a flood fill from the center. The shape is then translated to where you want the cloud to be drawn.
Using a separate function to draw 'a cloud' makes it possible to draw multiple clouds of different sizes and colours.
The code below used this approach to produce this image -
This image was created with the code below.
I do not quite understand how your bezierVertex coordinate values are calculated? Can you read it for me?
In your original code the Bezier coordinates were actual screen coordinates and you said the cloud centre was at [130, 190]. To get my Bezier points I have subtracted 130 from the X value and 190 from the Y value so the cloud centre is now [0,0].
The cloud can be drawn anywhere now by translating the axis (line 28) before drawing
Thank you very much,I appreciate your reply. :)>-