Advertisement
franklinglzhou

processing usage

May 9th, 2023
16
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Processing.JS inside Webpages: Template</title>
  5. </head>
  6. <body>
  7. <!--This draws the canvas on the webpage -->
  8. <canvas id="mycanvas"></canvas>
  9. </body>
  10.  
  11. <!-- Include the processing.js library -->
  12. <!-- See https://khanacademy.zendesk.com/hc/en-us/articles/202260404-What-parts-of-ProcessingJS-does-Khan-Academy-support- for differences -->
  13. <script src="https://cdn.jsdelivr.net/processing.js/1.4.8/processing.min.js"></script>
  14. <script>
  15. var programCode = function(processingInstance) {
  16. with (processingInstance) {
  17. size(400, 400);
  18. frameRate(30);
  19.  
  20. // Paste code from Khan Academy here:
  21. fill(255, 255, 0);
  22. ellipse(200, 200, 200, 200);
  23. noFill();
  24. stroke(0, 0, 0);
  25. strokeWeight(2);
  26. arc(200, 200, 150, 100, 0, PI);
  27. fill(0, 0, 0);
  28. ellipse(250, 200, 10, 10);
  29. ellipse(153, 200, 10, 10);
  30. }};
  31.  
  32. // Get the canvas that ProcessingJS will use
  33. var canvas = document.getElementById("mycanvas");
  34. // Pass the function to ProcessingJS constructor
  35. var processingInstance = new Processing(canvas, programCode);
  36. </script>
  37. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement