Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- float[] scal = new float[num];
- PVector[] dots = new PVector[num];
- boolean save = false;
- void setup() {
- size(500, 500);
- background(20);
- fill(#FFA41A);
- noFill();
- stroke(#FFA41A);
- strokeWeight(1);
- strokeJoin(ROUND);
- radius = width*.25;
- createSpikeyThing();
- }
- void draw() {
- background(20);
- drawSpikeyThing();
- theta += 0.0523;
- if (save) {
- if (frameCount%4==0 && frameCount<fc+121) saveFrame("image-###.gif");
- }
- }
- void createSpikeyThing() {
- float angle = 3*PI/2;
- for (int i=0; i<num; i++) {
- if (i%(step)==0) {
- scal[i] = random(1.1, 1.4);
- }
- else {
- scal[i] = 1;
- }
- float px = width/2 + sin(angle)*radius*scal[i];
- float py = height/2 + cos(angle)*radius*scal[i];
- dots[i]= new PVector(px, py);
- angle+=TWO_PI/num;
- }
- }
- void drawSpikeyThing() {
- float c = 0;
- for (int i=0; i<num; i++) {
- if (i%(step*2)==0) {
- float s = map(sin(theta+(TWO_PI/step)*c), -1, 1, 1, 1.4);
- dots[i].x = width/2 + sin(3*PI/2 + i*(TWO_PI/num))*radius*scal[i]*s;
- dots[i].y = height/2 + cos(3*PI/2 + i*(TWO_PI/num))*radius*scal[i]*s;
- c++;
- }
- }
- beginShape();
- for (int i=0; i<num; i++) {
- if (i==0) vertex(dots[i].x, dots[i].y);
- vertex(dots[i].x, dots[i].y);
- if (i==num-1) vertex(dots[i].x, dots[i].y);
- }
- endShape(CLOSE);
- }
- void mouseReleased() {
- createSpikeyThing();
- }
- void keyPressed() {
- fc = frameCount;
- save = true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement