-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path43-farenin-konumu.htm
130 lines (82 loc) · 3.43 KB
/
43-farenin-konumu.htm
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<!DOCTYPE html>
<html>
<head>
<title>Farenin Konumu</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- LIBRARY FILES -->
<link rel="stylesheet" type="text/css" href="basic/basic.min.css">
<script src="basic/basic.min.js" type="text/javascript" charset="utf-8"></script>
<script>
/*
- Farenin konumunu gösteren ve bu konumu kullanarak işlem yapan algoritma.
*/
// DEĞİŞKENLER
var lblMouseInfo
var mouseX, mouseY
// ÖZEL FONKSİYONLAR
// İlk çalışan fonksiyon.
var start = function() {
// LABEL: Farenin koordinat bilgileri.
lblMouseInfo = createLabel(30, 30)
that.text = ""
// LABEL: Ekranın ortasındaki bilgi yazısı.
createLabel(0, 0, 200)
that.text = "Lütfen, ekrana tıklayınız..."
that.fontSize = 14
that.textAlign = "center"
// Ekranın ortasına hizala.
that.center()
// Fare hareket ettiğinde çalıştır.
window.addEventListener('mousemove', mouseMoved);
// Fare basılı iken çalıştır.
window.addEventListener('mousedown', mouseDown);
// Fare basmayı bıraktığında çalıştır.
window.addEventListener('mouseup', mouseUp);
}
// DİĞER FONKSİYONLAR
var mouseMoved = function(event) {
var e = window.event;
var posX = e.clientX;
var posY = e.clientY;
mouseX = withPageZoom(posX)
mouseY = withPageZoom(posY)
// Farenin konumunu global değişkenlere aktar.
//mouseX = event.offsetX;
//mouseY = event.offsetY;
lblMouseInfo.text = mouseX + ", " + mouseY
}
var mouseDown = function(event) {
// Farenin konumu geçici değişkenlere aktar.
// var x = event.offsetX;
// var y = event.offsetY;
// veya global değişkenleri kullan.
createShape(mouseX, mouseY)
}
var mouseUp = function(event) {
}
// Rasgele renk ve boyutta bir daire oluştur.
var createShape = function(x, y) {
var colors = ["red", "green", "blue", "pink", "yellow", "black", "orange"]
// Rasgele boyut belirle.
var width = random(30, 90)
var height = width
// Yarı çap belirle.
var r = num(width / 2, "integer")
// Dairenin, farenin konumunda ortalanmış olarak çıkması için.
x -= r
y -= r
createBox(x, y, width, height)
that.round = r
that.border = 0
// 0.3 ile 1 arasında bir şeffaflık belirle.
that.opacity = num(random(30, 100) / 100)
// dizideki renklerden birini seç.
that.color = colors[random(0, colors.length - 1)]
}
</script>
</head>
<body>
<!-- HTML content -->
</body>
</html>