diff options
Diffstat (limited to 'client/assets/javascripts/rectangles/util/constants.js')
| -rw-r--r-- | client/assets/javascripts/rectangles/util/constants.js | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/client/assets/javascripts/rectangles/util/constants.js b/client/assets/javascripts/rectangles/util/constants.js new file mode 100644 index 0000000..58cb1a5 --- /dev/null +++ b/client/assets/javascripts/rectangles/util/constants.js @@ -0,0 +1,57 @@ +var FRONT = 0x1, BACK = 0x2, LEFT = 0x4, RIGHT = 0x8, FLOOR = 0x10, CEILING = 0x20 + FRONT_BACK = FRONT | BACK, LEFT_RIGHT = LEFT | RIGHT, FLOOR_CEILING = FLOOR | CEILING + +var TOP = CEILING, BOTTOM = FLOOR, + TOP_LEFT = TOP | LEFT, + TOP_RIGHT = TOP | RIGHT, + BOTTOM_LEFT = BOTTOM | LEFT, + BOTTOM_RIGHT = BOTTOM | RIGHT, + TOP_BOTTOM = TOP | BOTTOM + +var height_min = 200, + height_max = 2000, + side_min = 10, + side_max = 5000, + resize_margin = 8, + cursor_amp = 1.5 + +var painting_distance_from_wall = 8, + dot_distance_from_picture = 3 + +var dot_hide_delay = 50, // ms + dot_side = 20 + +var wall_rotation = {} +wall_rotation[FRONT] = PI +wall_rotation[BACK] = 0 +wall_rotation[LEFT] = HALF_PI +wall_rotation[RIGHT] = -HALF_PI + + + +function sidesToString(sides){ + var s = "" + if (sides & FRONT) s += "front " + if (sides & BACK) s += "back " + if (sides & LEFT) s += "left " + if (sides & RIGHT) s += "right " + if (sides & TOP) s += "top " + if (sides & BOTTOM) s += "bottom " + return s +} + +function side_direction (a, b) { + if (a === b) return 0 + if ((a | b) === FRONT_BACK) return 0 + if ((a | b) === LEFT_RIGHT) return 0 + switch (a) { + case FRONT: + return b & LEFT ? -1 : 1 + case BACK: + return b & RIGHT ? -1 : 1 + case LEFT: + return b & FRONT ? -1 : 1 + case RIGHT: + return b & BACK ? -1 : 1 + } +} |
