lumpynose

codingMath03b

May 10th, 2015
336
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.44 KB | None | 0 0
  1. float centerY, centerX, offset, speed, angle;
  2. float baseRadius;
  3.  
  4. void setup() {
  5.   size(400, 400);
  6.   noStroke();
  7.   fill(0);
  8.  
  9.   centerY = height / 2;
  10.   centerX = width / 2;
  11.   offset = 50; // amplitude
  12.   speed = 0.1;
  13.   angle = 0;
  14.  
  15.   baseRadius = 100;
  16. }
  17.  
  18. void draw() {
  19.   background(255); // clear canvas
  20.  
  21.   float radius = baseRadius + (sin(angle) * offset);
  22.  
  23.   ellipse(centerX, centerY, radius, radius);
  24.  
  25.   angle += speed;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment