Created
February 25, 2016 01:48
-
-
Save ohmygodwin/770f3e2e861fe450a352 to your computer and use it in GitHub Desktop.
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
int[] countData; | |
int[] countData2; | |
void setup() { | |
size(680, 830); | |
loadData(); | |
} | |
void draw() { | |
background(255); | |
renderCircle(countData); | |
} | |
void loadData() { | |
//load the luddite csv | |
Table myData = loadTable("crochetData.csv"); | |
countData = new int[myData.getRowCount()]; | |
//turn the luddite data into an array for easy use | |
for (int i = 0; i < myData.getRowCount (); i++) { | |
println(myData.getRow(i).getInt(0)); //could use getString for that type | |
countData[i] = myData.getRow(i).getInt(0); | |
} | |
} | |
void renderCircle(int[] nums) { | |
for (int i = 0; i < nums.length; i++) { | |
float angle=TWO_PI/nums.length; | |
int radius = 50; | |
float radius2 = map(nums[i], 0, max(nums), 60, 400); | |
float x = -radius*sin(angle*i)+width/2; | |
float x2 = -radius2*sin(angle*i)+width/2; | |
float y = radius*cos(angle*i)+height/2; | |
float y2 = radius2*cos(angle*i)+height/2; | |
stroke(0); | |
fill(0); | |
line(x,y,x2,y2); | |
//text(nums[i],x2,y2); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment