Open oldoc63 opened 1 year ago
def setup():
size(600,600)
def draw():
#set background white
background(255)
for x in range(20):
for y in range(20):
rect(30*x,30*y,25,25)
def setup():
size(600,600)
rectMode(CENTER)
colorMode(HSB)
def draw():
#set background black
background(0)
translate(20,20)
for x in range(30):
for y in range(30):
d = dist(30*x,30*y,mouseX,mouseY)
fill(0.5*d,255,255)
rect(30*x,30*y,25,25)
def setup():
size(600,600)
rectMode(CENTER)
t = 0
def draw():
global t
translate(width/2,height/2)
rotate(radians(t))
tri(200) #draw the equilateral triangle
t += 0.5
def tri(length):
'''Draws an equilateral triangle
around center of triangle'''
triangle(0,-length,
-length*sqrt(3)/2, length/2,
length*sqrt(3)/2, length/2)
def setup():
size(600,600)
rectMode(CENTER)
t = 0
def draw():
global t
background(255)#white
translate(width/2,height/2)
for i in range(90):
#space the triangles evenly
#around the circle
rotate(radians(360/90))
pushMatrix() #save this orientation
#go to circumference of circle
translate(200,0)
#spin each triangle
rotate(radians(t))
#draw the triangle
tri(100)
#return to saved orientation
popMatrix()
t += 0.5
def tri(length):
noFill() #makes the triangle transparent
triangle(0,-length,
-length*sqrt(3)/2, length/2,
length*sqrt(3)/2, length/2)
rotate(radians(t+1*360/90))
.def setup():
size(600,600)
rectMode(CENTER)
colorMode(HSB) #for the rainbow colors
strokeWeight(2) #a little thicker line
t = 0
def draw():
global t
background(255)#white
translate(width/2,height/2)
for i in range(90):
#space the triangles evenly
#around the circle
rotate(radians(360/90))
pushMatrix() #save this orientation
#go to circumference of circle
translate(200,0)
#add color to each triangle
stroke(2*i,255,255)
#spin each triangle
rotate(radians(t+2*i*360/90))
#draw the triangle
tri(100)
#return to saved orientation
popMatrix()
t += 0.5
def tri(length):
noFill() #makes the triangle transparent
triangle(0,-length,
-length*sqrt(3)/2, length/2,
length*sqrt(3)/2, length/2)
Drawing a Circle