Skip to content

Transparency with pygame.draw #2713

Open
@oddbookworm

Description

@oddbookworm

pygame.draw doesn't apply transparency, but the docs imply it should

reproducer

import pygame

screen = pygame.display.set_mode((500, 500))

OPAQUE = (255, 0, 0, 255)
TRANSLUCENT = (255, 0, 0, 128)
TRANSPARENT = (255, 0, 0, 0)

opaque_rect = pygame.Rect(0, 0, 100, 100)
translucent_rect = pygame.Rect(100, 0, 100, 100)
transparent_rect = pygame.Rect(200, 0, 100, 100)


running = True
while running:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False

    screen.fill("black")
    pygame.draw.rect(screen, OPAQUE, opaque_rect)
    pygame.draw.rect(screen, TRANSLUCENT, translucent_rect)
    pygame.draw.rect(screen, TRANSPARENT, transparent_rect)
    pygame.display.flip()

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    drawpygame.draw

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions