-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathNoteMath.html
More file actions
178 lines (129 loc) · 4.45 KB
/
NoteMath.html
File metadata and controls
178 lines (129 loc) · 4.45 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
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
171
172
173
174
175
176
177
178
<!DOCTYPE html>
<html lang="en-US">
<head>
<title>Sover the Note Math</title>
<meta charset="UTF-8">
<style>
html, body { height: 100%; margin: 0; }
body {
overflow: hidden;
background-color: #222222;
color: white;
zoom: 3;
font-size: 1vw;
}
button {
color: #111111;
background-color: #111111;
width: 1.6vw;
height: 3.2vh;
font-size: 0.5vw;
}
#buttonsDiv:hover button{
color: #FFFFFF;
}
#maxNumberId {
opacity:0;
}
#maxNumberId:hover { /* https://stackoverflow.com/a/19929157/12777947 */
opacity:1;
-webkit-transition: opacity 1s ease-in-out .0s;
transition: opacity 1s ease-in-out .0s;
}
a {
font-size: 2vw;
}
input {
width: 3vw;
height: 2vh;
font-size: 0.4vw;
}
</style>
</head>
<body>
<div style="text-align: center; margin-top: 2vh;"><a class="textId">Note Math</a></div><br>
<div id="maxNumberId">Max Number: <input id="maxNumberInput" type="number" value="20"></input></div>
<div id="equationDiv" align="center" class="textId"></div>
<div id="buttonsDiv" align="center"></div>
<script>
let notes = ["A", "A#", "B", "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#"];
let solution = 0;
let lastNote = 0;
function mod(n, m){
return ((n % m) + m) % m;
}
function setButtons(){
let buttons = "";
for (i in notes){
buttons += "<button onclick='checkSolution(" + i + ")'>" + notes[i] + "</button> ";
}
document.getElementById("buttonsDiv").innerHTML = buttons;
}
setButtons();
function getRandomNums(){
return [Math.floor(Math.random() * notes.length), Math.floor(Math.random() * document.getElementById("maxNumberInput").value) + 1];
}
function generateRandomNums(){
let nums = getRandomNums();
while (nums[0] == lastNote){
nums = getRandomNums();
}
lastNote = nums[0];
return nums;
}
function generateEquation(){
let isNegative = Math.floor(Math.random() * 2);
let operatorText = isNegative ? " - " : " + ";
let nums = generateRandomNums();
solution = mod(nums[0] + nums[1] * (-2 * isNegative + 1), notes.length);
document.getElementById("equationDiv").innerHTML = "<h1>" + (notes[nums[0]] + operatorText + nums[1] + " = ?") + "</h1>";
}
generateEquation();
function checkSolution(num){
if (num == solution){
generateEquation();
changeTextColor();
}
}
function changeTextColor(){
let prideColors = [
["#000000", "#a3a3a3", "#ffffff", "#880088"], //ace
["#ff218c", "#ffd800", "#21b1ff"], //pan
["#3da542", "#a7d379", "#ffffff", "#a9a9a9", "#000000"], //aro
["#e28c00", "#eccd00", "#ffffff", "#62aedc", "#203856"], //aroace
["#d60270", "#9b4f96", "#0038a8"], //bi
["#FFF433", "#FFFFFF", "#9B59D0", "#2D2D2D"], //emby
["#5BCEFA", "#F5A9B8", "#FFFFFF", "#F5A9B8", "#5BCEFA"], //trans
["#f61cb9", "#07d569", "#1c92f6"], //poly
["#000000", "#b9b9b9", "#ffffff", "#b8f483", "#ffffff", "#b9b9b9", "#000000"], //agender
["#7f7f7f", "#c4c4c4", "#9ad9eb", "#ffffff", "#9ad9eb", "#c4c4c4", "#7f7f7f"], //demiboy
["#7f7f7f", "#c4c4c4", "#ffaec9", "#ffffff", "#ffaec9", "#c4c4c4", "#7f7f7f"], //demigirl
["#ff75a2", "#f5f5f5", "#be18d6", "#2c2c2c", "#333ebd"], //genderfluid
["#b57edc", "#ffffff", "#4a8123"], //genderqueer
["#d52d00","#ef7627","#ff9a56","#ffffff","#d162a4","#b55690","#a30262"], //lesbian 7 stripes
["#d52d00","#ff9a56","#ffffff","#d362a4","#a30262"], //lesbian 5 stripes
["#078d70","#26ceaa","#98e8c1","#ffffff","#7bade2","#5049cc","#3d1a78"], //mlm 7 stripes
["#078d70","#98e8c1","#ffffff","#7bade2","#3d1a78"], //mlm 5 stripes
["#e50000", "#ff8b00", "#ffee00", "#028121", "#004cff", "#770088"] //pride rainbow
];
let color = prideColors[Math.floor(Math.random() * prideColors.length)];
//let color = prideColors[13];
let colorCodesText = "";
for (let i in color){
if (i == 0 || i == color.length - 1){
if (i != 0){
colorCodesText += ",";
}
colorCodesText += color[i];
colorCodesText += "," + color[i];
}
colorCodesText += "," + color[i];
}
let gradientText = "background: linear-gradient(" + colorCodesText + ");"
document.getElementsByClassName("textId")[0].style = gradientText + "-webkit-background-clip: text; -webkit-text-fill-color: transparent;";
document.getElementsByClassName("textId")[1].style = gradientText + "-webkit-background-clip: text; -webkit-text-fill-color: transparent; text-shadow: 0px 0px #FFFFFF44;";
}
changeTextColor();
</script>
</body>
</html>