Thought this was cool: Python turtle!
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 turtle.speed('fastest') 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.forward(step) turtle.right(turn) turtle.right(180 - 360*petal_arc) num_petals = 8 for i in range(num_petals): turtle.home() turtle.setheading(0) turtle.right(360*i/num_petals) Petal() print "Press any key to exit ..." raw_input()
from Nghia Ho: http://nghiaho.com/?p=1603