for_each_intersecting gives a rect
This commit is contained in:
@@ -44,7 +44,7 @@ impl<T> Layer<T> where T: Clone {
|
||||
Rect::new(x1, y1, x2 - x1, y2 - y1)
|
||||
}
|
||||
|
||||
pub fn for_each_intersecting<F>(&self, rect: &Rect, mut f: F) where F: FnMut(&T, i32, i32) {
|
||||
pub fn for_each_intersecting<F>(&self, rect: &Rect, mut f: F) where F: FnMut(&T, &Rect) {
|
||||
let intersect = self.get_intersecting(rect);
|
||||
|
||||
if intersect.x < 0 || intersect.x + intersect.w > self.width {
|
||||
@@ -56,7 +56,9 @@ impl<T> Layer<T> where T: Clone {
|
||||
|
||||
for y in range(intersect.y, intersect.y + intersect.h + 1) {
|
||||
for x in range(intersect.x, intersect.x + intersect.w + 1) {
|
||||
f(self.get_tile(x, y), x * self.tile_width, y * self.tile_height);
|
||||
let position = Rect::new(x * self.tile_width, y * self.tile_height, self.tile_width, self.tile_height);
|
||||
|
||||
f(self.get_tile(x, y), &position);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user