# Drawing A Petal with Turtle Graphics

Page 1 of 1

## 0 Replies - 665 Views - Last Post: 14 October 2013 - 11:39 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=331526&amp;s=b5b6a06521cd83e19724f6caa40720cf&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 cheesecakefan741

Reputation: 0
• Posts: 2
• Joined: 25-October 12

# Drawing A Petal with Turtle Graphics

Posted 14 October 2013 - 11:39 AM

I am having trouble trying to reconnecting the arcs to create a petal.

```# Load TurtleWorld functions
from swampy.TurtleWorld import *
import math

# TODO: Arc function
def draw_arc(t,r,theta,seg_len):
pd(t)
arc_len=(2*math.pi*r)*(theta/360.0)
num_seg=int(arc_len/seg_len)
dang=theta/num_seg
for i in range (num_seg):
fd(t,seg_len)
rt(t,dang)

# TODO: Petal function
def draw_petal(t,r,theta,seg_len):

draw_arc(t,r,theta,seg_len)
rt(t,190-theta)
draw_arc(t,r,theta,seg_len)
rt(t,190-theta)

# TODO: Flower function
#def draw_flower(t,num_petals):
#for i in range(num_petals):
# draw_petal(t,r,theta,seg_len)
# rt(t,n)

# Main program function
def main():
# TurtleWorld objects
world = TurtleWorld()
turtle = Turtle()
turtle.delay = 0.01

# Flower variables
num_petals= int(raw_input('Enter the number of petals '))

# Draw graphics
draw_petal(turtle, 100, 90, 4)
#draw_flower(turtle,num_petals)

# Press enter to exit
key = raw_input('Press enter to exit')
world.destroy()

#Call main program
main()

```

Is This A Good Question/Topic? 0

Page 1 of 1

 .related ul { list-style-type: circle; font-size: 12px; font-weight: bold; } .related li { margin-bottom: 5px; background-position: left 7px !important; margin-left: -35px; } .related h2 { font-size: 18px; font-weight: bold; } .related a { color: blue; }