Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width,initial-scale=1.0">
- <title>10_print</title>
- <style id="jsbin-css">
- body{
- margin:0;
- padding:0;
- }
- </style>
- </head>
- <body>
- <script id="jsbin-javascript">
- var can=document.createElement("canvas");
- document.body.appendChild(can);
- var ctx=can.getContext("2d");
- with(can){
- width=window.innerWidth;
- height=window.innerHeight;
- }
- function s(a,b,c,d) {
- with(ctx){
- beginPath();
- moveTo(a,b);
- lineTo(c,d);
- lineWidth=3;
- lineCap="round";
- strokeStyle=`rgb(${Math.floor(Math.random()*255)},${Math.floor(Math.random()*255)},${Math.floor(Math.random()*255)})`;
- stroke();
- }
- }
- var x=0;
- var y=0;
- var sp=0.5;
- function draw() {
- if(Math.random()>0.5){
- s(x,y,x+sp,y+sp);
- } else{
- s(x,y+sp,x+sp,y);
- }
- x+=sp;
- if(x>can.width){
- x=0;
- y+=sp;
- }
- requestAnimationFrame(draw);
- }
- requestAnimationFrame(draw);
- </script>
- <script id="jsbin-source-css" type="text/css">body{
- margin:0;
- padding:0;
- }</script>
- <script id="jsbin-source-javascript" type="text/javascript">var can=document.createElement("canvas");
- document.body.appendChild(can);
- var ctx=can.getContext("2d");
- with(can){
- width=window.innerWidth;
- height=window.innerHeight;
- }
- function s(a,b,c,d) {
- with(ctx){
- beginPath();
- moveTo(a,b);
- lineTo(c,d);
- lineWidth=3;
- lineCap="round";
- strokeStyle=`rgb(${Math.floor(Math.random()*255)},${Math.floor(Math.random()*255)},${Math.floor(Math.random()*255)})`;
- stroke();
- }
- }
- var x=0;
- var y=0;
- var sp=0.5;
- function draw() {
- if(Math.random()>0.5){
- s(x,y,x+sp,y+sp);
- } else{
- s(x,y+sp,x+sp,y);
- }
- x+=sp;
- if(x>can.width){
- x=0;
- y+=sp;
- }
- requestAnimationFrame(draw);
- }
- requestAnimationFrame(draw);
- </script></body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement