como soluciono estas funciones o como independizar
Publicado por Daniel (1 intervención) el 28/07/2019 09:12:16
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<!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>
Valora esta pregunta


0