Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def gradientRect(window, left_colour, right_colour, target_rect):
- """ Draw a horizontal-gradient filled rectangle covering <target_rect> """
- colour_rect = pg.Surface((2, 2)) # tiny! 2x2 bitmap
- pg.draw.line(colour_rect, left_colour, (0, 0), (0, 1)) # left colour line
- pg.draw.line(colour_rect, right_colour, (1, 0), (1, 1)) # right colour line
- colour_rect = pg.transform.smoothscale(colour_rect, (target_rect.width, target_rect.height)) # stretch!
- window.blit(colour_rect, target_rect) # paint it
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement