[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[pygame] unround circle!



Here is a bug from long ago, forgot to report it then (still present
on fresh 1.5.6): `pygame.draw.circle` doesn't create a round circle,
it's more tall than wide.  `pygame.draw.ellipse` with a square rect
behaves the same (it can be sort of corrected by a rect wider by 2
pixel than a square).  Here is the demonstartion code:

import pygame
from pygame.locals import *

pygame.init()
screen = pygame.display.set_mode((640, 480))

try:
    s = pygame.Surface((32, 24))
    size = 0
    def redraw():
        s.fill([255]*3)
        pygame.draw.circle(s, [0]*3, (16, 12), size)
        screen.blit(pygame.transform.scale(s, screen.get_size()),
                    (0, 0))
        pygame.display.update()
    redraw()
    for ev in iter(pygame.event.wait, None):
        if ev.type == QUIT:
            break
        elif ev.type == KEYDOWN and ev.unicode == '+':
            size += 1
        elif ev.type == KEYDOWN and ev.unicode == '-':
            if size > 0:
                size -= 1
        else:
            continue
        redraw()
finally:
    pygame.quit()


-- 
Beni Cherniavsky <cben@users.sf.net>

Premature classification is the superclass of all evil.