Commit ca44984b authored by ferhat tamer's avatar ferhat tamer 💬
Browse files

Initial commit

parents
*{
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: sans-serif;
}
body{
height: auto;
width: auto;
background:black;
}
canvas{
width: 100%;
height: 100%;
}
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Tanecik</title>
<link rel="stylesheet" href="tanecik.css">
</head>
<body>
<canvas id="canvas"></canvas>
<script src="tanecik.js"></script>
</body>
</html>
\ No newline at end of file
const c = document.getElementById("canvas");
const ctx = c.getContext("2d");
c.width=window.innerWidth;
c.height=window.innerHeight;
const width =c.width;
const height=c.height;
class Partikul{
constructor(x,y,r){
this.x=x;
this.y=y;
this.r=r;
}
ciz() {
ctx.fillStyle="white";
ctx.beginPath();
ctx.arc(this.x, this.y,this.r,0,Math.PI * 2);
ctx.closePath();
ctx.fill();
}
guncelle() {
this.x += Math.random() * 2 + 1 ;
this.y += Math.random() * 2 + 1 ;
}
}
function animasyon() {
ctx.clearRect(0,0,width,height);
tanecikler.forEach(p=>{
p.guncelle();
p.ciz();
})
requestAnimationFrame(animasyon);
}
function init() {
for(var y=100;y<900;y+=50){//900
for(var x=100;x<1600;x+=50){//1600
tanecikler.push(new Partikul(x,y,2));
}
}
animasyon();
}
var tanecikler=[];
init();
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment