-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.html
170 lines (121 loc) · 5.52 KB
/
test.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
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
<html>
<head>
<!-- meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" / -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
.vranger {
margin-top: 300;
transform: rotate(270deg);
-moz-transform: rotate(270deg); /*do same for other browsers if required*/
}
body {
background-color: #E6E6FA;
}
</style>
</head>
<body>
<input type="button" value="1600M" style="position: absolute; left: 350px; margin-top: 10px;" onclick="buttonFunction(1600)" />
<input type="button" value="1500M" style="position: absolute; left: 350px; margin-top: 48px;" onclick="buttonFunction(1514)" />
<input type="button" value="1400M" style="position: absolute; left: 350px; margin-top: 86px;" onclick="buttonFunction(1414)" />
<input type="button" value="1300M" style="position: absolute; left: 350px; margin-top: 125px;" onclick="buttonFunction(1314)" />
<input type="button" value="1200M" style="position: absolute; left: 350px; margin-top: 164px;" onclick="buttonFunction(1214)" />
<input type="button" value="1100M" style="position: absolute; left: 350px; margin-top: 203px;" onclick="buttonFunction(1114)" />
<input type="button" value="1000M" style="position: absolute; left: 350px; margin-top: 241px;" onclick="buttonFunction(1014)" />
<input type="button" value="900M" style="position: absolute; left: 350px; margin-top: 280;" onclick="buttonFunction(914)" />
<input type="button" value="800M" style="position: absolute; left: 350px; margin-top: 319;" onclick="buttonFunction(814)" />
<input type="button" value="700M" style="position: absolute; left: 350px; margin-top: 357;" onclick="buttonFunction(714)" />
<input type="button" value="600M" style="position: absolute; left: 350px; margin-top: 396;" onclick="buttonFunction(614)" />
<input type="button" value="500M" style="position: absolute; left: 350px; margin-top: 435;" onclick="buttonFunction(514)" />
<input type="button" value="400M" style="position: absolute; left: 350px; margin-top: 473;" onclick="buttonFunction(414)" />
<input type="button" value="300M" style="position: absolute; left: 350px; margin-top: 512;" onclick="buttonFunction(314)" />
<input type="button" value="200M" style="position: absolute; left: 350px; margin-top: 551;" onclick="buttonFunction(214)" />
<input type="button" value="100M" style="position: absolute; left: 350px; margin-top: 590px;" onclick="buttonFunction(130)" />
<!-- input id="button", type="button" value="asd" onclick="buttonFunction()" / -->
<input id="rangeInput" class="vranger" type="range" step="1" value="1014" min="115" max="1615" oninput="rangeInputFunction()" style="position: absolute;left: 0px; width:600" />
<canvas id="myCanvas" width="250" height="620" style="border:1px solid #000000;position: absolute;" /></canvas>
<script>
window.addEventListener("load", function(){
let m = document.getElementById('rangeInput');
m = parseInt(m.value);
canvasFunction(m);
});
function buttonFunction(m) {
//let myCanvas = document.getElementById('myCanvas');
//myCanvas = myCanvas.getContext('2d');
//myCanvas.clearRect(0, 0, myCanvas.canvas.width, myCanvas.canvas.height);
//console.log(m);
let range = document.getElementById('rangeInput');
range.value = parseInt(m);
rangeInputFunction();
}
function rangeInputFunction() {
let element = document.getElementById("myCanvas");
element.scrollIntoView({behavior: "smooth", block: "center", inline: "nearest"});
let m = document.getElementById('rangeInput');
m.title = "range";
console.log(m);
m = parseInt(m.value);
canvasFunction(m);
}
function canvasFunction(m) {
//let marray = [100,200,300,400,500,600,700,800,900,1000,1100,1200,1300,1400,1500,1600];
let myCanvas = document.getElementById('myCanvas');
myCanvas = myCanvas.getContext('2d');
myCanvas.clearRect(0, 0, myCanvas.canvas.width, myCanvas.canvas.height);
let start_offset = [50,10];
let spacing = 20;
let x = 0, y = 1;
let pos = [start_offset[x],start_offset[y]];
let color = "#FF0000";
let meters = 1600 - 100;
let mils = 622 - 978;
let scale = mils / meters;
let meter = m;
let a = (meter - 100) * scale;
let b = a + 978;
let lines_count = 30;
let IsHundred = new Boolean(false);
let grd = null;
grd = myCanvas.createLinearGradient(0,515,0,610);
grd.addColorStop(1,"green");
grd.addColorStop(0,"#E6E6FA");
// Fill BOTTOM with gradient
myCanvas.fillStyle = grd;
myCanvas.fillRect(0,515,250,105);
grd = myCanvas.createLinearGradient(0,0,0,100);
grd.addColorStop(0,"green");
grd.addColorStop(1,"#E6E6FA");
// Fill TOP with gradient
myCanvas.fillStyle = grd;
myCanvas.fillRect(0,0,250,105);
for(let i = 0; i <= lines_count; i++) {
a = (meter - 100) * scale;
b = a + 978;
IsHundred = Boolean(meter%100 == 0);
myCanvas.beginPath();
if(IsHundred) {
myCanvas.font='20px Courier New Bold';
myCanvas.strokeStyle = "#00FF00";
myCanvas.fillStyle = "#0000FF";
console.log(myCanvas);
}
else {
myCanvas.font='12px Courier New Bold';
myCanvas.strokeStyle = "#000000";
myCanvas.fillStyle = "#000000";
}
pos[y] = i * spacing;
pos[y] = start_offset[y] + pos[y];
myCanvas.moveTo(pos[x]-5,pos[y]);
myCanvas.lineTo(pos[x]+140,pos[y]);
myCanvas.stroke();
myCanvas.textBaseline='middle';
myCanvas.fillText(meter ,pos[x]-50,pos[y]);
myCanvas.fillText(b.toFixed(1) ,pos[x]+150,pos[y]);
myCanvas.closePath();
meter -= 1;
}
}
</script>
</body>
</html>