Last active
August 29, 2015 14:07
-
-
Save futurefabric/b552fd3f5fda3ed081c6 to your computer and use it in GitHub Desktop.
Plot points in a spiral
This file contains hidden or 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
// PLOT POINTS IN A SPIRAL | |
// By Guy Moorhouse @Futurefabric | |
float x, y; | |
int number_of_points = 280; | |
float circle_diameter = 10; | |
float plot_radius = 200; | |
float angle_incr = radians(10); | |
void setup() { | |
frameRate(100); | |
size(500,500); | |
fill(0); | |
smooth(8); | |
noStroke(); | |
} | |
void draw() { | |
background(255); | |
translate(width/2, height/2); | |
for(int i=0; i<number_of_points; i++){ | |
float ratio = i/(float)number_of_points; | |
float spiral_rad = ratio * plot_radius; | |
float angle = i*angle_incr; | |
x = cos(angle) * spiral_rad; | |
y = sin(angle) * spiral_rad; | |
ellipse(x,y,circle_diameter,circle_diameter); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment