-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathmegan.js
61 lines (50 loc) · 1.28 KB
/
megan.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import ctx, { size } from './main.js'
ctx.restore()
const x = 0 * size
const y = 1 * size
// draw a square
ctx.beginPath()
ctx.rect(x, y, size, size)
ctx.fillStyle = 'cyan'
ctx.fill()
// draw bread
ctx.beginPath()
ctx.rect(x + 18, y + 33, size - 36, size - 40)
ctx.fillStyle = '#8B4513'
ctx.fill()
ctx.strokeStyle = '#000'
ctx.stroke()
// draw bread
ctx.beginPath()
ctx.arc(x + size / 2, y + 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(x + size / 2, y + size / 2+3, 30, 0, Math.PI * 2)
ctx.fillStyle = '#fff'
ctx.fill()
// draw egg yolk
ctx.beginPath()
ctx.arc(x + size / 2, y + size / 2+3, 10, 0, Math.PI * 2)
ctx.fillStyle = '#DAA520'
ctx.fill()
// draw egg shiny
ctx.beginPath()
ctx.arc(x + size / 2 - 3, y + 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', x + 20, y + 30)
// Draw some text
ctx.beginPath()
ctx.font = '24px Helvetica'
ctx.fillStyle = 'blue'
ctx.fillText('eat you', x + 20, size + y - 5)
// Use the docs to figure out how to draw other things
// https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D