On this page
How to use it#
- Pick a colour with the colour box, drag the hue, saturation and lightness sliders, or type into any value field:
#ff8800,255, 136, 0or32, 100%, 50%. - Copy any format with its copy button. The Pygame field gives a tuple you can paste straight into
screen.fill((255, 136, 0)). - Click a shade to use a lighter or darker version of the same hue, which is useful for highlights and shadows.
- Save colour adds it to your palette (kept in this browser). Copy palette as Python produces a list ready to paste into your game.
Colours in Pygame#
Pygame accepts colours in several forms, and they are interchangeable:
screen.fill((255, 136, 0)) # RGB tuple, each value 0-255
screen.fill((255, 136, 0, 128)) # RGBA; alpha only matters on SRCALPHA surfaces
screen.fill("darkorange") # a named colour
screen.fill(pygame.Color("#ff8800")) # a Color object from hexpygame.Color also lets you read and change components: c = pygame.Color("#ff8800"); c.hsla gives hue, saturation, lightness and alpha, and c.lerp(other, 0.5) blends two colours.
Contrast#
The contrast figures compare the colour against white and black text using the WCAG formula. A ratio of at least 4.5:1 keeps text readable for most players, which matters for scores, menus and subtitles.
Building a game palette#
Games look more coherent with a small, fixed palette. Start with a dark colour for outlines and text, a light background, and two or three accents, then add a lighter and darker shade of each. Export the list and use names in your code:
PALETTE = [(21, 35, 63), (36, 87, 166), (244, 197, 49)]
INK, BLUE, GOLD = PALETTE