summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--public/assets/javascripts/rectangles/models/surface.js224
-rw-r--r--public/assets/javascripts/rectangles/models/vec2.js4
-rw-r--r--test/01-test-vec2.js19
-rw-r--r--test/07-test-surface.js267
4 files changed, 352 insertions, 162 deletions
diff --git a/public/assets/javascripts/rectangles/models/surface.js b/public/assets/javascripts/rectangles/models/surface.js
index 8330d41..9b82e4e 100644
--- a/public/assets/javascripts/rectangles/models/surface.js
+++ b/public/assets/javascripts/rectangles/models/surface.js
@@ -70,16 +70,14 @@
}
return null
}
- Surface.prototype.place = function(v, index){
- var face, faces = this.faces
- }
- function center (dimension, position) {
- return new vec2( position.a + dimension.a/2, position.b + dimension.b/2 )
- }
- function edges (dimension, position) {
- return new Rect( position.a, position.a + dimension.a,
- position.b, position.b + dimension.b )
+ function center_for (dimension, position, delta) {
+ var center = new vec2( position.a + dimension.a/2, position.b + dimension.b/2 )
+ if (delta) {
+ center.a += delta.a
+ center.b += delta.b
+ }
+ return center
}
Surface.prototype.clamp_delta = function (bounds, dimension, position, delta) {
@@ -104,26 +102,38 @@
}
}
- Surface.prototype.fit = function (old_bounds, dimension, position, delta) {
- // to reposition one of these fucking things
- // assume it's already in a valid position
-
+ Surface.prototype.translate = function (old_bounds, dimension, position, delta) {
this.clamp_delta( this.bounds, dimension, position, delta )
- // if it's moved and it's within the current bounds, we're done
- // it's outside the general bounds, do an initial clamp
- // given the center, find the element it wants to lie on
- // if it's too short for this element, look to the (left? right? compare dx) for the first element tall enough for it
- // move the (right? left?) edge to whatever div that is and move the center
- // find the elements containing the left and right edges, and any in between
- //
+ var left_side = this.index_for_x( position.a + delta.a, 0 )
+ var right_side = this.index_for_x( position.a + dimension.a + delta.a, left_side )
+
+ var bounds = this.sides[left_side].clone()
+
+ for (var i = left_side+1; i <= right_side; i++) {
+ if (this.faces[i].y.a > bounds.y.a) {
+ bounds.y.a = this.faces[i].y.a
+ }
+ if (this.faces[i].y.b < bounds.y.b) {
+ bounds.y.b = this.faces[i].y.b
+ }
+ bounds.x.b = this.faces[i].x.b
+ }
+
+ if (bounds.width() > dimension.a || bounds.height() > dimension.b) {
+ bounds = old_bounds
+ }
+
+ this.clamp_delta(bounds, dimension, position, delta)
+ return bounds
}
- Surface.prototype.index_for_x = function(x){
+ Surface.prototype.index_for_x = function(x, min_i){
+ min_i = min_i || 0
if (x < 0 || x > width) {
return -1
}
- for (var i = 0; i < this.faces.length; i++) {
+ for (var i = min_i; i < this.faces.length; i++) {
if (this.faces[i].x.contains(x)) {
return i
}
@@ -131,107 +141,113 @@
return -1
}
- Surface.prototype.bounds_at_index = function(index){
- var bounds = faces[index].clone()
- var height = faces[index].height()
- bounds.first = bounds.last = index
+ Surface.prototype.bounds_at_index_with_dimensions = function(index, dimensions){
+ var faces = this.faces
+ if (index == -1) index = this.faces.length-1
- for (var i = index-1; i >= 0; i--) {
+ var bounds, intersection
+ var width = dimensions.a
+ var height = dimensions.b
+
+ for (var i = index; i >= 0; i--) {
var face = faces[i]
if (face.y.length() < height) {
- continue
+ if (bounds) break
+ else continue
}
- if (face.y.a > bounds.y.a) {
- continue
- }
- if (face.y.b < bounds.y.b) {
- continue
+ if (! bounds) {
+ bounds = face.clone()
+ bounds.last = i
+ }
+ else if (bounds.width() < width) {
+ intersection = bounds.y.intersection(face.y)
+ if (intersection.length() < height) {
+ break
+ }
+ else {
+ bounds.y.a = intersection.a
+ bounds.y.b = intersection.b
+ bounds.x.a = face.x.a
+ bounds.first = i
+ continue
+ }
+ }
+ else {
+ if (face.y.a > bounds.y.a) break
+ if (face.y.b < bounds.y.b) break
}
- bounds.x.a = bounds.x.a
+ bounds.x.a = face.x.a
bounds.first = i
}
-
- for (var i = index+1; i < faces.length; i++) {
+
+ for (var i = bounds ? bounds.last+1 : index+1; i < faces.length; i++) {
var face = faces[i]
if (face.y.length() < height) {
- continue
- }
- if (face.y.a > bounds.y.a) {
- continue
+ if (bounds) break
+ else continue
}
- if (face.y.b < bounds.y.b) {
- continue
- }
- bounds.x.b = bounds.x.b
+ if (! bounds) {
+ bounds = face.clone()
+ bounds.first = i
+ }
+ else if (bounds.width() < width) {
+ intersection = bounds.y.intersection(face.y)
+ if (intersection.length() < height) {
+ break
+ }
+ else {
+ bounds.y.a = intersection.a
+ bounds.y.b = intersection.b
+ bounds.x.b = face.x.b
+ bounds.last = i
+ continue
+ }
+ }
+ if (face.y.a > bounds.y.a) break
+ if (face.y.b < bounds.y.b) break
+ bounds.x.b = face.x.b
bounds.last = i
}
+
+ if (! bounds) {
+ // console.log('no bounds')
+ return false
+ }
+ else if (bounds.width() < width) {
+ // console.log('too narrow')
+ return false
+ }
return bounds
}
- Surface.prototype.clamp = function (bounds, dimension, position, dx, dy) {
- // we start out with a set of boundaries where we know the object should fall
- // we then check if we've moved the box off any edge of the bounds
- // if so, check if the new position is valid with respect to the surface.
- // for horizontal movement, this means checking the height and boundaries of
- // faces with adjacent indexes
- var p = position.clone(), nextIndex, nextFace, newBounds
- p.a += dx
- p.b += dy
+ Surface.prototype.bounds_at_index = function(index){
+ var faces = this.faces
+ if (index == -1) index = this.faces.length-1
- // left edge
- if (p.a < bounds.x.a) {
- if (bounds.first == 0) {
- p.a = bounds.x.a
- }
- else {
- nextIndex = bounds.first - 1
- nextFace = this.faces[nextIndex]
- if (nextFace.y.a <= p.b && p.b + dimension.b <= nextFace.y.b) {
- // it appears the div to the left will accomodate this element
- }
- else {
- p.a = bounds.x.a
- }
- }
- }
- // right edge
- else if (p.a + dimension.a > bounds.x.b) {
- if (bounds.last == this.faces.length-1) {
- p.a = bounds.x.b - dimension.a
- }
- else {
- nextIndex = bounds.last + 1
- nextFace = this.faces[nextIndex]
- if (nextFace.y.a <= p.b && p.b + dimension.b <= nextFace.y.b) {
- // it appears the div to the right will accomodate this element
- }
- else {
- p.a = bounds.x.b - dimension.a
- }
- }
+ var bounds = faces[index].clone()
+ var height = faces[index].height()
+ bounds.first = bounds.last = index
+
+ for (var i = index-1; i >= 0; i--) {
+ var face = faces[i]
+ if (face.y.length() < height) break
+ if (face.y.a > bounds.y.a) break
+ if (face.y.b < bounds.y.b) break
+
+ bounds.x.a = face.x.a
+ bounds.first = i
}
- // for vertical movement, this means checking the height and boundaries of
- // elements in the set of bounds' indexes
- if (p.b < bounds.y.a) {
- for (var i = Math.min(nextIndex, bounds.first), last = Math.max(nextIndex, bounds.last); i < last; i++) {
- face = this.faces[i]
- // loop over each of the faces in the list
- // given a face, figure out if the new top-left is in its bounds
- // if so, find which one contains its right edge
- // get the lowest height of this set
- // then clamp to that lowest height
- // additionally, this is the new center-index
- // recalculate the bounds
-// if (face.x.b < p.
-// for (var j = bounds.first+1; j < bounds.last
- }
- }
- // bottom edge, so we can clamp here trivially
- else if (p.b + dimension.b > bounds.y.b) {
- p.b = bounds.y.b - dimension.b
+ for (var i = index+1; i < faces.length; i++) {
+ var face = faces[i]
+ if (face.y.length() < height) break
+ if (face.y.a > bounds.y.a) break
+ if (face.y.b < bounds.y.b) break
+
+ bounds.x.b = face.x.b
+ bounds.last = i
}
- // if we're able to move out of bounds in that direction, recalculate the bounds
+ return bounds
}
if ('window' in this) {
diff --git a/public/assets/javascripts/rectangles/models/vec2.js b/public/assets/javascripts/rectangles/models/vec2.js
index 214feb9..a36c614 100644
--- a/public/assets/javascripts/rectangles/models/vec2.js
+++ b/public/assets/javascripts/rectangles/models/vec2.js
@@ -123,12 +123,12 @@
}
vec2.prototype.union = function(v){
if (this.intersects(v)) {
- return new vec2( min(this.a,v.a), max(this.b, v.b) )
+ return new vec2( Math.min(this.a,v.a), Math.max(this.b, v.b) )
}
}
vec2.prototype.intersection = function(v){
if (this.intersects(v)) {
- return new vec2( max(this.a,v.a), min(this.b, v.b) )
+ return new vec2( Math.max(this.a,v.a), Math.min(this.b, v.b) )
}
}
diff --git a/test/01-test-vec2.js b/test/01-test-vec2.js
index 6104f92..429c537 100644
--- a/test/01-test-vec2.js
+++ b/test/01-test-vec2.js
@@ -37,6 +37,25 @@ describe('vec2', function(){
})
})
+ describe('#intersection()', function(){
+ it('intersects from left', function(){
+ var inter = vec.intersection( new vec2( 5, 15 ) )
+ assert.equal(true, inter.eq( new vec2(5, 10) ))
+ })
+ it('intersects from right', function(){
+ var inter = vec.intersection( new vec2( -5, 5 ) )
+ assert.equal(true, inter.eq( new vec2(0, 5) ))
+ })
+ it('intersects inner', function(){
+ var inter = vec.intersection( new vec2( 2, 5 ) )
+ assert.equal(true, inter.eq( new vec2(2, 5) ))
+ })
+ it('intersects outer', function(){
+ var inter = vec.intersection( new vec2( -5, 15 ) )
+ assert.equal(true, inter.eq( new vec2(0, 10) ))
+ })
+ })
+
describe('#contains()', function(){
it('contains itself', function(){
assert.equal(true, vec.contains( 0 ));
diff --git a/test/07-test-surface.js b/test/07-test-surface.js
index 2a51b7f..fa05d43 100644
--- a/test/07-test-surface.js
+++ b/test/07-test-surface.js
@@ -7,15 +7,19 @@ var Surface = require("../public/assets/javascripts/rectangles/models/surface.js
// [[3 4] [2 4]] front back left right
// [[4 5] [0 4]] front back left right
+var small = new vec2(2, 2)
+var wide = new vec2(5, 1)
+var tall = new vec2(1, 5)
+var large = new vec2(7, 7)
+var position = new vec2(2, 1)
+
describe('basic surface', function(){
var surface = new Surface ()
surface.add( new Rect( new vec2(1, 6), new vec2(0, 4) ) )
- var small = new vec2(2, 2)
- var oblong = new vec2(4, 1)
+ var position = new vec2(2, 1)
describe('#clamp_delta()', function(){
- var position = new vec2(2,1)
it("does not alter a zero delta", function(){
var delta = new vec2(0,0)
surface.clamp_delta(surface.bounds, small, position, delta)
@@ -48,64 +52,152 @@ describe('basic surface', function(){
})
})
- describe('#place()', function(){
- it("fits a small element on the top left", function(){
- var bounds = surface.place(small, new vec2(1,3))
-// console.log(bounds)
+ describe('#bounds_at_index_with_dimensions()', function(){
+ it("generates proper bounds from left", function(){
+ var bounds = surface.bounds_at_index_with_dimensions(0, small)
+ assert.notEqual(false, bounds)
+ assert.equal(true, bounds.eq(new Rect(1,0, 6,4)))
+ })
+ it("generates proper bounds with wide", function(){
+ var bounds = surface.bounds_at_index_with_dimensions(0, wide)
+ assert.notEqual(false, bounds)
+ assert.equal(true, bounds.eq(new Rect(1,0, 6,4)))
})
- it("places a small element on the right", function(){
- var bounds = surface.place(small, new vec2(4,6))
-// console.log(bounds)
+ it("returns false for large image", function(){
+ var bounds = surface.bounds_at_index_with_dimensions(0, large)
+ assert.equal(false, bounds)
})
})
-
- // describe placement
- // describe dragging up (clamp at top edge)
- // describe dragging down (clamp at bottom edge)
- // describe dragging left (clamp at left edge)
- // describe dragging right (clamp at right edge)
})
describe('double surface', function(){
var surface = new Surface ()
- surface.add( new Rect( new vec2(0, 3), new vec2(0, 4) ) )
- surface.add( new Rect( new vec2(3, 5), new vec2(0, 4) ) )
+ surface.add( new Rect( new vec2(1, 3), new vec2(0, 4) ) )
+ surface.add( new Rect( new vec2(3, 6), new vec2(0, 4) ) )
- var small = new vec2(2, 2)
- var oblong = new vec2(4, 1)
-
- // describe placement
- // describe dragging up (clamp at top edge)
- // describe dragging down (clamp at bottom edge)
- // describe dragging left (clamp at left edge)
- // describe dragging right (clamp at right edge)
+ describe('#bounds_at_index_with_dimensions()', function(){
+ it("generates proper bounds from left", function(){
+ var bounds = surface.bounds_at_index_with_dimensions(0, small)
+ assert.notEqual(false, bounds)
+ assert.equal(true, bounds.eq(new Rect(1,0, 6,4)))
+ })
+ it("generates proper bounds from right", function(){
+ var bounds = surface.bounds_at_index_with_dimensions(1, small)
+ assert.notEqual(false, bounds)
+ assert.equal(true, bounds.eq(new Rect(1,0, 6,4)))
+ })
+ it("generates proper bounds with wide", function(){
+ var bounds = surface.bounds_at_index_with_dimensions(0, wide)
+ assert.notEqual(false, bounds)
+ assert.equal(true, bounds.eq(new Rect(1,0, 6,4)))
+ })
+ it("generates proper bounds with wide from right", function(){
+ var bounds = surface.bounds_at_index_with_dimensions(1, wide)
+ assert.notEqual(false, bounds)
+ assert.equal(true, bounds.eq(new Rect(1,0, 6,4)))
+ })
+ it("returns false for large image", function(){
+ var bounds = surface.bounds_at_index_with_dimensions(0, large)
+ assert.equal(false, bounds)
+ })
+ })
})
describe('two-level surface', function(){
var surface = new Surface ()
- surface.add( new Rect( new vec2(0, 3), new vec2(0, 4) ) )
- surface.add( new Rect( new vec2(3, 5), new vec2(0, 6) ) )
+ surface.add( new Rect( new vec2(1, 3), new vec2(0, 4) ) )
+ surface.add( new Rect( new vec2(3, 6), new vec2(0, 6) ) )
+
+ describe('#bounds_at_index_with_dimensions()', function(){
+ it("generates proper bounds from left", function(){
+ var bounds = surface.bounds_at_index_with_dimensions(0, small)
+ assert.notEqual(false, bounds)
+ assert.equal(true, bounds.eq(new Rect(1,0, 6,4)))
+ })
+ it("generates proper bounds from right", function(){
+ var bounds = surface.bounds_at_index_with_dimensions(1, small)
+ assert.notEqual(false, bounds)
+ assert.equal(true, bounds.eq(new Rect(3,0, 6,6)))
+ })
+ it("generates proper bounds with wide", function(){
+ var bounds = surface.bounds_at_index_with_dimensions(0, wide)
+ assert.notEqual(false, bounds)
+ assert.equal(true, bounds.eq(new Rect(1,0, 6,4)))
+ })
+ it("generates proper bounds with wide from right", function(){
+ var bounds = surface.bounds_at_index_with_dimensions(1, wide)
+ assert.notEqual(false, bounds)
+ assert.equal(true, bounds.eq(new Rect(1,0, 6,4)))
+ })
+ it("generates proper bounds with tall", function(){
+ var bounds = surface.bounds_at_index_with_dimensions(0, tall)
+ assert.notEqual(false, bounds)
+ assert.equal(true, bounds.eq(new Rect(3,0, 6,6)))
+ })
+ it("generates the same bounds with tall from right", function(){
+ var bounds = surface.bounds_at_index_with_dimensions(1, tall)
+ assert.notEqual(false, bounds)
+ assert.equal(true, bounds.eq(new Rect(3,0, 6,6)))
+ })
+ it("returns false for large image", function(){
+ var bounds = surface.bounds_at_index_with_dimensions(0, large)
+ assert.equal(false, bounds)
+ })
- var small = new vec2(2, 2)
- var oblong = new vec2(4, 1)
+ })
- // describe placement/centering
- // describe dragging up (clamp at top edge)
- // describe dragging down (clamp at bottom edge)
- // describe dragging left (clamp at left edge)
- // describe dragging right (clamp at right edge)
- // describe dragging up and right (clamp at top edge, then pop into peninsula space)
})
describe('door surface', function(){
var surface = new Surface ()
- surface.add( new Rect( new vec2(0, 3), new vec2(0, 4) ) )
- surface.add( new Rect( new vec2(3, 4), new vec2(2, 4) ) )
- surface.add( new Rect( new vec2(4, 6), new vec2(0, 4) ) )
+ surface.add( new Rect( new vec2(1, 4), new vec2(0, 4) ) )
+ surface.add( new Rect( new vec2(4, 5), new vec2(2, 4) ) )
+ surface.add( new Rect( new vec2(5, 8), new vec2(0, 4) ) )
- var small = new vec2(2, 2)
- var large = new vec2(10, 10)
- var oblong = new vec2(4, 1)
+ describe('#bounds_at_index_with_dimensions()', function(){
+ it("generates proper bounds from left", function(){
+ var bounds = surface.bounds_at_index_with_dimensions(0, small)
+ assert.notEqual(false, bounds)
+ assert.equal(true, bounds.eq(new Rect(1,0, 4,4)))
+ })
+ it("generates proper bounds from middle", function(){
+ var bounds = surface.bounds_at_index_with_dimensions(1, small)
+ assert.notEqual(false, bounds)
+ assert.equal(true, bounds.eq(new Rect(1,2, 8,4)))
+ })
+ it("generates proper bounds from right", function(){
+ var bounds = surface.bounds_at_index_with_dimensions(2, small)
+ assert.notEqual(false, bounds)
+ assert.equal(true, bounds.eq(new Rect(5,0, 8,4)))
+ })
+
+ it("generates proper bounds for wide from left", function(){
+ var bounds = surface.bounds_at_index_with_dimensions(0, wide)
+ assert.notEqual(false, bounds)
+ assert.equal(true, bounds.eq(new Rect(1,2, 8,4)))
+ })
+ it("generates proper bounds for wide from middle", function(){
+ var bounds = surface.bounds_at_index_with_dimensions(1, wide)
+ assert.notEqual(false, bounds)
+ assert.equal(true, bounds.eq(new Rect(1,2, 8,4)))
+ })
+ it("generates proper bounds for wide from right", function(){
+ var bounds = surface.bounds_at_index_with_dimensions(2, wide)
+ assert.notEqual(false, bounds)
+ assert.equal(true, bounds.eq(new Rect(1,2, 8,4)))
+ })
+
+ it("returns false for tall", function(){
+ assert.equal(false, surface.bounds_at_index_with_dimensions(0, tall))
+ assert.equal(false, surface.bounds_at_index_with_dimensions(1, tall))
+ assert.equal(false, surface.bounds_at_index_with_dimensions(2, tall))
+ })
+ it("returns false for large image", function(){
+ assert.equal(false, surface.bounds_at_index_with_dimensions(0, large))
+ assert.equal(false, surface.bounds_at_index_with_dimensions(1, large))
+ assert.equal(false, surface.bounds_at_index_with_dimensions(2, large))
+ })
+ })
describe('#fits()', function(){
it("fits something small", function(){
@@ -114,8 +206,8 @@ describe('door surface', function(){
it("doesn't fit something large", function(){
assert.equal(false, !! surface.fits(large))
})
- it("fits something oblong", function(){
- assert.equal(true, !! surface.fits(oblong))
+ it("fits something wide", function(){
+ assert.equal(true, !! surface.fits(wide))
})
})
describe('#fits_scale()', function(){
@@ -125,24 +217,87 @@ describe('door surface', function(){
it("doesn't fit something small, scaled up", function(){
assert.equal(false, !! surface.fits_scale(small, 10))
})
- it("doesn't fit something oblong, scaled up", function(){
- assert.equal(false, !! surface.fits_scale(oblong, 10))
+ it("doesn't fit something wide, scaled up", function(){
+ assert.equal(false, !! surface.fits_scale(wide, 10))
})
})
- describe('#place()', function(){
- it("fits a small element on the top left", function(){
- var bounds = surface.place(small, new vec2(1,3))
-// console.log(bounds)
+})
+
+describe('double door surface', function(){
+ var surface = new Surface ()
+ surface.add( new Rect( new vec2(1, 4), new vec2(0, 4) ) )
+ surface.add( new Rect( new vec2(4, 5), new vec2(2, 4) ) )
+ surface.add( new Rect( new vec2(5, 8), new vec2(0, 6) ) )
+ surface.add( new Rect( new vec2(8, 10), new vec2(2, 4) ) )
+ surface.add( new Rect( new vec2(10, 14), new vec2(0, 4) ) )
+
+ describe('#bounds_at_index_with_dimensions()', function(){
+ it("generates proper bounds from left", function(){
+ var bounds = surface.bounds_at_index_with_dimensions(0, small)
+ assert.notEqual(false, bounds)
+ assert.equal(true, bounds.eq(new Rect(1,0, 4,4)))
})
- it("places a small element on the right", function(){
- var bounds = surface.place(small, new vec2(4,6))
-// console.log(bounds)
+ it("generates proper bounds from left door", function(){
+ var bounds = surface.bounds_at_index_with_dimensions(1, small)
+ assert.notEqual(false, bounds)
+ assert.equal(true, bounds.eq(new Rect(1,2, 14,4)))
+ })
+ it("generates proper bounds from middle", function(){
+ var bounds = surface.bounds_at_index_with_dimensions(2, small)
+ assert.notEqual(false, bounds)
+ assert.equal(true, bounds.eq(new Rect(5,0, 8,6)))
+ })
+ it("generates proper bounds from right door", function(){
+ var bounds = surface.bounds_at_index_with_dimensions(3, small)
+ assert.notEqual(false, bounds)
+ assert.equal(true, bounds.eq(new Rect(1,2, 14,4)))
+ })
+ it("generates proper bounds from right", function(){
+ var bounds = surface.bounds_at_index_with_dimensions(4, small)
+ assert.notEqual(false, bounds)
+ assert.equal(true, bounds.eq(new Rect(10,0, 14,4)))
+ })
+
+ it("generates proper bounds for wide from left", function(){
+ var bounds = surface.bounds_at_index_with_dimensions(0, wide)
+ assert.notEqual(false, bounds)
+ assert.equal(true, bounds.eq(new Rect(1,2, 14,4)))
+ })
+ it("generates proper bounds for wide from middle", function(){
+ var bounds = surface.bounds_at_index_with_dimensions(1, wide)
+ assert.notEqual(false, bounds)
+ assert.equal(true, bounds.eq(new Rect(1,2, 14,4)))
+ })
+ it("generates proper bounds for wide from right", function(){
+ var bounds = surface.bounds_at_index_with_dimensions(4, wide)
+ assert.notEqual(false, bounds)
+ assert.equal(true, bounds.eq(new Rect(1,2, 14,4)))
})
- })
- describe('#clamp()', function(){
- it("", function(){
+ it("places tall in middle", function(){
+ var bounds = surface.bounds_at_index_with_dimensions(0, tall)
+ assert.notEqual(false, bounds)
+ assert.equal(true, bounds.eq(new Rect(5,0, 8,6)))
+
+ var bounds = surface.bounds_at_index_with_dimensions(1, tall)
+ assert.equal(true, bounds.eq(new Rect(5,0, 8,6)))
+
+ var bounds = surface.bounds_at_index_with_dimensions(2, tall)
+ assert.equal(true, bounds.eq(new Rect(5,0, 8,6)))
+
+ var bounds = surface.bounds_at_index_with_dimensions(3, tall)
+ assert.equal(true, bounds.eq(new Rect(5,0, 8,6)))
+
+ var bounds = surface.bounds_at_index_with_dimensions(4, tall)
+ assert.equal(true, bounds.eq(new Rect(5,0, 8,6)))
+ })
+ it("returns false for large image", function(){
+ assert.equal(false, surface.bounds_at_index_with_dimensions(0, large))
+ assert.equal(false, surface.bounds_at_index_with_dimensions(1, large))
+ assert.equal(false, surface.bounds_at_index_with_dimensions(2, large))
+ assert.equal(false, surface.bounds_at_index_with_dimensions(3, large))
+ assert.equal(false, surface.bounds_at_index_with_dimensions(4, large))
})
})