<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Animacion</title>
<link rel="stylesheet" href="estilos.css">
</head>
<body>
<canvas id="lienzo" width="1000px" height="600px"></canvas>
<script type="text/javascript">
let canva=document.querySelector('#lienzo');
let ctx=canva.getContext("2d");
let xp1=1;
let yp1=10;
setInterval(function puntos1() {
ctx.beginPath();
ctx.fillStyle="white";
//ctx.fillRect(xp1,yp1,25,25);
ctx.arc(xp1, yp1, 7, 0, 2 * Math.PI);
ctx.arc(xp1, yp1*3, 6, 0, 2 * Math.PI);
ctx.arc(xp1, yp1*5, 5, 0, 2 * Math.PI);
ctx.arc(xp1, yp1*7, 4, 0, 2 * Math.PI);
ctx.arc(xp1, yp1*9, 3, 0, 2 * Math.PI);
ctx.arc(xp1, yp1*11, 2, 0, 2 * Math.PI);
ctx.arc(xp1, yp1*13, 1, 0, 2 * Math.PI);
ctx.fill();
xp1+=30;
yp1+=0;
},100);
let xp2=1000;
let yp2=10;
setInterval(function puntos2() {
ctx.beginPath();
ctx.fillStyle="white";
ctx.arc(xp2, yp2*47, 1, 0, 2 * Math.PI);
ctx.arc(xp2, yp2*49, 2, 0, 2 * Math.PI);
ctx.arc(xp2, yp2*51, 3, 0, 2 * Math.PI);
ctx.arc(xp2, yp2*53, 4, 0, 2 * Math.PI);
ctx.arc(xp2, yp2*55, 5, 0, 2 * Math.PI);
ctx.arc(xp2, yp2*57, 6, 0, 2 * Math.PI);
ctx.arc(xp2, yp2*59, 7, 0, 2 * Math.PI);
ctx.fill();
xp2-=30;
yp2+=0;
},100);
var can = function () {
var canvas;
var context;
return {
draw: function () {
var r = Math.floor(Math.random() * 255) + 70;
var g = Math.floor(Math.random() * 255) + 70;
var b = Math.floor(Math.random() * 255) + 70;
var s = 'rgba(' + r + ',' + g + ',' + b + ', 0.5)';
context.rotate(0.2 * Math.PI);
context.fillStyle = s;
context.fillRect(10, 0, 150, 50);
},
init: function () {
canvas = document.getElementById("lienzo");
context = canvas.getContext("2d");
context.translate(200, 250);
setInterval(can.draw, 250);
}
}
} ();
window.onload = can.init;
</script>
</body>
</html>