-
Notifications
You must be signed in to change notification settings - Fork 1
/
drawMap.sh
executable file
·86 lines (71 loc) · 1.93 KB
/
drawMap.sh
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
78
79
80
81
82
83
84
85
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\t\n'
if [[ $# -ne 2 ]]; then
echo >&2 "$0 <size> <seed>"
exit 1
fi
BIN="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SIZE="${1}"
IMGSIZE="${SIZE}x${SIZE}"
SEED="${2}"
NAME="${SEED}-${SIZE}"
PREVIEW="${NAME}.png"
optional() {
declare -n VAR="$1"
shift
#shellcheck disable=SC2034
VAR=( "$@" )
}
[[ ! -f dtm.png ]] && convert -size "${IMGSIZE}" -depth 16 gray:dtm.raw -flip dtm.png
[[ ! -f biomemap.png ]] && convert biomes.png \
-fill '#949442' -opaque '#ffa800' \
-fill '#393931' -opaque '#ba00ff' \
-fill '#c3c4d9' -opaque '#ffffff' \
biomemap.png
[[ ! -f splatmap.png ]] && convert splat3.png \
-alpha off -transparent black \
-fill '#9c8c7b' -opaque '#00ff00' \
-fill '#ceb584' -opaque '#ff0000' \
splatmap.png
[[ ! -f splat4map.png ]] && convert splat4.png \
-alpha off \
-set colorspace Gray \
-channel blue -separate \
splat4map.png
[[ ! -f watermap.png ]] && convert \
dtm.png \
splat4map.png \
-compose MinusSrc -composite \
-threshold 128 \
-fill '#738cce' -opaque black \
-transparent white \
watermap.png
[[ -f radiation.png && ! -f radiationmap.png ]] && convert radiation.png \
-channel rgba -fill "rgba(255,0,0,0.7)" -opaque "rgb(255,0,0)" +channel \
-transparent black \
-scale "${IMGSIZE}" \
radiationmap.png
IFS=$' \t\n' MOUNTAINS=( $( "${BIN}/drawMountains.sh" "$SIZE" ) )
if [[ -f radiationmap.png ]]; then
optional RADIATION_ARGS \
radiationmap.png -compose Over -composite
else
optional RADIATION_ARGS
fi
convert biomemap.png \
splatmap.png -composite \
"${MOUNTAINS[0]}" -compose screen -composite \
\( "${MOUNTAINS[1]}" -negate \) -compose multiply -composite \
watermap.png -compose Over -composite \
"${RADIATION_ARGS[@]}" \
-depth 8 \
-set comment "${SEED}" \
"${PREVIEW}"
mkdir -p thumbs
NAILSIZE="$((SIZE/16))"
convert "${PREVIEW}" \
-depth 8 \
-resize "${NAILSIZE}x${NAILSIZE}" \
"thumbs/${PREVIEW}"
echo "${PREVIEW}"