Advertisement
Guest User

Untitled

a guest
Oct 14th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width,initial-scale=1.0">
  6. <title>10_print</title>
  7. <style id="jsbin-css">
  8. body{
  9. margin:0;
  10. padding:0;
  11. }
  12. </style>
  13. </head>
  14. <body>
  15.  
  16. <script id="jsbin-javascript">
  17. var can=document.createElement("canvas");
  18. document.body.appendChild(can);
  19. var ctx=can.getContext("2d");
  20. with(can){
  21. width=window.innerWidth;
  22. height=window.innerHeight;
  23. }
  24.  
  25. function s(a,b,c,d) {
  26. with(ctx){
  27. beginPath();
  28. moveTo(a,b);
  29. lineTo(c,d);
  30. lineWidth=3;
  31. lineCap="round";
  32. strokeStyle=`rgb(${Math.floor(Math.random()*255)},${Math.floor(Math.random()*255)},${Math.floor(Math.random()*255)})`;
  33. stroke();
  34. }
  35. }
  36. var x=0;
  37. var y=0;
  38. var sp=0.5;
  39. function draw() {
  40. if(Math.random()>0.5){
  41. s(x,y,x+sp,y+sp);
  42. } else{
  43. s(x,y+sp,x+sp,y);
  44. }
  45. x+=sp;
  46. if(x>can.width){
  47. x=0;
  48. y+=sp;
  49. }
  50. requestAnimationFrame(draw);
  51. }
  52.  
  53.  
  54. requestAnimationFrame(draw);
  55. </script>
  56.  
  57.  
  58. <script id="jsbin-source-css" type="text/css">body{
  59. margin:0;
  60. padding:0;
  61. }</script>
  62.  
  63. <script id="jsbin-source-javascript" type="text/javascript">var can=document.createElement("canvas");
  64. document.body.appendChild(can);
  65. var ctx=can.getContext("2d");
  66. with(can){
  67. width=window.innerWidth;
  68. height=window.innerHeight;
  69. }
  70.  
  71. function s(a,b,c,d) {
  72. with(ctx){
  73. beginPath();
  74. moveTo(a,b);
  75. lineTo(c,d);
  76. lineWidth=3;
  77. lineCap="round";
  78. strokeStyle=`rgb(${Math.floor(Math.random()*255)},${Math.floor(Math.random()*255)},${Math.floor(Math.random()*255)})`;
  79. stroke();
  80. }
  81. }
  82. var x=0;
  83. var y=0;
  84. var sp=0.5;
  85. function draw() {
  86. if(Math.random()>0.5){
  87. s(x,y,x+sp,y+sp);
  88. } else{
  89. s(x,y+sp,x+sp,y);
  90. }
  91. x+=sp;
  92. if(x>can.width){
  93. x=0;
  94. y+=sp;
  95. }
  96. requestAnimationFrame(draw);
  97. }
  98.  
  99.  
  100. requestAnimationFrame(draw);
  101. </script></body>
  102. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement