forked from techmunk/stardew-predictor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wallpaper_css_gen.pl
77 lines (67 loc) · 1.47 KB
/
wallpaper_css_gen.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/perl
#
# wallpaper_css_gen.pl
#
# small perl script to generate the css for wallpaper images used in Stardew Predictor
# prints to STDOUT and should be redirected to wallpaper.css
my $tile_width = 16;
my $tile_height = 48;
my $image_width = 256;
print <<"END_PRINT";
/* wallpaper.css
* https://mouseypounds.github.io/stardew-predictor/
*/
div.wp {
clear: left;
}
img.wp {
float: left;
width: ${tile_width}px;
height: 45px;
border-top: 1px solid black;
border-bottom: 1px solid black;
background-image:url("./walls_and_floors.png")
}
img.left {
border-left: 1px solid black;
}
img.right {
border-right: 1px solid black;
}
END_PRINT
for (my $i = 0; $i < 112; $i++) {
use integer;
my $x = 0 - ($tile_width * ($i % ($image_width/$tile_width)));
my $y = 0 - ($tile_height * ($i / ($image_width/$tile_width)));
my $id = "wp_" . ($i+1);
print <<"END_PRINT";
img#$id {
background-position: ${x}px ${y}px;
}
END_PRINT
}
$tile_width = 32;
$tile_height = 32;
print <<"END_PRINT";
div.fl {
clear: left;
}
img.fl {
float: left;
width: ${tile_width}px;
height: ${tile_height}px;
border: 1px solid black;
background-image:url("./walls_and_floors.png")
}
END_PRINT
for (my $i = 0; $i < 40; $i++) {
use integer;
my $x = 0 - ($tile_width * ($i % ($image_width/$tile_width)));
my $y = -336 - ($tile_height * ($i / ($image_width/$tile_width)));
my $id = "fl_" . ($i+1);
print <<"END_PRINT";
img#$id {
background-position: ${x}px ${y}px;
}
END_PRINT
}