This shouldn’t be hard. But it is.
If you want to have a filled circle / ring in pygame you need to draw the antialiased part yourself. This is a terribly complicated way to get antialiased circles.
Unfortunately, pygame does not implement an antialiased filled circle, so you basically have to create them yourself. Also, the antialiased circles that pygame does implement seem to only antialiase to white, so they cause further problems by encroaching on the colored parts of the image.
def DrawTarget(self): # outside antialiased circle pygame.gfxdraw.aacircle(self.image, self.rect.width/2, self.rect.height/2, self.rect.width/2 - 1, self.color) # outside filled circle pygame.gfxdraw.filled_ellipse(self.image, self.rect.width/2, self.rect.height/2, self.rect.width/2 - 1, self.rect.width/2 - 1, self.color) temp = pygame.Surface((TARGET_SIZE,TARGET_SIZE), SRCALPHA) # the SRCALPHA flag denotes pixel-level alpha if (self.filled == False): # inside background color circle pygame.gfxdraw.filled_ellipse(temp, self.rect.width/2, self.rect.height/2, self.rect.width/2 - self.width, self.rect.width/2 - self.width, BG_ALPHA_COLOR) # inside antialiased circle pygame.gfxdraw.aacircle(temp, self.rect.width/2, self.rect.height/2, self.rect.width/2 - self.width, BG_ALPHA_COLOR) self.image.blit(temp, (0,0), None, BLEND_ADD)
02/28/11