Hi everyone – i am trying to draw a radial gradient in the background of my sketch – and I am trying to achieve this by manipulating the pixels like in an example by daniel shiffman – so far so good – it works as it should! BUT – now I want the radial gradient to be red – and the outer parts of the sketch to be black… So just as in the code example below, but inverted! I tried many things – experimented with the RGB values – inverted the values of the dist(); function – thought of map(); – tried to change the calculations for the pixels – nothing worked out – what am I missing or can somebody explain it to me? I know what the code does – but cant get it inverted… does someone have an idea and can it explain it to me? I am really stuck…
void setup() {
size(1080, 1080);
}
void draw() {
loadPixels();
for (int x = 0; x < width; x++) {
for (int y = 0; y < height; y++) {
float d = dist(width/2, height/2, x, y);
pixels[x+y*width] = color(255,d,255);
}
}
updatePixels();
}
Thank you for any kind of help!