mirror of
https://github.com/rastapasta/mapscii.git
synced 2024-11-21 23:53:08 +01:00
😄 adding support for points, using emoji utf8 symbols
This commit is contained in:
parent
29d6a084fb
commit
d3ddc23de4
@ -16,9 +16,30 @@ width = null
|
|||||||
height = null
|
height = null
|
||||||
|
|
||||||
config =
|
config =
|
||||||
drawOrder: ["admin", "water", "landuse", "building", "road"]
|
drawOrder: ["admin", "water", "landuse", "building", "road", "poi_label"]
|
||||||
|
|
||||||
|
icons:
|
||||||
|
car: "🚗"
|
||||||
|
school: "🏫"
|
||||||
|
marker: "⭐"
|
||||||
|
'art-gallery': "🎨"
|
||||||
|
attraction: "❕"
|
||||||
|
stadium: "🏈"
|
||||||
|
toilet: "🚽"
|
||||||
|
cafe: "☕"
|
||||||
|
laundry: "👚"
|
||||||
|
bus: "🚌"
|
||||||
|
restaurant: "🍕"
|
||||||
|
lodging: "🏨"
|
||||||
|
'fire-station': "🚒"
|
||||||
|
shop: "🏬"
|
||||||
|
pharmacy: "💊"
|
||||||
|
beer: "🍺"
|
||||||
|
cinema: "🎦"
|
||||||
|
|
||||||
layers:
|
layers:
|
||||||
|
poi_label:
|
||||||
|
color: "red"
|
||||||
road:
|
road:
|
||||||
color: "white"
|
color: "white"
|
||||||
landuse:
|
landuse:
|
||||||
@ -53,7 +74,7 @@ zlib.gunzip data, (err, buffer) ->
|
|||||||
for i in [0...layer.length]
|
for i in [0...layer.length]
|
||||||
feature = layer.feature i
|
feature = layer.feature i
|
||||||
features[name].push
|
features[name].push
|
||||||
type: feature.type
|
type: [undefined, "point", "line", "polygon"][feature.type]
|
||||||
id: feature.id
|
id: feature.id
|
||||||
properties: feature.properties
|
properties: feature.properties
|
||||||
points: feature.loadGeometry()
|
points: feature.loadGeometry()
|
||||||
@ -80,25 +101,29 @@ draw = ->
|
|||||||
for layer in config.drawOrder
|
for layer in config.drawOrder
|
||||||
continue unless features[layer]
|
continue unless features[layer]
|
||||||
|
|
||||||
canvas.strokeStyle = config.layers[layer].color
|
canvas.strokeStyle = canvas.fillStyle = config.layers[layer].color
|
||||||
|
|
||||||
for feature in features[layer]
|
for feature in features[layer]
|
||||||
for line in feature.points
|
for points in feature.points
|
||||||
found = false
|
|
||||||
points = for point in line
|
visible = false
|
||||||
|
points = for point in points
|
||||||
p = [point.x/scale, point.y/scale]
|
p = [point.x/scale, point.y/scale]
|
||||||
if not found and p[0]+view[0]>=0 and p[0]+view[0]<width and p[1]+view[1]>=0 and p[1]+view[1]<height
|
if not visible and p[0]+view[0]>=4 and p[0]+view[0]<width-4 and p[1]+view[1]>=0 and p[1]+view[1]<height
|
||||||
found = true
|
visible = true
|
||||||
p
|
p
|
||||||
continue unless found
|
continue unless visible
|
||||||
|
|
||||||
canvas.beginPath()
|
switch feature.type
|
||||||
canvas.moveTo points.shift()...
|
when "polygon", "line"
|
||||||
canvas.lineTo point... for point in points
|
canvas.beginPath()
|
||||||
canvas.stroke()
|
canvas.moveTo points.shift()...
|
||||||
|
canvas.lineTo point... for point in points
|
||||||
|
canvas.stroke()
|
||||||
|
|
||||||
|
when "point"
|
||||||
|
canvas.fillText (config.icons[feature.properties.maki] or "X"), point... for point in points
|
||||||
|
|
||||||
canvas.fillStyle = "white"
|
|
||||||
canvas.fillText "test", 0, 0
|
|
||||||
canvas.stroke()
|
|
||||||
canvas.restore()
|
canvas.restore()
|
||||||
|
|
||||||
flush()
|
flush()
|
||||||
|
Loading…
Reference in New Issue
Block a user