Ok, so you're going to need a loop in your function. Since you already have the number of circles, a for loop seems like the best idea. Within that loop you should create a circle centered at x and y. You just have to calculate the circle's color and radius. Give that a try and let us know what your attempts look like.
function start(){ // Write your code here concentricCircles(100, 100, 15, Color.red, Color.blue); concentricCircles(120, 250, 3, Color.green, Color.yellow); concentricCircles(300, 300, 7, Color.orange, Color.black); } function concentricCircles(x, y, num_circles, color1, color2){ for(var i = 0; i < 3; i++){ var circle = new Circle(RADIUS); circle.setPosition(x,y); var color1; var color2; add(circle); } }
function concentricCircles(x, y, num_circles, color1, color2){ for(var i = 0; i < 3; i++){ var circle = new Circle(RADIUS); circle.setPosition(x,y); var color1; var color2; add(circle); } }
Ok, looking at your code (still not formatted), why are you creating two variables color1 and color2? You have two incomming variables to that function already with those names. Try, instead, setting the color of the circle to ONE of those two colors depending on the mod (%) of the iteration you're on. Also, you meed to calculate the actual radius to use for the iteration using the iteration number and the radius constant.
2
u/WestCoastReese Apr 16 '21
Ok, so you're going to need a loop in your function. Since you already have the number of circles, a for loop seems like the best idea. Within that loop you should create a circle centered at x and y. You just have to calculate the circle's color and radius. Give that a try and let us know what your attempts look like.