diff options
| author | Jules Laplace <jules@okfoc.us> | 2014-05-05 15:56:07 -0400 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2014-05-05 15:56:07 -0400 |
| commit | 9f4204d35f1dbd861417cd8a04bb26c46299f55a (patch) | |
| tree | 79a6f43198f38dba10de55d47c3995b83a29d263 /assets/javascripts/rectangles/util/constants.js | |
| parent | 79b0e1b0a127260978c69165466953ae86f6d6b2 (diff) | |
happy with refactor
Diffstat (limited to 'assets/javascripts/rectangles/util/constants.js')
| -rw-r--r-- | assets/javascripts/rectangles/util/constants.js | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/assets/javascripts/rectangles/util/constants.js b/assets/javascripts/rectangles/util/constants.js new file mode 100644 index 0000000..db4eebf --- /dev/null +++ b/assets/javascripts/rectangles/util/constants.js @@ -0,0 +1,46 @@ +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 height_min = 200, + height_max = 2000, + side_min = 10, + side_max = 5000, + resize_margin = 8 + +var painting_distance_from_wall = 8 + +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 " + 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 + } +} |
