-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path4.02 - Pulsação.html
56 lines (44 loc) · 1.61 KB
/
4.02 - Pulsação.html
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
<h1>Pulsação</h1>
<canvas width="600" height="400"></canvas>
<body>
<script src="Ferramentas de desenho.js"></script>
<script>
// Seletor de tela
var tela = document.querySelector('canvas');
var desenho = tela.getContext('2d');
var W = tela.width, H = tela.height;
corLinha('black'); contornoRet(0, 0, W, H); // Tela de pintura
function Circulo(xc,yc,r,fundo,textoF,linha,textoL) {
var tela = document.querySelector('canvas');
var desenho = tela.getContext('2d');
inicio();
arco(xc,yc,r, 0, 2*3.14);
if (textoF == true && textoL == false) {
cor(fundo);
pintar();
}
if (textoF == false && textoL == true) {
corLinha(linha);
contorno();
}
if (textoF == true && textoL == true) {
cor(fundo);
pintar();
corLinha(linha);
contorno();
}
}
var r = 20, rmin = 20, rmax = 40; // raios do círculo
var pr = 2; // passo em r
var t = 20; // intervalo de tempo em [ms]
function pulsar() {
limparRet(0, 0, W, H); contornoRet(0, 0, W, H);
if(r >= rmax) { r = rmax; pr = -pr }
else
{ if(r<=rmin) { r=rmin; pr=-pr } }
Circulo(W/2, H/2, r, 'black', true, 'black', false);
r = r+pr;
}
setInterval(pulsar, t)
</script>
</body>