Question

See Above for description

However my code is adding circles to the array in incorrect colours:

I have a Color baseColor, which contains a variable int baseGreen. This int is reduced during each recursive call, with the intention of changing the type of green for each set of 3 circles.

If anyone is able to hazard a guess as to why this is happening I would be very grateful. Thanks.

Was it helpful?

Solution

tracking base color is unnecessary as you are passing it into your method.

this is a simple way of make the color progressively darker

public void createCircles(int x, int y, int rad, Color parentColor){
    Circle myCircle = new Circle(x, y, rad, parentColor);
    ...
    if(!(rad<1)){
        ...
        Color myColor = parentColor.darker();
        createCircles(x - (2*rad), y, rad/3, myColor);
        createCircles(x, y, rad/3, myColor);
        createCircles(x + (2*rad), y, rad/3, myColor);
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top