1

How do I do a lot of ellipses with the while-loop and change the color grey from the middle to the outside a little brighter?

I've tried a bit:

size(200,200);
background(255);
float width-ellipse = 20;
float height-ellipse = 20;
while(w < 200)){
    stroke(0);
    fill(125);
    ellipse(100,100,w,h);
    w = w + 20;
    w++;
    h = h + 20;
    h++;
}
3
  • 1
    If you draw from the inside out, your outer circles will be covering your inner circles. Instead of drawing from the inside out, draw from the outside in. Also please try to be more specific with your questions in the future: explain exactly what you expected your code to do, what it does instead, and which line of code is behaving differently from what you expected. May 16, 2018 at 16:22
  • Yes I thought I have to draw the circle from inside out. That was my problem and thank you for your help. Also I will try to be more specific in the future to make it easier to understand the problem. Thanks for the advise. Have a good day!
    – Serkan K.
    May 16, 2018 at 17:33
  • If you plan to animate radial gradients later on have a look at this answer. Jan 30, 2019 at 10:19

1 Answer 1

1

There probably is a better way to do this. However, this may work for you. Draw a darker smaller ellipse centered in the middle of the previous ellipse then repeat. Take a look here: https://forum.processing.org/one/topic/circle-gradient.html

Also, your while loop has 2 closing "))" parenthesis. Try the following:

void draw() {
    background(50);
    noStroke();
    for (int p = 0; p < 500; p+=100) {
        for (int i = 1; i < 100; i++) {
            fill(float(150 - i));
            ellipse(200, 100+p, 400-i*2, 120-(i*1.2));
        }
    }
}
1
  • @SerkanK. If this answer helped you, please mark it as accepted so your question stops showing up as needing an answer. May 16, 2018 at 16:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.