[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?
- To: pygame-users@xxxxxxxx
- Subject: Re: [pygame] Is there some type of hex codes to rgb converter or something?
- From: Luke Paireepinart <rabidpoobear@xxxxxxxxx>
- Date: Mon, 10 Sep 2007 18:56:49 -0500
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: pygame-users-outgoing@xxxxxxxx
- Delivered-to: pygame-users@xxxxxxxx
- Delivery-date: Mon, 10 Sep 2007 19:57:03 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:user-agent:mime-version:to:subject:references:in-reply-to:content-type:content-transfer-encoding; bh=JAQjx10xYZqaJ+FOCABoWgEULkdLZVBb2b4kyO/8eyM=; b=bjukogc9xFGTr31l8Cyqio4EpH7GJZKIklP6V7IQDzPFlzEHkh7dEl14Q46Y5OFOYOW8VFrcaKXFIp1OnKNJ4BcllAxp+iq8D9b011fT5hObnIAG2JLNwrgn+TkzadY8uuITcsEHEmodOUIvoDHyn5wWyJC+m8So1Ohp17UYIC4=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:user-agent:mime-version:to:subject:references:in-reply-to:content-type:content-transfer-encoding; b=plxCbJSrcqAvZlo8GMPvc7cR8cFgiUEAfHPkKsGyFegIsmXswHEj6V/uLnCSIeWbspfnn5oQ46ju5cpD19PHKy+TNHuClMAbvRr+IcvNS6PUXYutDJltjqqq+9eYJaPbXW2X2RyruXpeN2v2DU5jjeLPZaUE+hpRMuhF9kChaZo=
- In-reply-to: <eb79828c0709101608j5b6d9830ja980eefb0f3cb934@xxxxxxxxxxxxxx>
- References: <eb79828c0709101608j5b6d9830ja980eefb0f3cb934@xxxxxxxxxxxxxx>
- Reply-to: pygame-users@xxxxxxxx
- Sender: owner-pygame-users@xxxxxxxx
- User-agent: Thunderbird 2.0.0.6 (Windows/20070728)
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
HTML hex colors are defined as such:
color = "#DEFFC3"
I.E. a pound sign, then 2 hex digits for red, 2 for green, and 2 for blue.
This is very easy to convert between.
First let's get rid of the # sign
color = color[1:]
Next let's separate these into 3 different strings.
red = color[0:2]
green = color[2:4]
blue = color[4:6]
Next let's convert these all to integers
red = int(red, 16)
green = int(green, 16)
blue = int(blue, 16)
I'll leave it as an exercise for the reader to simplify this (I.E. I
have food on the stove and I have to go take it off.)
HTH,
-Luke