-
Notifications
You must be signed in to change notification settings - Fork 21
/
index.html
450 lines (339 loc) · 9.89 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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
<!DOCTYPE html>
<html>
<head>
<title></title>
<style>
canvas {
border: 1px solid;
}
</style>
</head>
<body>
<canvas width="600" height="600"></canvas>
<script>
const canvas = document.querySelector('canvas')
const ctx = canvas.getContext('2d')
const size = 113
const x = 0 * size
const y = 0 * size
// draw a square
ctx.beginPath()
ctx.rect(x, y, size, size)
ctx.fillStyle = 'tomato'
ctx.fill()
// draw a circle
ctx.beginPath()
// draw a complete circle
ctx.arc(x + size / 2, y + size / 2, 40, 0, Math.PI * 2)
ctx.fillStyle = '#333'
ctx.fill()
// Stroke a path
ctx.beginPath()
// draw half a circle
ctx.arc(x + size / 2, y + size / 2, 30, 0, Math.PI)
ctx.lineWidth = 3
ctx.strokeStyle = '#ffeeee'
ctx.stroke()
// Draw some text
ctx.beginPath()
ctx.font = '18px Helvetica'
ctx.fillStyle = '#fff'
ctx.fillText('Hello', x + 8, y + 20)
// Use the docs to figure out how to draw other things
// https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D
// 0, 0 Ernest
// 1, 0 Jonathan
//my position
const jwx = 1 * size
const jwy = 0 * size
// background square
drawRect(jwx, jwy, size, size, "#222222")
// stem
drawRect(jwx + (113 / 2) - 5, jwy + 15, 10, 25, "#FFFDD0")
// pumpkin
drawEllipse(jwx + (113 / 2), jwy + (113 / 2) + 10, 50, 40, "#FF7518")
// eyes black
drawCircle(jwx + (113 / 2) - 25, jwy + (113 / 2) - 5, 10, "#000000")
drawCircle(jwx + (113 / 2) + 15, jwy + (113 / 2) - 5, 10, "#000000")
// eyes white
drawCircle(jwx + (113 / 2) - 25, jwy + (113 / 2) - 5, 5, "#ffffff")
drawCircle(jwx + (113 / 2) + 15, jwy + (113 / 2) - 5, 5, "#ffffff")
// mouth
drawRect(jwx + (113 / 2) - 10, jwy + (113 / 2) + 15, 20, 10, "#000000")
drawRect(jwx + (113 / 2) - 5, jwy + (113 / 2) + 15, 10, 5, "#ffffff")
//signature
drawText(jwx, jwy, 30, "#fff")
// draw a rectangle
function drawRect(x, y, width, height, color) {
ctx.beginPath()
ctx.rect(x, y, width, height)
ctx.fillStyle = color
ctx.fill()
}
// draw a circle
function drawCircle(x, y, size, color) {
ctx.beginPath()
ctx.arc(x + size / 2, y + size / 2, size, 0, Math.PI * 2)
ctx.fillStyle = color
ctx.fill()
}
function drawText(x, y, size, color) {
ctx.beginPath()
ctx.font = '7px Helvetica'
ctx.fillStyle = color
ctx.fillText('Jonathan W.', x + 70, y + 10)
}
// draw an ellipse
// taken from:
//https://stackoverflow.com/questions/2172798/how-to-draw-an-oval-in-html5-canvas
function drawEllipse(cx, cy, rx, ry, color) {
ctx.save(); // save state
ctx.beginPath();
ctx.translate(cx - rx, cy - ry);
ctx.scale(rx, ry);
ctx.arc(1, 1, 1, 0, 2 * Math.PI, false);
ctx.restore(); // restore to original state
ctx.fillStyle = color
ctx.fill();
}
// 2, 0 Matthew
// 3, 0 Yin
// 4, 0 Ali
// 0, 1 Megan
const megx = 0
const megy = 1 * size
// draw a square
ctx.beginPath()
ctx.rect(megx, megy, size, size)
ctx.fillStyle = 'cyan'
ctx.fill()
// draw bread
ctx.beginPath()
ctx.rect(megx + 18, megy + 33, size - 36, size - 40)
ctx.fillStyle = '#8B4513'
ctx.fill()
ctx.strokeStyle = '#000'
ctx.stroke()
// draw bread
ctx.beginPath()
ctx.arc(megx + size / 2, megy + 48, size / 2 - 15, Math.PI-0.4, Math.PI * 2+0.4)
ctx.fillStyle = '#8B4513'
ctx.fill()
ctx.strokeStyle = '#000'
ctx.stroke()
// draw egg white
ctx.beginPath()
ctx.arc(megx + size / 2, megy + size / 2+3, 30, 0, Math.PI * 2)
ctx.fillStyle = '#fff'
ctx.fill()
// draw egg yolk
ctx.beginPath()
ctx.arc(megx + size / 2, megy + size / 2+3, 10, 0, Math.PI * 2)
ctx.fillStyle = '#DAA520'
ctx.fill()
// draw egg shiny
ctx.beginPath()
ctx.arc(megx + size / 2 - 3, megy + size / 2, 4, Math.PI / 2, -Math.PI / 2)
ctx.fillStyle = '#fff'
ctx.fill()
// Draw some text
ctx.beginPath()
ctx.font = '24px Helvetica'
ctx.fillStyle = 'blue'
ctx.fillText('Nice to', megx + 20, megy + 30)
// Draw some text
ctx.beginPath()
ctx.font = '24px Helvetica'
ctx.fillStyle = 'blue'
ctx.fillText('eat you', megx + 20, size + megy - 5)
// 1, 1 Philippos
// 1, 2 Cao
// 1, 3 Kash
// 1, 4 Zach
// 2, 0 Dino
const dino_x = 2 * size;
const dino_y = 0 * size;
// draw my canvas square
ctx.beginPath();
ctx.rect(dino_x,dino_y,size,size);
ctx.fillStyle = '#ffbad2';
ctx.fill();
// draw a little guy's head inside the square
ctx.beginPath();
ctx.arc(dino_x + size / 2, dino_y + 30, 25, 0, Math.PI * 2);
ctx.fillStyle = '#664455';
ctx.fill();
// draw his shoulders
ctx.beginPath();
ctx.arc(dino_x + size / 2, dino_y + 85, 30, Math.PI, 0);
ctx.fill();
ctx.beginPath();
ctx.rect(dino_x + size / 2 - 30,dino_y + 85, 60, 28);
ctx.fill();
ctx.beginPath()
ctx.font = '24px Helvetica';
ctx.fillStyle = '#eef';
ctx.fillText('Name', dino_x + size / 2 - 33, dino_y + size - 10);
// 2, 1 Jarquevious
// 2, 2 Joanelly
ctx.beginPath()
ctx.arc(2 * size, 2 * size, 50, 0, 2 * Math.PI);
ctx.fillStyle = '#92D3CA'
ctx.fill()
ctx.arc(2 * size, 2 * size, 65, 10, 0, Math.PI);
ctx.fillStyle = '#DCDCDC';
ctx.fill()
ctx.stroke()
ctx.font = '17px Helvetica'
ctx.fillStyle = '#fff'
ctx.fillText('help', 2 * size, 2 * size )
// 2, 3 Alex
// 2, 4 Ryan
// 3, 0 Starlight
star_x = x * 3
star_y = y
ctx.beginPath()
ctx.rect(star_x, star_y, size, size)
ctx.fillStyle = 'rgb(44, 171, 42)'
ctx.fill()
ctx.beginPath()
ctx.arc(star_x + size / 2, star_y + size / 2, 40, 0, Math.PI * 2)
ctx.fillStyle = 'rgb(42, 148, 81)'
ctx.fill()
ctx.beginPath()
ctx.moveTo(star_x, star_y)
ctx.lineTo(star_x + 25, star_y + 75)
ctx.lineTo(star_x + 25, star_y + 25)
ctx.fillStyle = 'rgb(166, 230, 190)'
ctx.fill()
ctx.beginPath()
ctx.moveTo(star_x + size, star_y + size)
ctx.lineTo(star_x + size - 30, star_y + size - 60)
ctx.lineTo(star_x + size - 30, star_y + size - 10)
ctx.fillStyle = 'rgb(166, 230, 190)'
ctx.fill()
ctx.beginPath()
ctx.font = '24px Helvetica'
ctx.fillStyle = '#fff'
ctx.fillText('65', star_x + size/2, star_y + size/2)
ctx.beginPath()
ctx.font = '18px Helvetica'
ctx.fillStyle = '#fff'
ctx.fillText('BM', star_x + 2, star_y + size - 2)
ctx.beginPath()
ctx.font = '30px Helvetica'
ctx.fillStyle = '#fff'
ctx.fillText('$$$', star_x + size/6, star_y + 30)
// 3, 1 Chris
const size = 113
const x = 3 * size
const y = 1 * size
// draw a square
ctx.beginPath()
ctx.rect(x, y, size, size)
ctx.fillStyle = 'black'
ctx.fill()
// draw a circle
ctx.beginPath()
// draw a complete circle
ctx.arc(x + size / 2, y + size / 2, 50, 0, Math.PI * 2)
ctx.fillStyle = '#aaaaaa'
ctx.fill()
// draw a circle
ctx.beginPath()
// draw a complete circle
ctx.arc(x + size / 2, y + size / 2, 40, 0, Math.PI * 2)
ctx.fillStyle = '#bbbbbb'
ctx.fill()
// draw a circle
ctx.beginPath()
// draw a complete circle
ctx.arc(x + size / 2, y + size / 2, 30, 0, Math.PI * 2)
ctx.fillStyle = '#cccccc'
ctx.fill()
// draw a circle
ctx.beginPath()
// draw a complete circle
ctx.arc(x + size / 2, y + size / 2, 20, 0, Math.PI * 2)
ctx.fillStyle = '#dddddd'
ctx.fill()
// draw a circle
ctx.beginPath()
// draw a complete circle
ctx.arc(x + size / 2, y + size / 2, 10, 0, Math.PI * 2)
ctx.fillStyle = '#eeeeee'
ctx.fill()
// draw a circle
ctx.beginPath()
// draw a complete circle
ctx.arc(x + size / 2, y + size / 2, 5, 0, Math.PI * 2)
ctx.fillStyle = '#ffffff'
ctx.fill()
// Draw some text
ctx.beginPath()
ctx.font = '18px Helvetica'
ctx.fillStyle = 'white'
ctx.fillText('chris says hi', x + 8, y + 55)
// 3, 2 Danika
// 3, 3 Luis
// 3, 4 Chao
// 4, 0 Jay
// 4, 1 Mario
// 4, 2 Anneka
const canvas = document.querySelector('canvas')
const ctx = canvas.getContext('2d')
const size = 113
let x = 4 * size
let y = 2 * size
// draw a square
ctx.beginPath()
ctx.rect(x, y, size, size)
ctx.fillStyle = 'mistyrose'
ctx.fill()
// draw a circle
ctx.beginPath()
// draw a complete circle
ctx.arc(x + size / 2, y + size / 1.6, 40, 0, Math.PI * 2)
ctx.fillStyle = 'tomato'
ctx.fill()
// Stroke a path
ctx.beginPath()
// draw half a circle
ctx.arc(x + size / 2.5, y + size / 1.4, 10, 0, Math.PI)
ctx.lineWidth = 3
ctx.strokeStyle = '#ffeeee'
ctx.stroke()
ctx.beginPath()
// draw half a circle
ctx.arc(x + size / 1.7, y + size / 1.4, 10, 0, Math.PI)
ctx.lineWidth = 3
ctx.strokeStyle = '#ffeeee'
ctx.stroke()
ctx.beginPath();
ctx.rect(470,228,30,60)
ctx.fillStyle = "tomato"
ctx.fill();
ctx.beginPath();
ctx.rect(515,228,30,60)
ctx.fillStyle = "tomato"
ctx.fill();
ctx.beginPath()
// draw a complete circle
ctx.arc(x + size / 1.6, y + size / 1.8, 7, 0, Math.PI * 2)
ctx.fillStyle = '#ffeeee'
ctx.fill()
ctx.beginPath()
// draw a complete circle
ctx.arc(x + size / 2.6, y + size / 1.8, 7, 0, Math.PI * 2)
ctx.fillStyle = '#ffeeee'
ctx.fill()
// Draw some text
ctx.beginPath()
ctx.font = '18px Helvetica'
ctx.fillStyle = 'purple'
ctx.fillText('Pyon!', x + 8, y + 20)
// 4, 3 Gobind
// 4, 4 Tian
</script>
</body>
</html>