BrU32

JS Canvas Graph Plot Demo SRC V2

Aug 29th, 2016
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. <html>
  2. <body onload="draw();">
  3. <canvas id="canvas" width="2000" height="2000" style="1px background:black"></canvas>
  4. </body>
  5. </html>
  6. <script>
  7. function draw() {
  8. var
  9. ctx=document.getElementById('canvas').getContext('2d');
  10. var img = new Image();
  11. img.onload = function(){
  12. ctx.scale(2,2);
  13. ctx.drawImage(img,0,0);
  14. ctx.beginPath();
  15. ctx.strokeStyle='darkred';
  16. ctx.moveTo(30,115);
  17. ctx.lineTo(60,15);
  18. ctx.lineTo(60,95);
  19. ctx.lineTo(90,15);
  20. ctx.lineTo(150,95);
  21. ctx.stroke();
  22. };
  23. img.src='https://mdn.mozillademos.org/files/5395/backdrop.png';
  24. }
  25. </script>
Advertisement
Add Comment
Please, Sign In to add comment