-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprograma3.html
More file actions
47 lines (37 loc) · 1.08 KB
/
Copy pathprograma3.html
File metadata and controls
47 lines (37 loc) · 1.08 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<canvas width="600" height="400"></canvas>
<meta charset="UTF-8">
<script>
var pantalla = document.querySelector("canvas");
var pincel = pantalla.getContext("2d");
pincel.fillStyle = "grey"
pincel.fillRect(0,0,600,400);
function exibirAlerta(evento) {
// console.log(evento)
var x = evento.pageX - pantalla.offsetLeft;
var y = evento.pageY - pantalla.offsetTop;
pincel.font="15px Georgia";
pincel.fillStyle="black";
pincel.fillText("x:"+x+" y:"+y, x, y);
alert("Usted hizo click en la posicion x:"+x+" y:"+y);
}
function dibujarCirculo(evento) {
var x = evento.pageX - pantalla.offsetLeft;
var y = evento.pageY - pantalla.offsetTop;
pincel.beginPath();
pincel.fillStyle="green";
pincel.arc(x,y,3,0,2*3.1416);
pincel.fill();
console.log(evento);
}
// pantalla.onclick = exibirAlerta;
pantalla.onclick = dibujarCirculo;
</script>
</body>
</html>