Advertisement
BrU32

JS Canvas Draw Text To Random Position V2

May 14th, 2016
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. <html>
  2. <body onload="
  3. Draw();">
  4. <canvas id="myCanvas" width="500" height="500"
  5. style="border:1px solid #d3d3d3;">
  6. Your browser does not support the canvas element.
  7. </canvas>
  8. <script>
  9. function Draw(){
  10. var intt=prompt("Enter #:");
  11. var t=prompt('Enter Text To Display:');
  12. for(var i=0;i<intt;i++){
  13. var canvas = document.getElementById("myCanvas");
  14. var ctx=canvas.getContext("2d");
  15. ctx.font="50px Comic Sans MS";
  16. ctx.fillStyle = "red";
  17. ctx.textAlign = "center";
  18. ctx.fillText(""+t,Math.floor(Math.random()*500),Math.floor(Math.random()*500));
  19. }
  20. }
  21. </script>
  22. </body>
  23. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement