lumpynose

codingMath03a

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