def _collideDraw(self): "Draw collision shape (circle or polygon)" img = Image(pygame.display.get_surface()) s = self.shape if type(s) is Circle2D: circ = Image.ellipse(s.radius, fill=self._collideRegion[1], stroke=None) circ.blitTo(img, tuple(s.center), CENTER) else: img.plot(s.points, fill=self._collideRegion[1], stroke=None, closed=True)
def makeImages(self, style=0, mark=None): sz = fontHeight(self) if style: r = sz // 2 img0 = Image.ellipse(r, fill=self.bgColor, stroke=self.color, strokeWeight=self.border) else: img0 = Image.rect((sz,sz), fill=self.bgColor, stroke=self.color, strokeWeight=self.border) img1 = img0.clone() if mark: if mark[0]: mark[0].blitTo(img0) if mark[1]: mark[1].blitTo(img1) elif style: pygame.draw.circle(img1.surface, self.color, (r,r), r//2) else: sz -= 2 pygame.draw.line(img1.surface, self.color, (1,1), (sz,sz)) pygame.draw.line(img1.surface, self.color, (1,sz), (sz,1)) return img0, img1
def leds(self): "Draw luminous LED indicators" fc = self.frontColor colors = [self.downColor, fc if fc else (0, 0, 0), self.penColor] r1 = self.width / 5 r2 = r1 / 2.5 a = (self.angle + 60) * DEG x0, y0 = self.posn led = [] for c in colors: x = x0 + r1 * cos(a) y = y0 + r1 * sin(a) if c is not None: img = Image.ellipse(r2, c, (0, 0, 0)) xy = rectAnchor((x, y), img.size, CENTER).topleft led.append((img, xy)) a -= pi / 1.5 if c: self._penPosn = True if self.centerPen else (round(x), round(y)) return led