summaryrefslogtreecommitdiff
path: root/public
diff options
context:
space:
mode:
Diffstat (limited to 'public')
-rw-r--r--public/assets/javascripts/rectangles/engine/map/tools/line.js16
-rw-r--r--public/assets/javascripts/rectangles/engine/map/tools/ortho.js2
-rw-r--r--public/assets/javascripts/rectangles/engine/map/tools/polyline.js2
-rw-r--r--public/assets/javascripts/rectangles/engine/shapes/polyline.js1
-rw-r--r--public/assets/javascripts/rectangles/engine/shapes/regionlist.js2
-rw-r--r--public/assets/javascripts/rectangles/engine/shapes/shapelist.js7
-rw-r--r--public/assets/javascripts/ui/blueprint/BlueprintEditor.js8
-rw-r--r--public/assets/javascripts/ui/blueprint/BlueprintSettings.js1
-rw-r--r--public/assets/test/ortho2.html9
9 files changed, 39 insertions, 9 deletions
diff --git a/public/assets/javascripts/rectangles/engine/map/tools/line.js b/public/assets/javascripts/rectangles/engine/map/tools/line.js
index 8f409a8..8fe4fff 100644
--- a/public/assets/javascripts/rectangles/engine/map/tools/line.js
+++ b/public/assets/javascripts/rectangles/engine/map/tools/line.js
@@ -1,3 +1,6 @@
+// This tool lets you define a very simple line between two points.
+// It is used by the BlueprintScaler to specify a sample distance to scale.
+
var LineTool = MapTool.extend(function(base){
var exports = {}
@@ -8,6 +11,17 @@ var LineTool = MapTool.extend(function(base){
var can_drag, dragging
exports.down = function(e, cursor){
+
+ // rightclick?
+ if (e.ctrlKey || e.which === 3) {
+ cursor.quantize(1/map.zoom)
+ app.router.blueprintView.map.center.a = cursor.x.a
+ app.router.blueprintView.map.center.b = -cursor.y.a
+ cursor.x.b = cursor.x.a
+ cursor.y.b = cursor.y.a
+ return
+ }
+
this.cursor = cursor
switch (line.length) {
case 0:
@@ -44,6 +58,6 @@ var LineTool = MapTool.extend(function(base){
exports.up = function(e, cursor){
can_drag = dragging = false
}
-
+
return exports
}) \ No newline at end of file
diff --git a/public/assets/javascripts/rectangles/engine/map/tools/ortho.js b/public/assets/javascripts/rectangles/engine/map/tools/ortho.js
index ef41096..918ac0d 100644
--- a/public/assets/javascripts/rectangles/engine/map/tools/ortho.js
+++ b/public/assets/javascripts/rectangles/engine/map/tools/ortho.js
@@ -14,6 +14,7 @@ var OrthoPolylineTool = MapTool.extend(function (base) {
map.ui.placing = false
if (shapes.workline.points.length > 2) {
shapes.workline.build()
+ shapes.add(shapes.workline)
}
else {
shapes.workline.reset()
@@ -35,6 +36,7 @@ var OrthoPolylineTool = MapTool.extend(function (base) {
else if (shapes.workline.canCloseWith(p)) {
shapes.workline.close()
shapes.workline.build()
+ shapes.add(shapes.workline)
map.ui.placing = false
}
else {
diff --git a/public/assets/javascripts/rectangles/engine/map/tools/polyline.js b/public/assets/javascripts/rectangles/engine/map/tools/polyline.js
index 1ab86f6..6716180 100644
--- a/public/assets/javascripts/rectangles/engine/map/tools/polyline.js
+++ b/public/assets/javascripts/rectangles/engine/map/tools/polyline.js
@@ -11,6 +11,7 @@ var PolylineTool = MapTool.extend(function (base) {
map.ui.placing = false
if (shapes.workline.points.length > 2) {
shapes.workline.build()
+ shapes.add(shapes.workline)
}
else {
shapes.workline.reset()
@@ -27,6 +28,7 @@ var PolylineTool = MapTool.extend(function (base) {
if (shapes.workline.canCloseWith(p)) {
shapes.workline.close()
shapes.workline.build()
+ shapes.add(shapes.workline)
map.ui.placing = false
}
else {
diff --git a/public/assets/javascripts/rectangles/engine/shapes/polyline.js b/public/assets/javascripts/rectangles/engine/shapes/polyline.js
index 609a2c8..54e11c6 100644
--- a/public/assets/javascripts/rectangles/engine/shapes/polyline.js
+++ b/public/assets/javascripts/rectangles/engine/shapes/polyline.js
@@ -133,7 +133,6 @@ var Polyline = Fiber.extend(function(base){
exports.build = function(){
this.mx_points && this.mx_points.forEach(function(mx){ scene.remove(mx) })
this.mx = new MX.Polyline(this)
- shapes.add(this)
}
exports.rebuild = function(){
this.mx.rebuild()
diff --git a/public/assets/javascripts/rectangles/engine/shapes/regionlist.js b/public/assets/javascripts/rectangles/engine/shapes/regionlist.js
index 663f3fd..86269a6 100644
--- a/public/assets/javascripts/rectangles/engine/shapes/regionlist.js
+++ b/public/assets/javascripts/rectangles/engine/shapes/regionlist.js
@@ -169,7 +169,7 @@ var RegionList = (function(){
}
}
- return { rooms: rooms }
+ return rooms
}
diff --git a/public/assets/javascripts/rectangles/engine/shapes/shapelist.js b/public/assets/javascripts/rectangles/engine/shapes/shapelist.js
index 90714c2..9cbf165 100644
--- a/public/assets/javascripts/rectangles/engine/shapes/shapelist.js
+++ b/public/assets/javascripts/rectangles/engine/shapes/shapelist.js
@@ -85,8 +85,13 @@ var ShapeList = Fiber.extend(function(base){
data && data.forEach(function(points){
var line = new Polyline()
line.deserialize(points)
- line.build()
+ shapes.add(line)
}.bind(this))
}
+ exports.build = function(){
+ this.shapes.forEach(function(shape){
+ shape.build()
+ })
+ }
return exports
}) \ No newline at end of file
diff --git a/public/assets/javascripts/ui/blueprint/BlueprintEditor.js b/public/assets/javascripts/ui/blueprint/BlueprintEditor.js
index a341a24..547cdca 100644
--- a/public/assets/javascripts/ui/blueprint/BlueprintEditor.js
+++ b/public/assets/javascripts/ui/blueprint/BlueprintEditor.js
@@ -5,7 +5,7 @@ var last_point = new vec2 (0,0)
var BlueprintEditor = View.extend(AnimatedView.prototype).extend({
- rooms: [],
+ regions: [],
initialize: function(opt){
this.parent = opt.parent
@@ -82,7 +82,7 @@ var BlueprintEditor = View.extend(AnimatedView.prototype).extend({
scale: media.scale,
})
this.startAnimating()
- this.rooms = RegionList.build()
+ this.regions = RegionList.build()
},
animate: function(t, dt){
@@ -118,9 +118,9 @@ var BlueprintEditor = View.extend(AnimatedView.prototype).extend({
// var colors = ["rgba(0,0,0,0.1)"]
// var colors = ["rgba(255,255,255,1)"]
//
- map.draw.regions(this.rooms.rooms, colors, "#000")
+ map.draw.regions(this.regions, colors, "#000")
-// this.rooms.rooms.forEach(function(room,i){
+// this.regions.forEach(function(room,i){
// map.draw.ctx.fillStyle = colors[i % colors.length]
// map.draw.ctx.fillRect( room.x.a, room.y.a, room.width(), room.height() )
// })
diff --git a/public/assets/javascripts/ui/blueprint/BlueprintSettings.js b/public/assets/javascripts/ui/blueprint/BlueprintSettings.js
index 252e3f1..9c8808a 100644
--- a/public/assets/javascripts/ui/blueprint/BlueprintSettings.js
+++ b/public/assets/javascripts/ui/blueprint/BlueprintSettings.js
@@ -35,6 +35,7 @@ var BlueprintSettings = FormView.extend(ToggleableView.prototype).extend({
if (data.shapes) {
shapes.destroy()
shapes.deserialize( data.shapes )
+ shapes.build()
}
this.data = data
},
diff --git a/public/assets/test/ortho2.html b/public/assets/test/ortho2.html
index 448f029..ef77256 100644
--- a/public/assets/test/ortho2.html
+++ b/public/assets/test/ortho2.html
@@ -58,7 +58,9 @@ body {
<script src="/assets/javascripts/rectangles/models/rect.js"></script>
<script src="/assets/javascripts/rectangles/models/rect.js"></script>
<script src="/assets/javascripts/rectangles/engine/map/_map.js"></script>
-<script src="/assets/javascripts/rectangles/engine/map/ui_ortho.js"></script>
+<script src="/assets/javascripts/rectangles/engine/map/ui/ortho.js"></script>
+<script src="/assets/javascripts/rectangles/engine/map/tools/_base.js"></script>
+<script src="/assets/javascripts/rectangles/engine/map/tools/arrow.js"></script>
<script src="/assets/javascripts/rectangles/engine/map/draw.js"></script>
<script>
@@ -73,6 +75,7 @@ var MapTool = Fiber.extend(function(base){
move: function(e, cursor){},
drag: function(e, cursor){},
up: function(e, cursor, new_cursor){},
+ cancel: function(){},
}
return exports
})
@@ -150,6 +153,7 @@ var PolylineTool = MapTool.extend(function (base) {
})
var scene, map, controls
+var last_point = new vec2(0,0)
map = new Map ({
type: "ortho",
@@ -161,6 +165,7 @@ map = new Map ({
map.ui.add_tool("arrow", new ArrowTool)
map.ui.add_tool("polyline", new PolylineTool)
map.ui.add_tool("position", new PositionTool)
+map.ui.set_tool("arrow")
$(window).resize(function(){
scene.width = window.innerWidth/2
@@ -174,6 +179,8 @@ var shapes = []
var ctx = map.draw.ctx
var last_point
+shapes.findClosestPoint = function(){}
+
function polyline (points, finished) {
if (! points) return
if (points.length == 1) {