Added color table for tilemapper.

This commit is contained in:
Sascha L. Teichmann 2014-09-09 15:01:14 +02:00
parent 01626f0d22
commit 0da0761b44
3 changed files with 2067 additions and 1 deletions

36
tilemapper/colors.go Normal file
View File

@ -0,0 +1,36 @@
package main
import (
"bufio"
"fmt"
"image/color"
"os"
"strings"
)
func ParseColors(filename string) (colors map[string]color.RGBA, err error) {
var file *os.File
if file, err = os.Open(filename); err != nil {
return
}
defer file.Close()
colors = make(map[string]color.RGBA)
scanner := bufio.NewScanner(file)
for scanner.Scan() {
line := scanner.Text()
if strings.HasPrefix(line, "#") {
continue
}
c := color.RGBA{A: 0xff}
var name string
if n, _ := fmt.Sscanf(
line, "%s %d %d %d %d", &name, &c.R, &c.G, &c.B, &c.A); n > 0 {
colors[name] = c
}
}
err = scanner.Err()
return
}

2019
tilemapper/colors.txt Normal file

File diff suppressed because it is too large Load Diff

View File

@ -3,6 +3,7 @@ package main
import (
"flag"
"fmt"
"image/color"
"log"
"bitbucket.org/s_l_teichmann/mtredisalize/common"
@ -14,6 +15,7 @@ func main() {
host string
x, y, z int
width, height, depth int
colorsfile string
)
flag.IntVar(&port, "port", 6379, "port to of mtredisalize server")
@ -27,12 +29,21 @@ func main() {
flag.IntVar(&width, "w", 18, "width of query cuboid (shorthand)")
flag.IntVar(&height, "h", 18, "height of query cuboid (shorthand)")
flag.IntVar(&depth, "d", 150, "depth of query cuboid (shorthand)")
flag.StringVar(&colorsfile, "colors", "colors.txt", "definition of colors")
flag.Parse()
var err error
var colors map[string]color.RGBA
if colors, err = ParseColors(colorsfile); err != nil {
log.Fatalf("Cannot open color file: %s", err)
}
_ = colors
address := fmt.Sprintf("%s:%d", host, port)
var err error
var client *Client
if client, err = NewClient("tcp", address); err != nil {