summaryrefslogtreecommitdiff
path: root/rect.js
diff options
context:
space:
mode:
authorJulie Lala <jules@okfoc.us>2014-04-11 10:20:57 -0400
committerJulie Lala <jules@okfoc.us>2014-04-11 10:20:57 -0400
commit6f895c8db89ce8ae6295db1dc93284cdb521217c (patch)
tree606a701523319dd41dff18a42556b993cf3f62d3 /rect.js
parent30d75e82c7649ef2ab9f71fa360f5735eb098bc5 (diff)
notes
Diffstat (limited to 'rect.js')
-rw-r--r--rect.js30
1 files changed, 30 insertions, 0 deletions
diff --git a/rect.js b/rect.js
index dcf2d33..f643b6f 100644
--- a/rect.js
+++ b/rect.js
@@ -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
+}