Complete.Org: Mailing Lists: Archives: freeciv-dev: October 2004:
[Freeciv-Dev] (PR#10779) render shields flags from SVG
Home

[Freeciv-Dev] (PR#10779) render shields flags from SVG

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#10779) render shields flags from SVG
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 29 Oct 2004 00:47:14 -0700
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=10779 >

This patch sets things up to automatically render the shields flags from 
the SVG files.  This fixes the bug in current CVS where some shield 
graphics aren't present.

The algorithm is simple.  There are several shield mask PNG files (these 
could be stored in SVG also, but since we want the 1-pixel outline for 
the shield it might be best for them to be edited by hand...on the other 
hand we could probably use anti-aliasing here to get good effect).

The mask files are 13x13; this is the resolution the shield will take 
(this is configurable in the script).  First the SVG is rendered at a 
flat 11x11 resolution (changing the aspect ratio).  Then this SVG is 
drawn over an arbitrary mask file to give it a +1,+1 offset from the 
origin.  Then the mask is drawn back on top of the image.  Finally the 
"magenta" parts of the mask are turned transparent.

Attached is:

- A diff.  This changes the needed CVS non-binary files.
- A mask.png file.  This goes into data/flags.
- A shields.png file.  This is just an example.
- Note the current data/misc/shields.png can be removed.

The purpose of this change is mostly to allow shield graphics to be 
generated from the flags.  The new shields may be better than the 
current ones, but at this resolution it's hard to say.

The only real drawback is that "magenta" is a special case color that 
cannot be used in flags.  This probably won't present any problems in 
the near future, but eventually we should have a more advanced script 
that handles this correctly.  I chose "magenta" because that's what civ3 
uses.

jason

? data/flags/afghanistan-shield.png
? data/flags/arab-shield.png
? data/flags/argentina-shield.png
? data/flags/armenia-shield.png
? data/flags/assyria-shield.png
? data/flags/australia-shield.png
? data/flags/austria-shield.png
? data/flags/azerbaijan-shield.png
? data/flags/barbarian-shield.png
? data/flags/bavarian-shield.png
? data/flags/belgium-shield.png
? data/flags/boer-shield.png
? data/flags/bosnia-shield.png
? data/flags/brasil-shield.png
? data/flags/bulgaria-shield.png
? data/flags/canada-shield.png
? data/flags/catalan-shield.png
? data/flags/cheyenne-shield.png
? data/flags/chile-shield.png
? data/flags/china-shield.png
? data/flags/columbia-shield.png
? data/flags/cornwall-shield.png
? data/flags/croatia-shield.png
? data/flags/cuba-shield.png
? data/flags/czech-shield.png
? data/flags/denmark-shield.png
? data/flags/dunedain-shield.png
? data/flags/egypt-shield.png
? data/flags/elves-shield.png
? data/flags/england-shield.png
? data/flags/estonia-shield.png
? data/flags/ethiopia-shield.png
? data/flags/europe-shield.png
? data/flags/finland-shield.png
? data/flags/france-shield.png
? data/flags/galicia-shield.png
? data/flags/germany-shield.png
? data/flags/greece-shield.png
? data/flags/greenland-shield.png
? data/flags/hobbits-shield.png
? data/flags/hungary-shield.png
? data/flags/iceland-shield.png
? data/flags/india-shield.png
? data/flags/indonesia-shield.png
? data/flags/iran-shield.png
? data/flags/iraq_old-shield.png
? data/flags/ireland-shield.png
? data/flags/israel-shield.png
? data/flags/italy-shield.png
? data/flags/japan-shield.png
? data/flags/kampuchea-shield.png
? data/flags/kenya-shield.png
? data/flags/korea-shield.png
? data/flags/krev-shield.png
? data/flags/latvia-shield.png
? data/flags/lithuania-shield.png
? data/flags/macedonia-shield.png
? data/flags/malaysia-shield.png
? data/flags/mars-shield.png
? data/flags/mask.png
? data/flags/mexico-shield.png
? data/flags/mongolia-shield.png
? data/flags/mordor-shield.png
? data/flags/nato-shield.png
? data/flags/netherlands-shield.png
? data/flags/nigeria-shield.png
? data/flags/norway-shield.png
? data/flags/observer-shield.png
? data/flags/pakistan-shield.png
? data/flags/peru-shield.png
? data/flags/philippines-shield.png
? data/flags/phoenicia-shield.png
? data/flags/poland-shield.png
? data/flags/portugal-shield.png
? data/flags/quebec-shield.png
? data/flags/rome-shield.png
? data/flags/russia-shield.png
? data/flags/rwanda-shield.png
? data/flags/scotland-shield.png
? data/flags/serbia-shield.png
? data/flags/silesia-shield.png
? data/flags/singapore-shield.png
? data/flags/slovenia-shield.png
? data/flags/south_africa-shield.png
? data/flags/soviet-shield.png
? data/flags/spain-shield.png
? data/flags/stpatrick-shield.png
? data/flags/sumeria-shield.png
? data/flags/sweden-shield.png
? data/flags/swiss-shield.png
? data/flags/syria-shield.png
? data/flags/taiwan-shield.png
? data/flags/thailand-shield.png
? data/flags/tunisia-shield.png
? data/flags/turkey-shield.png
? data/flags/ukraine-shield.png
? data/flags/united_kingdom-shield.png
? data/flags/united_nations-shield.png
? data/flags/unknown-shield.png
? data/flags/usa-shield.png
? data/flags/vietnam-shield.png
? data/flags/wales-shield.png
Index: data/trident_shields.tilespec
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/trident_shields.tilespec,v
retrieving revision 1.15
diff -u -r1.15 trident_shields.tilespec
--- data/trident_shields.tilespec       19 Oct 2004 18:04:55 -0000      1.15
+++ data/trident_shields.tilespec       29 Oct 2004 07:23:04 -0000
@@ -20,7 +20,7 @@
 
 ; offset the flags by this amount when drawing units
 flag_offset_x = 0
-flag_offset_y = 0
+flag_offset_y = 2
 
 ; Do not blend hills and mountains together.
 is_mountainous = 0
Index: data/flags/convert_png
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/flags/convert_png,v
retrieving revision 1.1
diff -u -r1.1 convert_png
--- data/flags/convert_png      29 Oct 2004 01:53:46 -0000      1.1
+++ data/flags/convert_png      29 Oct 2004 07:23:04 -0000
@@ -10,6 +10,9 @@
 # automatically).
 TARGET_WIDTH=28
 
+SHIELD_WIDTH=13
+SHIELD_HEIGHT=13
+
 which $RENDERER >/dev/null \
   || (echo "You need $RENDERER to render the SVG files.")
 (which convert >/dev/null && which composite >/dev/null) \
@@ -47,4 +50,25 @@
         mv "$filebase-4-fs8.png" $file5)
 
   rm -f $file1 $file2 $file3 $file4 "$filebase-4-fs8.png"
+
+  file1="$filebase-1.png"
+  file2="$filebase-2.png"
+  file3="$filebase-3.png"
+  file4="$filebase-4.png"
+  file5="$filebase-shield.png"
+
+  WIDTH=$(($SHIELD_WIDTH-2))
+  HEIGHT=$(($SHIELD_HEIGHT-2))
+
+  $RENDERER -f $file0 -w $WIDTH -h $HEIGHT -e $file1 > /dev/null
+
+  composite -geometry 0x0+1+1 $file1 mask.png $file2
+  composite -geometry 0x0+0+0 mask.png $file2 $file3
+  convert -transparent magenta $file3 $file4
+
+  which pngquant >/dev/null \
+    && (pngquant 256 $file4; \
+        mv "$filebase-4-fs8.png" $file5)
+
+  rm -f $file1 $file2 $file3 $file4 "$filebase-4-fs8.png"
 done
Index: data/misc/shields.png
===================================================================
RCS file: data/misc/shields.png
diff -N data/misc/shields.png
Binary files /tmp/cvs5PNDhS and /dev/null differ
Index: data/misc/shields.spec
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/misc/shields.spec,v
retrieving revision 1.17
diff -u -r1.17 shields.spec
--- data/misc/shields.spec      4 Oct 2004 19:39:20 -0000       1.17
+++ data/misc/shields.spec      29 Oct 2004 07:23:05 -0000
@@ -1,3 +1,4 @@
+
 [spec]
 
 ; Format and options of this spec file:
@@ -6,103 +7,112 @@
 [info]
 
 artists = "
-    Falk Hueffner <falk.hueffner@xxxxxxxxxxxxxxxxxxxxxxxx>
-    Tomasz Wegrzanowski <maniek@xxxxxxxx> (Bulgaria...Boer, Silesia)
-    Paul Zastoupil <paulz@xxxxxxxx> (Dunedain, Mordor)
-    Jeff Mallatt <jjm@xxxxxxxxxxxx> (Bavarian, Rome, Cornwall)
+   See flags/credits
 "
-
-[file]
-gfx = "misc/shields"
-
-[grid_main]
-
-x_top_left = 0
-y_top_left = 0
-dx = 45
-dy = 45
-
-tiles = { "row", "column", "tag"
-  0,  0, "f.italy"
-  0,  1, "f.iraq_old"
-  0,  2, "f.germany"
-  0,  3, "f.egypt"
-  0,  4, "f.usa"
-  0,  5, "f.greece"
-  0,  6, "f.india"
-  0,  7, "f.russia"
-  0,  8, "f.rwanda"       ; for Zulu
-  0,  9, "f.france"
-  0, 10, "f.mexico"
-  0, 11, "f.china"
-  0, 12, "f.united_kingdom"
-  0, 13, "f.mongolia"
-  1,  0, "f.denmark"
-  1,  1, "f.australia"
-  1,  2, "f.brasil"
-  1,  3, "f.soviet"
-  1,  4, "f.japan"
-  1,  5, "f.spain"
-  1,  6, "f.finland"
-  1,  7, "f.hungary"
-  1,  8, "f.poland"
-  1,  9, "f.iran"
-  1, 10, "f.peru"
-  1, 11, "f.turkey"
-  1, 12, "f.tunisia"
-  1, 13, "f.arab"         ; Saudi Arabia
-  2,  0, "f.south_africa" ; Republic of South Africa, for Zulus
-  2,  1, "f.sweden"
-  2,  2, "f.netherlands", 
-        "f.holland"      ; backward compatibility
-  2,  3, "f.syria"
-  2,  4, "f.macedonia"
-  2,  5, "f.ukraine"
-  2,  6, "f.cheyenne"
-  2,  7, "f.norway"
-  2,  8, "f.portugal"
-  2,  9, "f.czech"
-  2, 10, "f.england"
-  2, 11, "f.scotland"
-  2, 12, "f.unknown"      ; useful for alternates
-  2, 13, "f.barbarian"
-  3,  0, "f.europe"
-  3,  1, "f.canada"
-  3,  2, "f.korea"
-  3,  3, "f.israel"
-  3,  4, "f.ireland"
-  3,  5, "f.belgium"
-  3,  6, "f.iceland"
-  3,  7, "f.pakistan"
-  3,  8, "f.greenland"
-  3,  9, "f.austria"
-  3, 10, "f.argentina"
-  3, 11, "f.united_nations"
-  3, 12, "f.nato"
-  3, 13, "f.vietnam"
-  4,  0, "f.thailand"
-  4,  1, "f.olympic"
-  4,  2, "f.krev"
-  4,  3, "f.wales"
-  4,  4, "f.lithuania"
-  4,  5, "f.kenya"
-  4,  6, "f.dunedain"
-  4,  7, "f.bulgaria"
-  4,  8, "f.armenia"
-  4,  9, "f.azerbaijan"
-  4, 10, "f.boer"         ; old south african
-  4, 11, "f.mordor"
-  4, 12, "f.bavarian"
-  4, 13, "f.rome"         ; Roman republic flag
-  5,  0, "f.cornwall"
-  5,  1, "f.philippines"
-  5,  2, "f.estonia"
-  5,  3, "f.latvia"
-  5,  4, "f.silesia"
-  5,  5, "f.singapore"
-  5,  6, "f.chile"
-  5,  7, "f.catalan"
-  5,  8, "f.croatia"
-  5,  9, "f.slovenia"
-  5, 10, "f.serbia"
-}
+[extra]
+sprites =
+       {       "tag", "file"
+               "f.afghanistan", "flags/afghanistan-shield"
+               "f.arab", "flags/arab-shield"           ; Saudi Arabia
+               "f.argentina", "flags/argentina-shield"
+               "f.armenia", "flags/armenia-shield"
+               "f.assyria", "flags/assyria-shield"
+               "f.australia", "flags/australia-shield"
+               "f.austria", "flags/austria-shield"
+               "f.azerbaijan", "flags/azerbaijan-shield"
+               "f.barbarian", "flags/barbarian-shield"
+               "f.bavarian", "flags/bavarian-shield"
+               "f.belgium", "flags/belgium-shield"
+               "f.boer", "flags/boer-shield"           ; old south african
+               "f.bosnia", "flags/bosnia-shield"
+               "f.brasil", "flags/brasil-shield"
+               "f.bulgaria", "flags/bulgaria-shield"
+               "f.canada", "flags/canada-shield"
+               "f.catalan", "flags/catalan-shield"
+               "f.cheyenne", "flags/cheyenne-shield"
+               "f.chile", "flags/chile-shield"
+               "f.china", "flags/china-shield"
+               "f.columbia", "flags/columbia-shield"
+               "f.cornwall", "flags/cornwall-shield"
+               "f.croatia", "flags/croatia-shield"
+               "f.cuba", "flags/cuba-shield"
+               "f.czech", "flags/czech-shield"
+               "f.denmark", "flags/denmark-shield"
+               "f.dunedain", "flags/dunedain-shield"
+               "f.egypt", "flags/egypt-shield"
+               "f.elves", "flags/elves-shield"
+               "f.england", "flags/england-shield"
+               "f.estonia", "flags/estonia-shield"
+               "f.ethiopia", "flags/ethiopia-shield"
+               "f.europe", "flags/europe-shield"
+               "f.finland", "flags/finland-shield"
+               "f.france", "flags/france-shield"
+               "f.galicia", "flags/galicia-shield"
+               "f.germany", "flags/germany-shield"
+               "f.greece", "flags/greece-shield"
+               "f.greenland", "flags/greenland-shield"
+               "f.hobbits", "flags/hobbits-shield"
+               "f.holland", "flags/netherlands-shield" ; backward compatabiliy
+               "f.hungary", "flags/hungary-shield"
+               "f.iceland", "flags/iceland-shield"
+               "f.india", "flags/india-shield"
+               "f.indonesia", "flags/indonesia-shield"
+               "f.iran", "flags/iran-shield"
+               "f.iraq_old", "flags/iraq_old-shield"
+               "f.ireland", "flags/ireland-shield"
+;              "f.ireland", "flags/stpatrick-shield"
+               "f.israel", "flags/israel-shield"
+               "f.italy", "flags/italy-shield"
+               "f.japan", "flags/japan-shield"
+               "f.kampuchea", "flags/kampuchea-shield"
+               "f.kenya", "flags/kenya-shield"
+               "f.korea", "flags/korea-shield"
+               "f.krev", "flags/krev-shield"
+               "f.latvia", "flags/latvia-shield"
+               "f.lithuania", "flags/lithuania-shield"
+               "f.macedonia", "flags/macedonia-shield"
+               "f.malaysia", "flags/malaysia-shield"
+               "f.mars", "flags/mars-shield"
+               "f.mexico", "flags/mexico-shield"
+               "f.mongolia", "flags/mongolia-shield"
+               "f.mordor", "flags/mordor-shield"
+               "f.nato", "flags/nato-shield"
+               "f.netherlands", "flags/netherlands-shield"
+               "f.nigeria", "flags/nigeria-shield"
+               "f.norway", "flags/norway-shield"
+               "f.observer", "flags/observer-shield"
+               "f.pakistan", "flags/pakistan-shield"
+               "f.peru", "flags/peru-shield"
+               "f.philippines", "flags/philippines-shield"
+               "f.phoenicia", "flags/phoenicia-shield"
+               "f.poland", "flags/poland-shield"
+               "f.portugal", "flags/portugal-shield"
+               "f.quebec", "flags/quebec-shield"
+               "f.rome", "flags/rome-shield"           ; Roman republic flag
+               "f.russia", "flags/russia-shield"
+               "f.rwanda", "flags/rwanda-shield"       ; Alternate Zulu
+               "f.scotland", "flags/scotland-shield"
+               "f.serbia", "flags/serbia-shield"
+               "f.silesia", "flags/silesia-shield"
+               "f.singapore", "flags/singapore-shield"
+               "f.slovenia", "flags/slovenia-shield"
+               "f.south_africa", "flags/south_africa-shield"   ; for Zulus
+               "f.soviet", "flags/soviet-shield"
+               "f.spain", "flags/spain-shield"
+               "f.sumeria", "flags/sumeria-shield"
+               "f.sweden", "flags/sweden-shield"
+               "f.switzerland", "flags/swiss-shield"
+               "f.syria", "flags/syria-shield"
+               "f.taiwan", "flags/taiwan-shield"
+               "f.thailand", "flags/thailand-shield"
+               "f.tunisia", "flags/tunisia-shield"
+               "f.turkey", "flags/turkey-shield"
+               "f.ukraine", "flags/ukraine-shield"
+               "f.united_kingdom", "flags/united_kingdom-shield"
+               "f.united_nations", "flags/united_nations-shield"
+               "f.unknown", "flags/unknown-shield"     ; useful for alternates
+               "f.usa", "flags/usa-shield"
+               "f.vietnam", "flags/vietnam-shield"
+               "f.wales", "flags/wales-shield"
+               "f.alien", "flags/alien-shield"
+       }

PNG image

PNG image


[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#10779) render shields flags from SVG, Jason Short <=