Request for those using masks.

5 replies [Last post]
nemo
nemo's picture
User offline. Last seen 18 hours 28 min ago. Offline
Joined: 2009-01-28
Posts: 1529

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:
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 in GIMP, set background colour to black, export to PNG and uncheck "Save color values from transparent pixels" in the PNG options.

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.

--
Oh, what the heck. 1PLXzL1CBUD1kdEWqMrwNUfGrGiirV1WpH <= tip a hedgewars dev

Mystery_2nd Account
User offline. Last seen 4 years 18 weeks ago. Offline
Joined: 2012-04-10
Posts: 60

How is about Inkscape?

nemo
nemo's picture
User offline. Last seen 18 hours 28 min ago. Offline
Joined: 2009-01-28
Posts: 1529

Mystery_2nd Account allegedly 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.

--
Oh, what the heck. 1PLXzL1CBUD1kdEWqMrwNUfGrGiirV1WpH <= tip a hedgewars dev

sphrix
sphrix's picture
User offline. Last seen 2 hours 19 min ago. Offline
Joined: 2011-04-07
Posts: 195

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

nemo
nemo's picture
User offline. Last seen 18 hours 28 min ago. Offline
Joined: 2009-01-28
Posts: 1529

Sphrix, WRT svg, that's for stuff that's being committed to the repository.
For later editing/improvements.

For DLC, not a big deal. Unless you want to make it easy for others to do the same.

--
Oh, what the heck. 1PLXzL1CBUD1kdEWqMrwNUfGrGiirV1WpH <= tip a hedgewars dev

Wuzzy
Wuzzy's picture
User offline. Last seen 5 hours 12 min ago. Offline
Joined: 2012-06-20
Posts: 879

Thanks, nemo, for this guide. I have converted mask.png of my farm map with your guide and ideed I found some “faulty” pixels in it. I will soon upload a new version of farm. Oh, and I will finally apply the proper version numbering scheme.

Is this guide on the wiki yet? If not, someone please paste it into the wiki, because it is hard to find this guide deep down in the forums, especially when it is not a sticky thread.

Copyright © 2004-2017 Hedgewars Project. All rights reserved. [ contact ]