Request for those using masks.

3 replies [Last post]
nemo
User offline. Last seen 1 hour 1 min ago. Offline
Joined: 01/28/2009
Posts: 1019

http://code.google.com/p/hedgewars/wiki/PresetMaps#mask.png

If you want the mask to work correctly, please try to avoid antialiasing it.
A 50% opacity red pixel is not indestructible.

If you are working in GIMP, I would suggest disabling AA in selection, and before saving, use either:
Colors->Posterise
or
Image->Indexed (enter a number of colours that matches the non-transparent colours your mask uses) then Image->RGB again (since all game PNGs must be RGBA).

You can fix partially translucent existing pixels by reselecting (non-AA select) then flood fill, by indexing the image, or by semi-flattening the layer then fixing the now-white pixels with posterise, erasure or indexing.

Once you've saved it, you can verify the colours using a histogram tool.
For example:
$ identify -verbose share/hedgewars/Data/Maps/Lonely_Island/mask.png | grep -A3 Histogram
Histogram:
1710969: ( 0, 0, 0, 0) #00000000 none
139664: ( 0, 0, 0,255) #000000 black
246519: (255,255,255,255) #FFFFFF white

Here, you can see that all the pixels are either black, white or transparent.

If you have some that don't match one of the rules, that pixel will be ignored in the mask, and will just inherit the default value from map.png.

As well as avoiding unexpected behaviour, a PNG with fewer colours compresses slightly better.

Another thing that can help PNGs compress better is the choice of transparent colour.
If you want transparent black (or transparent white) in GIMP, just make a new layer that is black or white, then ctrl-a, ctrl-x erase it, position it below your main mask layer and merge down.
This can save quite a bit of space. For example, I just tidied up the TrophyRace mask.
Before, it was using this transparent "colour"
Histogram:
3212815: (217,215,196, 0) #D9D7C400 rgba(217,215,196,0)
4399210: (255, 0, 0,255) #FF0000 red
5827: (255, 0, 0,254) #FF0000FE rgba(255,0,0,0.996078)
(also notice 5827 non-solid red pixels, that would be ignored)
Now...
Histogram:
3869995: ( 0, 0, 0, 0) #00000000 none
4420309: (255, 0, 0,255) #FF0000 red
Reduction in size?
PNG went from 233,882 down to 45,252.

Mystery_2nd Account
User offline. Last seen 4 days 17 hours ago. Offline
Joined: 04/10/2012
Posts: 64

How is about Inkscape?

nemo
User offline. Last seen 1 hour 1 min ago. Offline
Joined: 01/28/2009
Posts: 1019

Mystery_2nd Account wrote:

How is about Inkscape?

Doing a mask in Inkscape doesn't seem that convenient. The reason to use Inkscape is to get nice smooth vector rendered art with antialiasing.

In order to do a mask for this, you'd have to clone your entire image and all objects, then map them to the solid colour. Doable, but why?
You'd just have to update it if you added new objects anyway. Changes could be hooked up to be mirrored, but that's pretty convoluted.
Plus, once you were done, you'd still want to open in a pixel based editor (like GIMP) to ensure that the mask was flattened to a few colours as in the request above.

Overall, I'd suggest generating the map in Inkscape (for attractiveness and flexibility) then create any mask layer you feel the map needs, in GIMP.

Oh, and of course, share your SVG Smile Open source game after all. If you submit a map to the game, including any XCF or SVG is definitely appreciated.

sphrix
sphrix's picture
User is online Online
Joined: 04/07/2011
Posts: 150

Quote:
Oh, and of course, share your SVG Open source game after all. If you submit a map to the game, including any XCF or SVG is definitely appreciated.

if we could add the svg in the map.zip we send to unit22 why not... but what's the real utility for this ?

anyway, when i'll do a mask i'll try to respect your request Smile

the beachs hogs surfin hedgewars

Copyright © 2004-2013 Hedgewars Project. All rights reserved.