-
Notifications
You must be signed in to change notification settings - Fork 0
/
63_bolinhaBolaBolao.html
45 lines (33 loc) · 1008 Bytes
/
63_bolinhaBolaBolao.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 = 'rgba(0,0,0,0.03)';
pincel.fillRect(0, 0, 600, 400);
var cores = ['Red','purple','Blue','Lime','yellow'];
var corAtual = 0;
var raio = 10;
function desenhaCirculo(evento) {
var x = evento.pageX - tela.offsetLeft;
var y = evento.pageY - tela.offsetTop;
console.log(x+','+y);
if (evento.shiftKey){
raio = raio + 10;
}
pincel.fillStyle = cores[corAtual];
pincel.beginPath();
pincel.arc(x, y, raio, 0, 2 * 3.14);
pincel.fill();
console.log(x + ',' + y);
}
tela.onclick = desenhaCirculo;
function mudaCor(){
corAtual++;
if(corAtual>= cores.length){
corAtual = 0;
}
alert('Trocou de Cor.');
return false;
}
tela.oncontextmenu = mudaCor;
</script>