[pygame] Inverting colors

2008-09-17 Thread pymike
Hi,

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/)


Re: [pygame] Inverting colors

2008-09-17 Thread Nicholas Dudfield

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/)





Re: [pygame] pygame.org - update finished!

2008-09-17 Thread Ian Mallett
http://www.pygame.org/docs/
doesn't have links to the modules Color and Scrap and the alphabetical order
is incorrect in some places.

Ian


Re: [pygame] Inverting colors

2008-09-17 Thread pymike
Thanks :-) I actually already converted my font to a shapestrip, and I got
it working fine now :-)
http://pymike.4rensics.org/files/Screenshot-PixelWars-1.png

However pygame SHOULD have a function to invert colors on images. like
image.invert()

Cheers

On Wed, Sep 17, 2008 at 9:26 AM, Nicholas Dudfield [EMAIL PROTECTED]wrote:

 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/)





-- 
- pymike (http://pymike.4rensics.org/)


Re: [pygame] Inverting colors

2008-09-17 Thread Nicholas Dudfield

1.9?  Until then

def inverted(img):
   inv = pygame.Surface(img.get_rect().size, pygame.SRCALPHA)
   inv.fill((255,255,255,255))
   inv.blit(img, (0,0), None, BLEND_RGB_SUB)
   return inv

pymike wrote:
Thanks :-) I actually already converted my font to a shapestrip, and I 
got it working fine now :-) 
http://pymike.4rensics.org/files/Screenshot-PixelWars-1.png


However pygame SHOULD have a function to invert colors on images. like 
image.invert()


Cheers



Re: [pygame] Inverting colors

2008-09-17 Thread pymike
 ok thx :-)

On Wed, Sep 17, 2008 at 10:15 AM, Nicholas Dudfield [EMAIL PROTECTED]wrote:

 1.9?  Until then

 def inverted(img):
   inv = pygame.Surface(img.get_rect().size, pygame.SRCALPHA)
   inv.fill((255,255,255,255))
   inv.blit(img, (0,0), None, BLEND_RGB_SUB)
   return inv


 pymike wrote:

 Thanks :-) I actually already converted my font to a shapestrip, and I got
 it working fine now :-)
 http://pymike.4rensics.org/files/Screenshot-PixelWars-1.png

 However pygame SHOULD have a function to invert colors on images. like
 image.invert()

 Cheers




-- 
- pymike (http://pymike.4rensics.org/)


Re: [pygame] Good code for text wrapping?

2008-09-17 Thread Charlie Nolan
Hmm, I've written this too.  Given that it seems pretty common,
wouldn't this be a good candidate for adding to pygame.font.Font?

-FM

On 9/16/08, Marius Gedminas [EMAIL PROTECTED] wrote:
 On Tue, Sep 16, 2008 at 12:11:45PM +1000, René Dudfield wrote:
 The cookbook has this entry, but it doesn't work with new lines.
 http://www.pygame.org/wiki/TextWrapping

 Anyone have any code like this that supports new lines?

 http://mg.pov.lt/pyspacewar/trac/browser/trunk/src/pyspacewar/ui.py#L466

 Output example: http://mg.pov.lt/pyspacewar/pyspacewar-help-screen.png

 It's GPL-ed, feel free to use or ask me for a licence change if that's
 not suitable.

 Marius Gedminas
 --
 If you are smart enough to know that you're not smart enough to be an
 Engineer, then you're in Business.



Re: [pygame] Good code for text wrapping?

2008-09-17 Thread Ian Mallett
I'd appreciate it.


Re: [pygame] Good code for text wrapping?

2008-09-17 Thread pymike
Yeah pygame.font needs support for \n. :P

On Wed, Sep 17, 2008 at 2:31 PM, Charlie Nolan [EMAIL PROTECTED]wrote:

 Hmm, I've written this too.  Given that it seems pretty common,
 wouldn't this be a good candidate for adding to pygame.font.Font?

 -FM

 On 9/16/08, Marius Gedminas [EMAIL PROTECTED] wrote:
  On Tue, Sep 16, 2008 at 12:11:45PM +1000, René Dudfield wrote:
  The cookbook has this entry, but it doesn't work with new lines.
  http://www.pygame.org/wiki/TextWrapping
 
  Anyone have any code like this that supports new lines?
 
  http://mg.pov.lt/pyspacewar/trac/browser/trunk/src/pyspacewar/ui.py#L466
 
  Output example: http://mg.pov.lt/pyspacewar/pyspacewar-help-screen.png
 
  It's GPL-ed, feel free to use or ask me for a licence change if that's
  not suitable.
 
  Marius Gedminas
  --
  If you are smart enough to know that you're not smart enough to be an
  Engineer, then you're in Business.
 




-- 
- pymike (http://pymike.4rensics.org/)