|
mas110 exhibition
.fundamentals of computational media design.spring 2000.professor john maeda
|
|||
|   |
#the transition from a square to a triangle over time
import math
g.norefresh()
def square(x, y, size, color):
#a simple empty square
g.field(x, y, x+size, y+size, color)
g.field(x+5, y+5, x+size-5, y+size-5, 0)
g.refresh()
def to_triangle(x, y, size, L, color):
#a shape that can be square, trapazoidal, triangular
#depending on the value of L
g.pen(color)
g.field(x, y, x+size+4, y+4, color)
if L < size:
g.field(x+(L/2)+2, y+size, x+2+size-(L/2), y+size+4, color)
for b in range(0, 6):
#left edges of square/triangle
g.line(x, y+b, x+(L/2), y+size+b-1)
g.line(x+1, y+b, x+(L/2)+1, y+size+b-1)
g.line(x+2, y+b, x+(L/2)+2, y+size+b-1)
#right edges of square/triangle
g.line(x+size+4, y+b, x+4+size-(L/2), y+size+b-1)
g.line(x+size+3, y+b, x+3+size-(L/2), y+size+b-1)
g.line(x+size+2, y+b, x+2+size-(L/2), y+size+b-1)
if L > size:
g.field(x+(size/2)+2, y+size, x+2+size-(size/2), y+size+4, color)
for b in range(0, 6):
s = size/2
c = size + b - 1
#left edges of square/triangle
g.line(x, y+b, x+s, y+c)
g.line(x+1, y+b, x+s+1, y+c)
g.line(x+2, y+b, x+s+2, y+c)
#right edges of square/triangle
g.line(x+size+4, y+b, x+4+size-s, y+c)
g.line(x+size+3, y+b, x+3+size-s, y+c)
g.line(x+size+2, y+b, x+2+size-s, y+c)
def clock1(pen_color, paper_color):
#watch the square grow over time
for i in range(0, 180):
g.paper(paper_color)
#draw the square
square(40, 10, i/4, pen_color)
#draw the clock
angle = i * 2 * math.pi / 180.0
sx = math.sin(angle)
sy = math.cos(angle)
x = sx * 20
y = sy * 20
g.line(25, 70, int(x)+25, int(y)+70)
g.setPixel(int(x)+25, int(y)+74, 100)
g.refresh()
def clock2(pen_color, paper_color):
#watch the triangle form over time
for i in range(0, 180):
g.paper(paper_color)
#draw the morphing square/triangle
to_triangle(40, 10, 40, i/4, pen_color)
#draw the clock
angle = i * 2 * math.pi / 180.0
sx = math.sin(angle)
sy = math.cos(angle)
x = sx * 20
y = sy * 20
g.line(25, 70, int(x)+25, int(y)+70)
g.setPixel(int(x)+25, int(y)+74, 100)
g.refresh()
clock1(80, 10)
clock2(80, 10)
|
||