🎨 working on background color based polygon filling

pull/7/head
Michael Straßburger 2016-09-28 14:11:05 +02:00
rodzic 22907f4168
commit f5fdd8dea5
4 zmienionych plików z 18 dodań i 4 usunięć

Wyświetl plik

@ -34,7 +34,9 @@ module.exports = class BrailleBuffer
@foregroundBuffer = []
@backgroundBuffer = []
setBackground: (idx, color) ->
setBackground: (x, y, color) ->
return unless 0 <= x < @width and 0 <= y < @height
idx = @_project x, y
@backgroundBuffer[idx] = color
setPixel: (x, y, color) ->

Wyświetl plik

@ -49,6 +49,10 @@ module.exports = class Canvas
bresenham projected[i-1]..., projected[i]...,
(x, y) => @buffer.setPixel x, y, color
background: (x, y, color) ->
point = @_project x, y
@buffer.setBackground point[0], point[1], color
# TODO: support for polygon holes
polygon: (points, color) ->
vertices = []

Wyświetl plik

@ -19,7 +19,7 @@ module.exports = class Renderer
labelMargin: 5
#"poi_label", "water",
drawOrder: ["admin", "building", "road", "place_label", "poi_label", "housenum_label"]
drawOrder: ["water", "admin", "building", "road", "place_label", "poi_label", "housenum_label"]
icons:
car: "🚗"
@ -109,9 +109,11 @@ module.exports = class Renderer
features = @features[layer].tree.search box
@notify "rendering #{features.length} #{layer} features.."
for feature in features
@_drawFeature layer, feature.data, scale
@_drawFeature layer, feature, scale
_drawFeature: (layer, data, scale) ->
feature = data.data
_drawFeature: (layer, feature, scale) ->
# TODO: this is ugly :) need to be fixed @style
#return false if feature.properties.class is "ferry"
feature.type = "LineString" if layer is "building" or layer is "road"
@ -137,6 +139,11 @@ module.exports = class Renderer
when "Polygon"
@canvas.polygon toDraw[0], colorCode
# points = toDraw[0]
# for y in [Math.max(0,Math.floor(data.minY/scale))..Math.min(@height, Math.floor(data.maxY/scale))] by 4
# for x in [Math.max(0, Math.floor(data.minX/scale))..Math.min(@width, Math.floor(data.maxX/scale))] by 2
# if utils.pointInPolygon points, [x, y]
# @canvas.background x, y, colorCode
when "Point"
text = feature.properties["name_"+@config.language] or

Wyświetl plik

@ -16,6 +16,7 @@ utils =
point[0] < (polygon[j][0]-polygon[i][0]) * (point[1]-polygon[i][1]) / (polygon[j][1]-polygon[i][1]) + polygon[i][0]
inside = !inside
j = i
inside
deg2rad: (angle) ->
# (angle / 180) * Math.PI