[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[pygame] `pygame.draw.(aa)?lines?(...)` with Alpha
- To: "pygame-users@xxxxxxxx" <pygame-users@xxxxxxxx>
- Subject: [pygame] `pygame.draw.(aa)?lines?(...)` with Alpha
- From: Ian Mallett <ian@xxxxxxxxxxxxxx>
- Date: Sun, 16 Aug 2015 12:22:09 -0700
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: pygame-users-outgoing@xxxxxxxx
- Delivered-to: pygame-users@xxxxxxxx
- Delivery-date: Sun, 16 Aug 2015 15:22:28 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:from:date:message-id:subject:to:content-type; bh=7epbg8CeCjq/emL1Ciq66IrDlmftD/XKtpIWYIzzq3w=; b=DfVYvWQnM0V1B5dBPA+KtPV78UnUBDz629nrmYYyyHzx9FTSpAQSyywzxPUJTSl4+X 8lKCDLBPu260PGhEOsJqm/1sLivCYGCbx33CwheAUnZlmPwZ82ZOg+zDO8qfSfVbq1CP AaNu+aarF0FzQcfYpJNhAMlaW6fkdv07HpXOWc+RFlQfU1T3ceZoZDZO+/v0ScKqxABE YkIpRhipDry8u7q3V8U/KL+WnSS7mHbBQ7O9gvG+cU/tTeMFhiF0MfW+I9Z4PvcbB5cU aCGMHhIomTZaoy7PCdH8HqruZLd4MDpMT2GjF25P+2jYEEL902mGqkgxZGK0ymjJb6iS hLsg==
- Reply-to: pygame-users@xxxxxxxx
- Sender: owner-pygame-users@xxxxxxxx
Hi all,
I recently got a problem that traces back to the drawing functions "line", "aaline", "lines", and "aalines" ignoring any alpha value they are fed.
This seems to me to be a Bad Thing. The obvious workaround is to draw to a temporary surface, and then blit the surface with transparency, but this is extremely wasteful, as it squares the asymptotic complexity. Really, I think this should instead be handled by PyGame in the underlying rasterizer.
Attached is a simple example.
Ian
import pygame
surface = pygame.display.set_mode((128,128))
pygame.draw. line(surface, (255,0,0,128), (0, 0),(128,128))
pygame.draw.aaline(surface, (0,255,0,128), (0,64),(128, 64))
running = True
while running:
for event in pygame.event.get():
if event.type==pygame.QUIT or (event.type==pygame.KEYDOWN and event.key==pygame.K_ESCAPE):
running = False
pygame.display.flip()