-
Notifications
You must be signed in to change notification settings - Fork 1
/
canvas.js
45 lines (32 loc) · 1.12 KB
/
canvas.js
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
//Rot zu Blau
var temp = document.getElementById("temperaturCanvas");
var tempx = temp.getContext("2d");
var grd = tempx.createLinearGradient(0,0,0,256);
grd.addColorStop(0,"red");
grd.addColorStop(.5,"white");
grd.addColorStop(1, "blue");
tempx.fillStyle = grd;
tempx.fillRect(0,0,100,256);
var slider = document.getElementById("output");
var output = document.getElementById("year");
output.innerHTML = convertYears(slider.value);
// slider.oninput = function(){
// output.innerHTML = convertYears(this.value);
// }
function convertYears(input){
var months = ['Januar', 'Februar', 'März', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember'];
var temp = parseInt(input/12);
var year = temp+1880;
var month = months[input%12];
return month + " " + year;
}
//Schwarz zu Weiß
/*
var temp = document.getElementById("temperaturCanvas");
var tempx = temp.getContext("2d");
var grd = tempx.createLinearGradient(0,0,0,256);
grd.addColorStop(0,"black");
grd.addColorStop(1, "white");
tempx.fillStyle = grd;
tempx.fillRect(0,0,100,256);
*/