Coffeescript Game Tutorial Add Some Color

색깔 원을 그리는 코드이다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
window.onload = ->
# get a reference to the canvas
canvas = document.getElementById("canvas")
ctx = canvas.getContext("2d")
ctx.fillStyle = "#00A308"
ctx.beginPath()
ctx.arc(220, 220, 50, 0, Math.PI*2, true)
ctx.closePath()
ctx.fill()
ctx.fillStyle = "#FF1C0A"
ctx.beginPath()
ctx.arc(100, 100, 100, 0, Math.PI*2, true)
ctx.closePath()
ctx.fill()
# the rectangle is half transparent
ctx.fillStyle = "rgba(255, 255, 0, 0.5)"
ctx.beginPath()
ctx.rect(15, 150, 120, 120)
ctx.closePath()
ctx.fill()

Reference

Share Comments