Pygame extension for advanced surface manipulation.
import pygame
import pgext
# pygame init and set up window with dimensions 800x600
pygame.display.init()
screen = pygame.display.set_mode((800, 600))
# create gradient
gradient = pgext.filters.gradient(
(800, 600), # size
(0, 0, 200), # start color
(200, 0, 0), # end color
0, # horizontal
1.0 # ratio (1.0 = linear)
)
# blit gradient to screen
screen.blit(gradient, (0, 0))
# "game" loop
cnt = 100
while cnt:
pygame.display.flip()
pygame.time.wait(50)
cnt -= 1
For more information take a look on
gradient filter.