[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Is there some type of hex codes to rgb converter or something?



Lamonte Harris wrote:
I like using HTML hex, is there a library or something on pygame or python it self to convert hex to rgb

Pygame comes with a color module. Just noticed it wasn't in the docs though.


import pygame.color

red = pygame.color.Color("#ff0000")
blue = pygame.color.Color("cornflowerblue")

It also includes some simple math, so you can mix colors yourself.

purple = pygame.color.add(red, blue)