I am trying to make a flower, where yellow lines are drawn out from its approximate center, for the entire circumference.
The issue I have is getting a line to draw out, go to center, and draw out again the same length, but be 10 degrees greater than the previous one.
I can't wrap my mind around how to do this, the line just either bounces back and forth repeatedly, OR it pivots around the side (such as when I make a pointed shape).
So how do I get this yellow line to call back, and incrementally feather out / get that pointed shape to continually draw itself the full 360 degrees?
This is my first 'real' program I guess. I have no prior programing experience, and have only started doing this for a few days. The code I used in the function "draw_feather()" is from another site, because I didn't know how to pivot a triangle in a circle.
for i in range(1,37):
if abs(ink.pos()) < 1:
window = turtle.Screen()
R = turtle.Turtle()
G = turtle.Turtle()
B = turtle.Turtle()
Stem = turtle.Turtle()
Feather = turtle.Turtle()
Below is a rework of your code to literally do what you described:
import turtle def draw_flower(ink): ink.up() ink.home() for degrees in range(10, 370, 10): ink.down() ink.forward(200) ink.up() ink.home() # resets angle to 0 degrees ink.left(degrees) # so absolute angle, not relative def draw_stem(ink): ink.goto(1, -400) ink.home() ink.goto(5, -400) ink.home() ink.goto(3, -400) def Draw(): window = turtle.Screen() window.bgcolor("white") stem = turtle.Turtle() stem.color("green") stem.speed("fast") draw_stem(stem) flower = turtle.Turtle() flower.color("yellow") flower.speed("fastest") draw_flower(flower) Draw() turtle.done()
Simply go to the center of the screen, draw a yellow line, reset to the center of the screen, turn slightly and repeat. Note that the
turtle.home() method affects the angle of the turtle so we have to adjust for that:
Also, 100 doesn't mean anything to
turtle.speed() beyond that it's greater than 10 -- use the symbolic arguments to make clear your intention.