Skip to content

Commit

Permalink
fixed a typo, adding the placement to the top_right and bottom_left p…
Browse files Browse the repository at this point in the history
…lacement functions
  • Loading branch information
jmoiron committed Apr 12, 2010
1 parent 793b6ed commit d0a94e7
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions pyxie/packer.py
Expand Up @@ -72,6 +72,10 @@ def bottom_left(self, placed, new, place=False):
"""Attempt to place a new rectangle on the bottom left corner of a
previously placed rectangle. Return the amt that the overall area of
the field would increase, or None if a collision is detected."""
if place:
self.rectangles.append(PositionedRectangle(placed.x, placed.y + placed.rect.y, new))
self.x, self.y = self.calculate_area()
return
if placed.bl:
return None
# the corner we're adding it to is here:
Expand All @@ -81,9 +85,13 @@ def bottom_left(self, placed, new, place=False):


def top_right(self, placed, new, place=False):
if place:
self.rectangles.append(PositionedRectangle(placed.x + placed.rect.x, placed.y, new))
self.x, self.y = self.calculate_area()
return
if placed.tr:
return None
corner = (placed.x + placed.rect.x, placed,y)
corner = (placed.x + placed.rect.x, placed.y)
if not self.collision(corner, new):
return self.new_area(corner, new)

Expand All @@ -92,7 +100,9 @@ def new_area(self, corner, new):
with its top left corner at `corner`."""
pass

def calculate_area(self, rectangles=None):
def calculate_bounds(self, rectangles=None):
"""Calculate x/y bounds for a field with the given rectangles. If
rectangles is None, calculate it for self's rectangles."""
if rectangles is None:
rectangles = self.rectangles
return None
Expand Down

0 comments on commit d0a94e7

Please sign in to comment.