Need help with drawing the Olympic Logo with C
The Olympic logo shown below consists of 5 colored rings. Mimic this logo by drawing circles with the turtle library. You can lift the pen up and down using turtle pen up and turtle pen down. To change the turtle’s pen color, use turtle set pen color. Turtle set pen color(0, 255, 0) makes the pen color entirely green, turtle set pen color(0, 0, 0) makes it black, and turtle set pen color(150, 123, 182 makes it lavender.
does the library have a draw circle routine ?
we tried to draw using the while loop
{ turtle_init(600,600); int angle = 0; while (angle < 360) { turtle_forward(1); turtle_turn_left(1); angle++; }
ok. Have you learned how to write subroutines (or functions) ? because you have to use that a few times.
Nope
Well what do you mean by "subroutines (or functions)"?
for example forward(200) is a function (that is in the library) if would be convenient if we had a circle(radius, centerx, centery) that drew a circle
I did not learn that :(
Is there any other way to do this?
btw, your circle code will make a very tiny circle. You will have to "debug" it ***Is there any other way to do this? *** yes, you copy and paste the circle code (once for each circle) but will different "start position", and line color the program will get long, but it will work.
OK I think I am ready
what is your code for a circle? Have you tested it ?
Do you mean this: { turtle_init(600,600); int angle = 0; while (angle < 360) { turtle_forward(1); turtle_turn_left(1); angle++; }
If yes, then I have tested this.
how big is the circle ?
The Olympic circle?
when you run your circle program, it draws a circle. How big is it? we have to fit 3 across on the screen
It's something like this:
ok. can you draw a circle on each side of it ? (by changing the start position, and keeping the code the same) maybe we can do it in a loop ?
I have only learned while loop.
And the if-then executions
you can make it count by doing: ct=0 while ( ct++ < 3) { do stuff }
I don't understand the command @phi
you want to draw more than 1 circle you could do something like x= 200; y= 600; ct= 0; while (ct++ < 3) { turtle_init(x,y); do the circle stuff x+= 130; (this is a guess) }
What does the x represent?
the start position for the circle. If you want different circles, we have to change it each time "through the loop"
And the y?
you have turtle_init(600,600) we want to be a able to change that (all the circles have to start at different places) so I was thinking ahead... we will also want to change the y values for the bottom 2 circles
ok
try something.it might make more sense if you experiment.
i am testing it out right now
Is it going to be something like this: #include "turtle.h" { int x=200; int y=600; int ct=0; while(ct++ <3) { turtle_init(600,600) int angle = 0; while (angle < 360) { turtle_forward(1); turtle_turn_left(1); angle++; }
I don't know what turtle_init does, but I'm thinking it erases everything on the screen and then "puts" the pen at the position you tell it. so we can't use it to move to the next circle. maybe we have to draw the circle lift the pen move to the new start position lower the pen does that make sense ?
turtle_init I think just sets the greatest and shortest amount of pixels on the screen
it must also set the start position of the pen ?
Join our real-time social learning platform and learn together with your friends!