-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprograma4.3.html
45 lines (29 loc) · 862 Bytes
/
programa4.3.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
<canvas width="600" height="400"></canvas>
<script>
var tela = document.querySelector('canvas');
var pincel = tela.getContext('2d');
pincel.fillStyle = 'lightgray';
pincel.fillRect(0, 0, 600, 400);
function desenhaCirculo(x, y, raio, cor) {
pincel.fillStyle = cor;
pincel.beginPath();
pincel.arc(x, y, raio, 0, 2 * Math.PI);
pincel.fill();
}
function limpaTela() {
pincel.clearRect(0, 0, 600, 400);
}
var raio = 19;
var fatorCrescimento = 0;
function atualizaTela() {
limpaTela();
if(raio > 30) {
fatorCrescimento = -1;
} else if (raio < 20) {
fatorCrescimento = 1;
}
raio = raio + fatorCrescimento;
desenhaCirculo(300, 200, raio, 'blue');
}
setInterval(atualizaTela, 20);
</script>