-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
210 lines (195 loc) · 11.1 KB
/
index.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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Simple Color Match Game</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<link href="index.css" rel="stylesheet">
<script src="index.js"></script>
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.4.1/dist/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
<script src="package/moment.min.js"></script>
<meta name="theme-color" content="#ffffff">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
</head>
<body>
<div class="container">
<br/>
<h1>Color Match</h1>
<hr/>
<div class="row">
<div class="col-md-6">
<div class="row">
<div class="col-md-12">
<div class="card" id="game">
<div class="card-body">
<!-- mode section -->
<div class="form-check form-switch float-right">
<input class="form-check-input" type="checkbox" role="switch" id="mode">
<label class="form-check-label" for="mode">CMYK</label>
</div>
<!-- canvas that centers horizontally and vertically -->
<canvas id="canvas"
width="400"
height="400"
style="display: block; margin-left: auto; margin-right: auto; margin-bottom: 20px; border-radius: 5px">
</canvas>
<!-- input sections -->
<div id="rgb-mode">
<div class="form-group row">
<label for="red" class="col-sm-2 col-form-label">Red:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="red" max="255" min="0" value="0" pattern="[0-9]{3}" required>
</div>
</div>
<br/>
<div class="form-group row">
<label for="green" class="col-sm-2 col-form-label">Green:</label>
<div class="col-sm-10">
<input type="number" class="form-control" id="green" max="255" min="0" value="0" step="1">
</div>
</div>
<br/>
<div class="form-group row">
<label for="blue" class="col-sm-2 col-form-label">Blue:</label>
<div class="col-sm-10">
<input type="number" class="form-control" id="blue" max="255" min="0" value="0" step="1">
</div>
</div>
</div>
<div id="cmyk-mode" style="display: none">
<div class="input-group">
<label for="cyan" class="col-sm-2 col-form-label">Cyan:</label>
<input type="number" class="form-control" id="cyan" max="100" min="0" value="0" step="1">
<span class="input-group-text">%</span>
</div>
<br/>
<div class="input-group">
<label for="magenta" class="col-sm-2 col-form-label">Magenta:</label>
<input type="number" class="form-control" id="magenta" max="100" min="0" value="0" step="1">
<span class="input-group-text">%</span>
</div>
<br/>
<div class="input-group">
<label for="yellow" class="col-sm-2 col-form-label">Yellow:</label>
<input type="number" class="form-control" id="yellow" max="100" min="0" value="0" step="1">
<span class="input-group-text">%</span>
</div>
<br/>
<div class="input-group">
<label for="key" class="col-sm-2 col-form-label">Black Key:</label>
<input type="number" class="form-control" id="key" max="100" min="0" value="0" step="1">
<span class="input-group-text">%</span>
</div>
</div>
<br/>
<div class="form-group row">
<div class="d-grid gap-2">
<button type="button" class="btn btn-primary" id="submit" data-bs-toggle="modal" data-bs-target="#score-modal">Submit</button>
</div>
</div>
</div>
</div>
<br/>
</div>
</div>
</div>
<div class="col-md-6">
<!-- score history section -->
<div class="card">
<div class="card-body">
<h5 class="card-title d-flex justify-content-between align-items-center">
<span>Score History (Best: <span id="high-score"></span>)</span>
<button id="score-history-clear" type="button" class="btn btn-danger btn-sm float-right">Clear</button>
</h5>
<hr/>
<ul class="list-group-flush" id="score-history" style="max-height: 400px; overflow-y: auto;"></ul>
</div>
</div>
<br/>
<div class="card">
<div class="card-body">
<h5 class="card-title">About</h5>
<hr/>
<div class="card-text">
<div class="accordion">
<div class="accordion-item">
<h2 class="accordion-header">
<button class="accordion-button" type="button" aria-expanded="true">
How to play?
</button>
</h2>
<div class="accordion-collapse">
<div class="accordion-body">
This is a simple color matching game.
<br/><br/>
You will be shown a color on screen, and you have to input the correct RGB/CMYK value.
<br/><br/>
A score will be given after each round ranging from 0 to 100 percent.
</div>
</div>
</div>
<div class="accordion-item">
<h2 class="accordion-header">
<button class="accordion-button" type="button" aria-expanded="true">
How are you scored?
</button>
</h2>
<div class="accordion-collapse">
<div class="accordion-body">
I thought this would be a quick 2-hour project, but I ended up spending hours researching
color space. After trying out different scoring systems, I decided to use the established CIE94 formula.
<br/><br/>
CIE94 was chosen for this game because it takes into account the human perception of color,
which is non-uniform across the light spectrum. The formula is also not as complex as
CIEDE2000, making it easier to implement. If you want to learn more about it, you can find
more info <a href="https://en.wikipedia.org/wiki/Color_difference#CIE94">here</a>.
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<br/>
<br/>
<br/>
</div>
<!-- modal to display result -->
<div class="modal model-lg fade" id="score-modal" tabindex="-1" aria-labelledby="scoreModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Result</h5>
</div>
<div class="modal-body">
<b><span id="score"></span>% MATCH</b>
<div id="message">
</div>
<div class="row">
<div class="col-sm-6">
The color you created:
<canvas id="input-canvas" width="90" height="30" style="vertical-align: middle;"></canvas>
</div>
<div class="col-sm-6">
The color given:
<canvas id="target-canvas" width="90" height="30" style="vertical-align: middle;"></canvas>
</div>
</div>
</div>
<div class="modal-footer">
<button id="new-game-button" type="button" class="btn btn-primary" data-bs-dismiss="modal">Another One</button>
</div>
</div>
</div>
</div>
</div>
</div>
<nav class="navbar fixed-bottom bg-dark">
<div class="container-fluid text-center text-white">
<small id="cp-notice" style="width: 100%;"></small>
</div>
</nav>
</body>
</html>