Created
June 22, 2018 19:44
-
-
Save stevefaeembra/4a217fb7d4671334340c488fd799fc88 to your computer and use it in GitHub Desktop.
kaleidoscope draw sketch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SYMMETRY = 7 | |
def setup(): | |
size(720,720,P2D) | |
background(0) | |
def keyPressed(): | |
global SYMMETRY | |
if key == 's': | |
saveFrame("/Users/steven/tmp/screen.png") | |
print("Saved!") | |
if key == 'x': | |
background(0) | |
if key == '3': | |
SYMMETRY = 3 | |
if key == '4': | |
SYMMETRY = 4 | |
if key == '5': | |
SYMMETRY = 5 | |
if key == '6': | |
SYMMETRY = 6 | |
if key == '7': | |
SYMMETRY = 7 | |
if key == '8': | |
SYMMETRY = 8 | |
if key == '9': | |
SYMMETRY = 9 | |
def draw(): | |
global SYMMETRY | |
dangle = (2.0*PI)/float(SYMMETRY) | |
if (mousePressed): | |
fill(255) | |
noStroke() | |
dx = mouseX-(width/2.0) | |
dy = mouseY-(height/2.0) | |
r = sqrt((dx*dx)+(dy*dy)) | |
fill(255-(r/2),0,r/2) | |
ang = atan2(dy,dx) | |
for x in range(0, int(SYMMETRY)): | |
ang2 = ang+(x*dangle) | |
x2 = width/2.0 + (r*cos(ang2)) | |
y2 = height/2.0 + (r*sin(ang2)) | |
ellipse(x2,y2,11,11) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment