19 lines
563 B
CoffeeScript
19 lines
563 B
CoffeeScript
toxy = (position)->
|
|
x: position%config.map.width
|
|
y: Math.floor(position/config.map.width)
|
|
|
|
# function: rect drawing
|
|
rect = (x, y, w, h, color) ->
|
|
context.fillStyle = color
|
|
context.fillRect x, y, w, h
|
|
|
|
pixel = (position, w, h, color) ->
|
|
x = config.pixelsize*toxy(position).x+config.map.origin.x
|
|
y = config.pixelsize*toxy(position).y+config.map.origin.y
|
|
rect(x, y, w, h, color)
|
|
|
|
write = (x, y, text, size, color) ->
|
|
context.textAlign = 'center';
|
|
context.fillStyle = color
|
|
context.font = 'normal '+size+'pt Verdana'
|
|
context.fillText(text, x, y) |