Just another site

Thought this was cool: Python turtle!

leave a comment »

I’ve recently started learning Python and was surprised and delighted to find that it has an implementation of the old Turtle program that I used to play around with back in primary. For some reason it even runs as slow as the original! (intentional?). Here is a simple geometric flower pattern I whipped up that I thought I’d share.

Seems to be lacking anti-aliasing support …

Here is the Python code.

import turtle
import math
def Petal():
    step = 4 # the larger the faster, but coarser
    radius = 100 # circle radius
    petal_arc = 0.25; # percent of full circle
    sides = 2*math.pi*radius/step
    turn = 360 / sides
    for i in range(2):
        for x in range(int(sides*petal_arc)):
        turtle.right(180 - 360*petal_arc)
num_petals = 8
for i in range(num_petals):
print "Press any key to exit ..."

from Nghia Ho:

Written by cwyalpha

八月 25, 2012 在 1:25 上午

发表在 Uncategorized


Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / 更改 )

Twitter picture

You are commenting using your Twitter account. Log Out / 更改 )

Facebook photo

You are commenting using your Facebook account. Log Out / 更改 )

Google+ photo

You are commenting using your Google+ account. Log Out / 更改 )

Connecting to %s

%d 博主赞过: