ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cf.schmorp.de/util/world2png
Revision: 1.3
Committed: Sun Dec 17 18:03:11 2006 UTC (17 years, 6 months ago) by root
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +0 -0 lines
State: FILE REMOVED
Log Message:
*** empty log message ***

File Contents

# Content
1 #!/opt/bin/perl
2
3 use Crossfire::Map;
4 use Storable;
5
6 use Gtk2 -init;
7
8 my %type = (
9 deep_sea => "#008",
10 sea => "#008",
11 shallow_sea => "#008",
12
13 beach => "#aa0",
14 desert => "#cc0",
15 brush => "#880",
16 steppe => "#880",
17
18 marsh => "#0f8",
19 grassbrown => "#0f0",
20 grassmedium => "#0f0",
21 grassdark => "#0f0",
22 grass => "#0f0",
23
24 darkforest => "#040",
25 evergreens => "#0a0",
26 evergreen => "#0a0",
27 tree => "#080",
28 tree1 => "#080",
29 tree2 => "#080",
30 tree3 => "#080",
31 tree4 => "#080",
32 tree5 => "#080",
33 tree6 => "#080",
34 forestsparse=> "#080",
35 woods => "#080",
36 woods_2 => "#080",
37 woods_3 => "#080",
38
39 swamp => "#660",
40 deep_swamp => "#440",
41
42 jungle_1 => "#084",
43 jungle_2 => "#084",
44 jungle_3 => "#084",
45
46 flagstone => "#bbb",
47 istone => "#bbc",
48
49 hills_rocky => "#aa8",
50 hills => "#aa4",
51 treed_hills => "#aa4",
52 mountain => "#ccc",
53 mountain_2 => "#ccd",
54 mountain2 => "#ccd",
55 mountain4 => "#ddb",
56 mountain5 => "#ddd",
57 s_mountain => "#dff",
58
59 wasteland => "#ddf",
60 drifts => "#eef",
61 snow => "#eff",
62 );
63
64 for my $k (keys %type) {
65 my $v = join "", map chr, (map $_*255/15, map hex, split //, substr $type{$k}, 1), 255;
66 $color{$k} = $v;
67 }
68
69 my $elev = "\x00\x00\x00\x00" x (1500*1500);
70 my $type = "\x00\x00\x00\x00" x (1500*1500);
71 my $mask = "\x00\x00\x00\x00" x (1500*1500);
72
73 my $maps = Storable::retrieve "worldmaps.pst";
74
75 for my $X (100..129) {
76 print "$X\n";#d#
77 for my $Y (100..129) {
78 my $map = $maps->[$X][$Y];
79 my $X = ($X - 100) * 50;
80 my $Y = ($Y - 100) * 50;
81 for my $x (0..49) {
82 for my $y (0..49) {
83 my $ofs = (($Y + $y)* 1500 + $X + $x) * 4;
84 my $i = 0;
85 for (@{ $map->{map}[$x][$y] || [] }) {
86 if (defined (my $h = $_->{elevation})) {
87 my ($g, $g, $b);
88 if ($h < 0) {
89 $r = 0;
90 $g = 0;
91 $b = int 256 * ($h + 32000) / 32001;
92 } else {
93 $g = 255;
94 $r = $b = int 256 * $h / (160619 + 1);
95 }
96 substr $elev, $ofs, 4, (chr $r) . (chr $g) . (chr $b) . "\xff";
97 }
98 if ((my $color = $color{$_->{_name}}) && !exists $_->{slaying}) {
99 substr $type, $ofs, 4, $color;
100 } else {
101 substr $type, $ofs, 4, "\xff\00\00\xff";
102 substr $mask, $ofs, 4, "\xff\00\00\xff";
103 print "$X $x, $Y $y $i $_->{_name}\n" unless $seen{$_->{_name}}++;
104 }
105 $i++;
106 }
107 }
108 }
109 }
110 }
111
112 Gtk2::Gdk::Pixbuf->new_from_data ($elev, "rgb", 1, 8, 1500, 1500, 1500*4)->save ("elev.png", "png");
113 Gtk2::Gdk::Pixbuf->new_from_data ($type, "rgb", 1, 8, 1500, 1500, 1500*4)->save ("type.png", "png");
114 Gtk2::Gdk::Pixbuf->new_from_data ($mask, "rgb", 1, 8, 1500, 1500, 1500*4)->save ("mask.png", "png");
115