+ self.coords = coords
+
+
+ innerWidth, innerHeight = [l-self.BORDER*2 for l in self.rect.size]
+
+ imagePath = InstrumentTile._get_instrument_image(name)
+ img = pygame.image.load(imagePath)
+ iWidth, iHeight = img.get_size()
+ imgRatio = float(iWidth) / iHeight
+
+ # adapts dimensions
+ iw = innerWidth
+ ih = int(round(innerWidth / imgRatio))
+
+ if ih > innerHeight:
+ ih = innerHeight
+ iw = int(round(innerHeight * imgRatio))
+
+ position = ((innerWidth - iw) / 2 + self.BORDER, (innerHeight - ih) / 2 + self.BORDER)
+
+ img = pygame.transform.smoothscale(img, (iw, ih))
+
+ bg = pygame.Surface(self.rect.size)
+ bg.fill((255,255,255,255))
+ bg.blit(img, pygame.Rect(position, (iw, ih)))
+
+ self.image = bg
+
+ def inflate(self, refPoint) :
+ keep = {}
+ for name in REF_POINTS[refPoint] :
+ keep[name] = getattr(self.rect, name)
+
+ self.rect.inflate_ip(*[l*self.INFLATE_ZOOM for l in self.rect.size])
+
+ img = pygame.transform.smoothscale(self.image, self.rect.size)
+ self.image = img
+
+ for k, v in keep.items() :
+ setattr(self.rect, k, v)
+
+ self.dirty = 1
+
+
+
+REF_POINTS = {
+ (0, 0) : ['top', 'left'],
+ (1, 0) : ['top'],
+ (2, 0) : ['top', 'right'],
+
+ (0, 1) : ['left'],
+ (1, 1) : [],
+ (2, 1) : ['right'],
+
+ (0, 2) : ['bottom', 'left'],
+ (1, 2) : ['bottom'],
+ (2, 2) : ['bottom', 'right']
+}
\ No newline at end of file