diff options
Diffstat (limited to 'assets/javascripts')
| -rw-r--r-- | assets/javascripts/rectangles/engine/builder.js | 8 | ||||
| -rw-r--r-- | assets/javascripts/rectangles/models/room.js | 18 | ||||
| -rw-r--r-- | assets/javascripts/rectangles/util/colors.js | 1 | ||||
| -rw-r--r-- | assets/javascripts/util.js | 6 |
4 files changed, 27 insertions, 6 deletions
diff --git a/assets/javascripts/rectangles/engine/builder.js b/assets/javascripts/rectangles/engine/builder.js index 42ef76b..4ccc649 100644 --- a/assets/javascripts/rectangles/engine/builder.js +++ b/assets/javascripts/rectangles/engine/builder.js @@ -15,6 +15,7 @@ var builder = new function(){ if (window.scene) { clear() build() + bind() } } function build (){ @@ -35,6 +36,13 @@ var builder = new function(){ }) }) } + + function bind (){ + clipper.rooms.forEach(function(r){ + r.bind() + }) + } + function clear (){ els.forEach(function(el){ scene.remove(el) diff --git a/assets/javascripts/rectangles/models/room.js b/assets/javascripts/rectangles/models/room.js index 4d83d56..f0ebc76 100644 --- a/assets/javascripts/rectangles/models/room.js +++ b/assets/javascripts/rectangles/models/room.js @@ -30,6 +30,18 @@ window.room = (function(){ this.$floor = $([]) this.$ceiling = $([]) } + + room.prototype.bind = function(){ + this.$walls.bind({ + mouseover: function(){ + }, + mousemove: function(e){ + }, + mousedown: function(){ + $(this).css("background-color", choice(window.palettes.colors)) + } + }) + } room.prototype.clipTo = function(r){ // for each of this rect's regions split the region if necessary @@ -86,9 +98,3 @@ window.room = (function(){ })() -function bitcount(v) { - v = v - ((v >>> 1) & 0x55555555); - v = (v & 0x33333333) + ((v >>> 2) & 0x33333333); - return ((v + (v >>> 4) & 0xF0F0F0F) * 0x1010101) >>> 24; -} - diff --git a/assets/javascripts/rectangles/util/colors.js b/assets/javascripts/rectangles/util/colors.js index 3bdebbc..77473d7 100644 --- a/assets/javascripts/rectangles/util/colors.js +++ b/assets/javascripts/rectangles/util/colors.js @@ -33,4 +33,5 @@ select.addEventListener("change", function(){ colors = color_palettes[select.value] }) window.colors = color_palettes[select.value] + window.palettes = color_palettes })() diff --git a/assets/javascripts/util.js b/assets/javascripts/util.js index 8a0e5ba..89889c4 100644 --- a/assets/javascripts/util.js +++ b/assets/javascripts/util.js @@ -155,3 +155,9 @@ function invert_hash (h) { return k } +function bitcount(v) { + v = v - ((v >>> 1) & 0x55555555); + v = (v & 0x33333333) + ((v >>> 2) & 0x33333333); + return ((v + (v >>> 4) & 0xF0F0F0F) * 0x1010101) >>> 24; +} + |
