Advertisement
Guest User

Untitled

a guest
Oct 20th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3.  
  4. <head>
  5. <title>Smiley</title>
  6. <script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.3/p5.js"></script>
  7.  
  8. <script>
  9. var centerX, centerY;
  10. var scale;
  11. var angle; // don't worry about this
  12.  
  13. function setup() {
  14. createCanvas(300, 400);
  15. centerX = 150; // this could have been any point, but we are
  16. centerY = 200; // deciding to use the middle of the yellow ellipse
  17. scale = 1;
  18. angle = 0;
  19. }
  20.  
  21. function draw() {
  22. background(255);
  23.  
  24. // head
  25. fill(255, 255, 0);
  26. ellipse(150, 200, 200, 200);
  27.  
  28. // eyes
  29. fill(0);
  30. ellipse(115,165,30,30); // left
  31. ellipse(185,165,30,30); // right
  32.  
  33. // mouth
  34. fill(255);
  35. rectMode(CENTER);
  36. rect(150,240,100,30);
  37. line(100,240,200,240);
  38.  
  39. // ONCE YOU HAVE FINISHED PROPERLY USING centerX, centerY, and scale,
  40. // UN-COMMENT THE TWO LINES BELOW TO SEE YOUR SMILEY BOUNCE IN AND OUT
  41. // scale = abs(cos(angle));
  42. // angle += PI/100;
  43. }
  44. </script>
  45. </head>
  46.  
  47. <body>
  48.  
  49. </body>
  50.  
  51. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement