diff options
Diffstat (limited to 'rect.js')
| -rw-r--r-- | rect.js | 30 |
1 files changed, 30 insertions, 0 deletions
@@ -58,3 +58,33 @@ rect.prototype.quantize = function(n){ this.x.quantize(n) this.y.quantize(n) } +rect.prototype.reset = function(){ + var copy = this.clone() + copy.sides = 0xf + this.regions = [ copy ] +} +rect.prototype.clipTo = function(r){ + // for each of this rect's regions split the region if necessary + for (var i = 0, len = regions.length; i < len; i++) { + if (regions[i] && regions[i].intersects(r)) { + var splits = regions[i].split(r) + regions.concat(splits) + regions[i] = null + } + } +} +rect.prototype.split = function(r){ + var splits = [] + + + + // 1 split (horizontal) + // 1 split (vertical) + // 2 splits (top left) + // 2 splits (top right) + // 2 splits (bottom left) + // 2 splits (bottom right) + // 3 splits (center) + + return splits +} |
