Skip to content

Commit

Permalink
support custom colors with colors.txt
Browse files Browse the repository at this point in the history
fixes #42
  • Loading branch information
BuckarooBanzay committed Dec 8, 2024
1 parent a2e5aec commit 567caa6
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
18 changes: 18 additions & 0 deletions cmd/maprenderer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"image"
"image/png"
"os"
"path"
"strconv"
"strings"
"time"
Expand Down Expand Up @@ -140,6 +141,23 @@ func main() {
panic(err)
}

//load provided colors, if available
colors_path := path.Join(wd, "colors.txt")
info, err := os.Stat(colors_path)
if info != nil && err == nil {
data, err := os.ReadFile(colors_path)
if err != nil {
panic(err)
}

count, err := cm.LoadBytes(data)
if err != nil {
panic(err)
}

fmt.Printf("Loaded %d custom colors from '%s'\n", count, colors_path)
}

from, err := parsePos(*from_pos)
if err != nil {
panic(err)
Expand Down
8 changes: 8 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ Example output:

![](./map_example.png)

# Custom `colors.txt`

If a custom color-mapping is needed a `colors.txt` can be placed in the world-directory in the following format:
```
# node:name r g b
nc_terrain:cobble 10 20 30
```

# Binary downloads

See: https://github.com/minetest-go/maprenderer/releases
Expand Down

0 comments on commit 567caa6

Please sign in to comment.