A triumph of post-modern turtelistic calligraphy, a fusion of deceptively simple yet interwoven 3D mikado patterns and bold visio-aleatoric, symbolizing perhaps the convoluted path we take through life.
2011 class:
Here's Jay's turtle art:
# Draw Yin and Yang to fit the drawing window # by Jay Smith import turtle import math # Reset the turtle graphics turtle.reset() # Calculate the screen ratio of x pixels to y pixels # Screens are typically wider on the x axis than the y axis ss = turtle.screensize() ratio = float(ss[0]) / float(ss[1]) # Set the drawing window size (centered square) # percent of y direction, adjusted for x direction using screen ratio # If you don't do this, circles won't come out round ypercent = 50 xpercent = int(ypercent / ratio) turtle.setup(xpercent/100.0,ypercent/100.0) # Coordinates maximum # Greater size => better resolution size = 1000 # Set coordinate system turtle.setworldcoordinates(-size,-size,size,size) # Drawing speed (fast) turtle.tracer(10, 0) # Draw Yin turtle.color("black") turtle.penup() for deg in range(270,90,-1): x = int(size * math.cos(math.radians(deg))) y = int(size * math.sin(math.radians(deg))) turtle.goto(x,y) if (deg == 270): turtle.pendown() turtle.fill(True) for deg in range(450,270,-1): x = int((size/2) * math.cos(math.radians(deg))) y = int((size/2) * math.sin(math.radians(deg))) + (size/2) turtle.goto(x,y) for deg in range(90,270): x = int((size/2) * math.cos(math.radians(deg))) y = int((size/2) * math.sin(math.radians(deg))) - (size/2) turtle.goto(x,y) turtle.fill(False) # Draw Yang for deg in range(270,450): x = int(size * math.cos(math.radians(deg))) y = int(size * math.sin(math.radians(deg))) turtle.goto(x,y) # Draw seed turtle.color("white") turtle.penup() for deg in range(361): x = int((size/8) * math.cos(math.radians(deg))) y = int((size/8) * math.sin(math.radians(deg))) + (size/8)*4 turtle.goto(x,y) if (deg == 0): turtle.pendown() turtle.fill(True) turtle.fill(False) # Draw seed turtle.color("black") turtle.penup() for deg in range(361): x = int((size/8) * math.cos(math.radians(deg))) y = int((size/8) * math.sin(math.radians(deg))) - (size/8)*4 turtle.goto(x,y) if (deg == 0): turtle.pendown() turtle.fill(True) turtle.fill(False) # Move turtle off screen so that it isn't in the middle of finished drawing turtle.penup() turtle.goto(size*2,size*2) # Finish incomplete screen updates (if any) turtle.update() raw_input("press enter")
------------------------
And here's Tyler's homage to Picasso on a Bicyle:
4 comments:
strangely, I am enjoying this a little too much I think. -Kim
Copy and paste the following code....
from turtle import *
def draw_fractal(length, angle, level, initial_state, target, replacement, target2, replacement2):
state = initial_state
for counter in range(level):
state2 = ''
for character in state:
if character == target:
state2 += replacement
elif character == target2:
state2 += replacement2
else:
state2 += character
state = state2
# draw
for character in state:
if character == 'F':
forward(length)
elif character == '+':
right(angle)
elif character == '-':
left(angle)
if __name__ == '__main__':
delay(0)
speed(0)
hideturtle()
up(); goto(-180, 60); down();
draw_fractal(1, 60, 5, 'X++X++X', 'X', 'FX-FX++XF-XF', '', '')
exitonclick()
You can really start to see the capabilities of turtle graphics. I especially like the exitonclick()
I got the code from ActiveState which has a nice repository of code snippets
http://code.activestate.com/recipes/langs/python/
I actually found this site via the PyCon Lightning Talks on blip.tv
http://pycon.blip.tv/
hmmm didn't keep my formatting so you will have to indent it yourself.
This is fantastic :o)
Post a Comment