Gradient using pixels[]
in
Programming Questions
•
17 days ago
Hello everyone, I'm trying to make a radial gradient using pixels[] and I have to use dist() to do it from the center, but I'm not sure how to do it. So far I'm making a linear gradient, here is the code:
- PImage img;
- void setup() {
- size(800, 600);
- }
- void draw() {
- background(0);
- img = createImage(300, 300, RGB);
- for (int i = 0; i < img.pixels.length; i++) {
- float c = map(i, 0, img.pixels.length, 0, 255);
- img.pixels[i] = color(c);
- }
- image(img, 250, 150);
- }
Now, what I need to do is this:
Any help will be much appreciated, thanks.
1