-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathall.html
158 lines (152 loc) · 4.23 KB
/
all.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
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8" />
<style>
body {
margin: 0px;
padding: 0px;
}
</style>
</head>
<body>
<p>C:<canvas id="myCanvasC" width="600" height="150"></canvas>
Db:<canvas id="myCanvasDb" width="600" height="150"></canvas>
D:<canvas id="myCanvasD" width="600" height="150"></canvas></p>
<p>Eb:<canvas id="myCanvasEb" width="600" height="150"></canvas>
E:<canvas id="myCanvasE" width="600" height="150"></canvas>
F:<canvas id="myCanvasF" width="600" height="150"></canvas></p>
<p>Gb:<canvas id="myCanvasGb" width="600" height="150"></canvas>
G:<canvas id="myCanvasG" width="600" height="150"></canvas>
Ab:<canvas id="myCanvasAb" width="600" height="150"></canvas></p>
<p>A:<canvas id="myCanvasA" width="600" height="150"></canvas>
Bb:<canvas id="myCanvasBb" width="600" height="150"></canvas>
B:<canvas id="myCanvasB" width="600" height="150"></canvas></p>
<script>
var keys = {
'C': [
[2, 4, 'green'],
[2, 6, 'red'],
[1, 7, 'red'],
[2, 12, 'orange'],
[1, 13, 'red'],
[1, 23, 'green'],
[2, 18, 'red'],
[1, 19, 'red']
],
'Db': [
[3, 7, 'green'],
[3, 13, 'green'],
[3, 19, 'green']
],
'D': [
[1, 7, 'green'],
[1, 15, 'green'],
[3, 15, 'red'],
[2, 20, 'green']
],
'Eb': [
[3, 7, 'red'],
[3, 13, 'red'],
[3, 15, 'green'],
[3, 19, 'red']
],
'E': [
[1, 3, 'red'],
[1, 9, 'red'],
[2, 6, 'green'],
[1, 15, 'red'],
[2, 14, 'green'],
[1, 21, 'red'],
[2, 22, 'green']
],
'F': [
[2, 2, 'red'],
[1, 9, 'green'],
[2, 8, 'red'],
[1, 17, 'green'],
[2, 14, 'red'],
[2, 20, 'red']
],
'Gb': [
[1, 1, 'red'],
[3, 11, 'red'],
[3, 9, 'green'],
[3, 17, 'red']
],
'G': [
[1, 3, 'green'],
[1, 5, 'red'],
[1, 11, 'red'],
[2, 8, 'green'],
[1, 17, 'red'],
[2, 16, 'green'],
[1, 23, 'red']
],
'Ab': [
[1, 1, 'green'],
[3, 11, 'green'],
[3, 17, 'green']
],
'A': [
[2, 4, 'red'],
[1, 11, 'green'],
[2, 10, 'red'],
[1, 19, 'green'],
[2, 16, 'red'],
[2, 22, 'red']
],
'Bb': [
[2, 2, 'green'],
[2, 10, 'green']
],
'B': [
[1, 5, 'green'],
[1, 13, 'green'],
[1, 21, 'green']
]
};
var context = {};
for (var key in keys) {
var canvas = document.getElementById('myCanvas'+key);
context[key] = canvas.getContext('2d');
context[key].beginPath();
context[key].lineTo(canvas.width, 0);
context[key].lineTo(canvas.width, canvas.height);
context[key].lineTo(0, canvas.height);
context[key].lineTo(0, 0);
context[key].stroke();
}
function drawKey(diagram, coords) {
if (!coords) {
console.log('WARNING: key ' + key + ' does not exist');
}
var centerY = (4 - coords[0]) * (canvas.height / 5);
var centerX = (coords[1] + 1) * (canvas.width / 25);
var radius = 10;
context[diagram].beginPath();
context[diagram].arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
context[diagram].fillStyle = coords[2];
context[diagram].fill();
context[diagram].lineWidth = 5;
context[diagram].strokeStyle = '#003300';
context[diagram].stroke();
}
var j;
for (var i in keys) {
for (j=1; j<=23; j+=2) {
drawKey(i, [1, j, 'white']);
}
for (j=2; j<=22; j+=2) {
drawKey(i, [2, j, 'white']);
}
for (j=7; j<=19; j+=2) {
drawKey(i, [3, j, 'white']);
}
for (j=0; j< keys[i].length; j++) {
drawKey(i, keys[i][j]);
}
}
</script>
</body>
</html>