0

Here is my code

import pygame

BLUE = (0 , 0 , 255, 1)
screen=pygame.display.set_mode((500,500))
clock = pygame.time.Clock()

surface = pygame.Surface((500,500), pygame.SRCALPHA)
def draw_circle_alpha(surface, color, center, radius):
    target_rect = pygame.Rect(center, (0, 0)).inflate((radius * 2, radius * 2))
    shape_surf = pygame.Surface(target_rect.size, pygame.SRCALPHA)
    pygame.draw.circle(shape_surf, color, (radius, radius), radius)
    surface.blit(shape_surf, target_rect)

isPressed = False
while True:
    clock.tick(60)
    for event in pygame.event.get():
        if event.type == pygame.MOUSEBUTTONDOWN:
            isPressed = True
        elif event.type == pygame.MOUSEBUTTONUP:
            isPressed = False
        elif event.type == pygame.MOUSEMOTION and isPressed == True:         
            x, y  = pygame.mouse.get_pos()       # returns the position of mouse cursor
            draw_circle_alpha(surface, BLUE, (x, y), 15)
    pygame.display.flip()
    screen.blit(surface, (0,0))

It kinda works and produces this cool effect: see here

But I want my line to stay transparent. How can I do that?

0 Answers0