mirror of
https://bitbucket.org/s_l_teichmann/mtsatellite
synced 2025-01-28 09:00:18 +01:00
Added color table for tilemapper.
This commit is contained in:
parent
01626f0d22
commit
0da0761b44
36
tilemapper/colors.go
Normal file
36
tilemapper/colors.go
Normal 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
2019
tilemapper/colors.txt
Normal file
File diff suppressed because it is too large
Load Diff
@ -3,6 +3,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"image/color"
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"bitbucket.org/s_l_teichmann/mtredisalize/common"
|
"bitbucket.org/s_l_teichmann/mtredisalize/common"
|
||||||
@ -14,6 +15,7 @@ func main() {
|
|||||||
host string
|
host string
|
||||||
x, y, z int
|
x, y, z int
|
||||||
width, height, depth int
|
width, height, depth int
|
||||||
|
colorsfile string
|
||||||
)
|
)
|
||||||
|
|
||||||
flag.IntVar(&port, "port", 6379, "port to of mtredisalize server")
|
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(&width, "w", 18, "width of query cuboid (shorthand)")
|
||||||
flag.IntVar(&height, "h", 18, "height 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.IntVar(&depth, "d", 150, "depth of query cuboid (shorthand)")
|
||||||
|
flag.StringVar(&colorsfile, "colors", "colors.txt", "definition of colors")
|
||||||
|
|
||||||
flag.Parse()
|
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)
|
address := fmt.Sprintf("%s:%d", host, port)
|
||||||
|
|
||||||
var err error
|
|
||||||
var client *Client
|
var client *Client
|
||||||
|
|
||||||
if client, err = NewClient("tcp", address); err != nil {
|
if client, err = NewClient("tcp", address); err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user