Skip to content

Instantly share code, notes, and snippets.

@disser2
Created April 1, 2013 10:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save disser2/5284264 to your computer and use it in GitHub Desktop.
Save disser2/5284264 to your computer and use it in GitHub Desktop.
Rotating pie chart!
void setup(){
size(500,500);
}
float start = 0;
float speed = 0;
void draw(){
speed = 0.1*(mouseX-width/2)/width;
start = start + speed;
fill(0);
rect(0, 0, width, height);
int a = height/2;
int b = height/2;
int c = 300;
int d = 300;
//Teilstück 1
int farbe1 = #FF7A5F;
float prozent1 = 0.15;
//Teilstück 2
int farbe2 = #376264;
float prozent2 = 0.35;
//Teilstück 3
int farbe3 = #D2D5D6;
float prozent3 = 0.10;
//Teilstück 4
int farbe4 = #907267;
float prozent4 = 0.25;
//Teilstück 5
int farbe5 = #909587;
float prozent5 = 0.15;
fill(farbe1);
arc(a, b, c, d, start, start+2*PI*prozent1, PIE);
fill(farbe2);
arc(a, b, c, d, start+2*PI*prozent1, start+2*PI*prozent1+2*PI*prozent2, PIE);
fill(farbe3);
arc(a, b, c, d, start+2*PI*prozent1+2*PI*prozent2, start+2*PI*prozent1+2*PI*prozent2+2*PI*prozent3, PIE);
fill(farbe4);
arc(a, b, c, d, start+2*PI*prozent1+2*PI*prozent2+2*PI*prozent3, start+2*PI*prozent1+2*PI*prozent2+2*PI*prozent3+2*PI*prozent4, PIE);
fill(farbe5);
arc(a, b, c, d, start+2*PI*prozent1+2*PI*prozent2+2*PI*prozent3+2*PI*prozent4, start+2*PI*prozent1+2*PI*prozent2+2*PI*prozent3+2*PI*prozent4+2*PI*prozent5, PIE);
text("MouseX", 10, 15);
text(mouseX, 10, 30);
text("Speed", 80, 15);
text(speed, 80, 30);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment