[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] Inverting colors
- To: pygame-users@xxxxxxxx
- Subject: Re: [pygame] Inverting colors
- From: Nicholas Dudfield <ndudfield@xxxxxxxxx>
- Date: Thu, 18 Sep 2008 00:26:56 +1000
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: pygame-users-outgoing@xxxxxxxx
- Delivered-to: pygame-users@xxxxxxxx
- Delivery-date: Wed, 17 Sep 2008 10:27:14 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; 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=ZfFNb4fMspwaQI92IpUYkzAQdHLWQi+D7JrKIX/w1YE=; b=RPN5btXZx+0PwRJ7FpXgHrsaoNTa3Nu8/pejlHMqFwM8Fpa3MeuczArKKl9RhMZoso nBzPvE9JTgYSpnxqWKvdo+Fdp4X/OSwk7R2nwj+ybL1SHuqKqba/Vj6or9IQsROxb0J6 +BH9DWgQBP3acWUSaLr+qn+J+E/LqXn6CwS0g=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; b=GuIxijo3RqVGYZ6Yi+idg5viUVuw5FbYbLxDUQZ2MQ6JQAfdCeikgx36xzBDYk01m+ PA99c5bbsFUDZPXUmfMSMKd8m/aLuavhPjm5w8kanlSWDrz4XFL1UwHILmzfDNsp9EoF n8NTnmY3GBegMHGSO9gUK0Ic3UQPRuQETbCik=
- In-reply-to: <a0efdb8a0809170640p1f4f7386p3fcf2a42a3ed9530@xxxxxxxxxxxxxx>
- References: <a0efdb8a0809170640p1f4f7386p3fcf2a42a3ed9530@xxxxxxxxxxxxxx>
- Reply-to: pygame-users@xxxxxxxx
- Sender: owner-pygame-users@xxxxxxxx
- User-agent: Thunderbird 2.0.0.16 (Windows/20080708)
The new Color class may have invert but I don't recall.
Well the rgb inverted algorithm is essentially 255 - color
new_red = 255 - old_red
new_green = 255 - old_green
new_blue = 255 - old_blue
So a subtractive blend mode blit may do the trick:
BLEND_RGBA_SUB
BLEND_RGB_SUB
inverted.fill((255,255,255))
inverted.blit(letters, (0,0), None, BLEND_RGB_SUB)
This might work, haven't tested it though...
I'm working on a game, and I made a bitmap font for it. This was quite
silly of me; I made each letter a 16x16 image. Well, now I need the
letters to invert colors. I was wondering if there's a way to do this
in pygame, or if I have to go through all those images (around 40) and
make a shapestrip or something?
Thanks,
--
- pymike (http://pymike.4rensics.org/)