We are about to switch to a new forum software. Until then we have removed the registration on this forum.
So far I've managed to create with the help of some forum programs for color grading.
static final int ribbon_length = 255, H = 200;
void setup() {
size(ribbon_length, H);
}
void draw() {
float p = 0.5;
int up_y = 10;
int widthh = 1;
int height = 180;
float a = pow (ribbon_length, 1-p);
float colour = 0;
for (int step = 0; step <= 255; step++) {
colour = a <em> pow (step, p);
fill(colour);
rect(widthh</em>step, up_y, widthh, height);
noStroke();
//save("cross20.png");
}
}
My next step is to creat a color gradation of two colors in irregular shape and to have the opportunity to shift the gradient within the shape. An example is the following code.
void setup() { size(400, 400); } void draw() { background(0); translate(width/2, height/2); noStroke(); for (int i=0;i<255;i++) { scale(.95); fill(200-10*i, 200, (i>=10)?(20*(i-10)):0); beginShape(); vertex(-180, -100); vertex(-190, -120); vertex(-150, -150); vertex(100, -100); vertex(100, 100); vertex(0, 150); vertex(-110, 100); vertex(-120, 100); vertex(-130, 100); vertex(-140, 100); vertex(-150, 100); endShape(CLOSE); } noLoop(); }
In the above code just trying to be able to change the possision of color gradient, with a variable. Any help or ideas?
Answers
Maybe I got you wrong, but you are already positioning the gradient shape. translate() basically moves the coordinate system to the specified point, just replace width/2 and height/2 with some variables.
Example with you code:
Improved code (utilizing openGL's color interpolation):
Btw.: The latter example runs much faster.
Also take a look at the To newcomers in this forum: read attentively these instructions topic, it explains how to format code... (using the pre tag is OK, but not need for html and body tags! And no p or br are necessary...)
I will try to show you what I mean with pictures. I have the following code and changing the number p, changes the picture as below. The three images are numbers 0.5 - 2 and 5.
I try to do the same in programma with the shape.
Any way thank you for the code.
Although PhiLho is totally right, it's not the solution to your problem. Never a good idea to mark a thread as answered before someone helped you with your actual problem.
You can create shaped gradients using Processing's mask() method. An unoptimized example: