diff options
Diffstat (limited to 'public/assets/javascripts/rectangles')
3 files changed, 17 insertions, 6 deletions
diff --git a/public/assets/javascripts/rectangles/engine/map/draw.js b/public/assets/javascripts/rectangles/engine/map/draw.js index c97603b..8498a46 100644 --- a/public/assets/javascripts/rectangles/engine/map/draw.js +++ b/public/assets/javascripts/rectangles/engine/map/draw.js @@ -22,7 +22,13 @@ Map.Draw = function(map, opt){ ctx.scale( -1, 1 ) draw.coords() - draw.regions(Rooms.regions, [ "#fff" ], "#000") + if (Rooms.shapesMode) { + shapes.draw(draw.ctx, "#fff", null) + shapes.draw(draw.ctx, null, "#000") + } + else { + draw.regions(Rooms.regions, [ "#fff" ], "#000") + } draw.camera(scene.camera) } else { diff --git a/public/assets/javascripts/rectangles/engine/shapes/polyline.js b/public/assets/javascripts/rectangles/engine/shapes/polyline.js index 54e11c6..fc6cad7 100644 --- a/public/assets/javascripts/rectangles/engine/shapes/polyline.js +++ b/public/assets/javascripts/rectangles/engine/shapes/polyline.js @@ -95,7 +95,7 @@ var Polyline = Fiber.extend(function(base){ tail: closest_i, } } - exports.draw = function(ctx){ + exports.draw = function(ctx, fillStyle, strokeStyle){ var points = this.points if (! points.length) return if (points.length == 1) { @@ -103,17 +103,17 @@ var Polyline = Fiber.extend(function(base){ map.draw.dot_at(this.points[0].a, points[0].b, 5) } if (points.length > 1) { - ctx.fillStyle = "rgba(255,255,0,0.1)" - ctx.strokeStyle = "#f80" + ctx.fillStyle = fillStyle + ctx.strokeStyle = strokeStyle ctx.lineWidth = 2 / map.zoom ctx.beginPath() ctx.moveTo(points[0].a, points[0].b) points.forEach(function(point, i){ i && ctx.lineTo(point.a, point.b) }) - ctx.stroke() + strokeStyle && ctx.stroke() if (! map.ui.placing || this.closed) { - ctx.fill() + fillStyle && ctx.fill() } } } diff --git a/public/assets/javascripts/rectangles/engine/shapes/shapelist.js b/public/assets/javascripts/rectangles/engine/shapes/shapelist.js index 9cbf165..75ecae6 100644 --- a/public/assets/javascripts/rectangles/engine/shapes/shapelist.js +++ b/public/assets/javascripts/rectangles/engine/shapes/shapelist.js @@ -76,6 +76,11 @@ var ShapeList = Fiber.extend(function(base){ }) return segments } + exports.draw = function(ctx, fillStyle, strokeStyle) { + this.shapes.forEach(function(shape){ + shape.draw(ctx, fillStyle, strokeStyle) + }) + } exports.serialize = function(){ return this.shapes.map(function(shape){ return shape.serialize() |
