English, asked by saireenchoudhury1995, 11 months ago

name five things that feel and live? poem kindness of animals​

Answers

Answered by aman7913
1

&lt;!DOCTYPE html&gt;</p><p>&lt;html&gt;</p><p>&lt;head&gt;&lt;title&gt;hearts&lt;/title&gt;&lt;/head&gt;</p><p>&lt;body style="margin:0;"&gt;</p><p>&lt;canvas&gt;&lt;/canvas&gt;</p><p>&lt;script type="text/javascript"&gt;</p><p>var canvas=document.querySelector("canvas");</p><p>var context=canvas.getContext("2d");</p><p>canvas.width=window.innerWidth;</p><p>canvas.height=window.innerHeight;</p><p>var no = prompt("Enter your favourite number","20");</p><p>var hearts=[];</p><p>for(var i=0;i&lt;no;i++){</p><p>var color=360*Math.random();</p><p>var x=Math.floor(canvas.width*Math.random());</p><p>var y=Math.floor(canvas.height*Math.random());</p><p>hearts[i]=new heart(x,y,color);</p><p>}</p><p>function heart(x,y,color){</p><p>this.x=x;</p><p>this.y=y;</p><p>this.color=color;</p><p></p><p>this.fall=function(){</p><p>if(this.x&gt;=innerWidth){</p><p>    this.x-=16;</p><p>}</p><p>if(this.x&lt;=0){</p><p>    this.x+=16;</p><p>}</p><p>var dir=Math.floor(Math.random()*3);</p><p>if(dir==0){</p><p>this.x=this.x;</p><p>}</p><p>if(dir==1){</p><p>this.x=this.x-1;</p><p>}</p><p>if(dir==2){</p><p>this.x=this.x+1;</p><p>}</p><p>this.y=this.y+1;</p><p>if(this.y&gt;canvas.height){</p><p>this.y=-10;</p><p>}</p><p>}</p><p>this.show=function(){</p><p>context.beginPath(); </p><p>context.arc(this.x,this.y,7,0,Math.PI,false);</p><p>context.strokeStyle="hsl("+color+",100%,50%)";</p><p>context.lineWidth=14;</p><p>context.lineCap="round";       </p><p>context.stroke();       </p><p>context.closePath();</p><p>}</p><p>}</p><p>function draw(){</p><p>context.fillStyle="#000";</p><p>context.fillRect(0,0,canvas.width,canvas.height);</p><p>for(var i=0;i&lt;no;i++){</p><p>hearts[i].show();</p><p>hearts[i].fall();</p><p>}</p><p>}</p><p>function update(){</p><p>draw();</p><p>window.requestAnimationFrame(update);</p><p>}</p><p>update();</p><p>&lt;/script&gt;</p><p>&lt;/body&gt;</p><p>&lt;/html&gt;

Similar questions