diff --git a/SETUP.md b/SETUP.md index deae0a3..cba3c00 100644 --- a/SETUP.md +++ b/SETUP.md @@ -79,8 +79,9 @@ This contacts the `mtredisalize` server running at localhost port 6379 to fetch need a `colors.txt` to map the block nodes to pixel colors of your map. The repository contains [one](https://bitbucket.org/s_l_teichmann/mtsatellite/raw/default/colors.txt). If you want to have certain nodes to be transparent you can add `-transparent=true` to the -options. In this case if the colors from colors.txt do have a forth color component with a numerical -value lower than 255 (e.g 128) the corresponding pixels on the resultung tiles would be transparent. +options. In this case if a color from colors.txt does have a forth color component the numerical +value between 0 (fully transparent) and 255 (fully opaque) will be the base transparency of the +pixel. Every depth meter of the same material will reduce the transparency by 2%. See `mtseeder --help` for all options. The `-workers=` option and the `GOMAXPROCS=` environment variable are completely optional but very useful diff --git a/common/colors.go b/common/colors.go index 83044bf..e27f489 100644 --- a/common/colors.go +++ b/common/colors.go @@ -113,11 +113,13 @@ func (colors *Colors) BlendColors(span *Span, col color.RGBA, pos int32) color.R if curr == nil { return col } - const scale = float32(1) / float32(100) + const scale = float32(1) / 100 for ; curr != nil; curr = curr.Next { - // At least 50% attenuation + 2% extra for each depth meter. - factor := float32(min(100, 50+(curr.To-curr.From)*2)) * scale - col = BlendColor(colors.Colors[curr.Value], col, factor) + c := colors.Colors[curr.Value] + // At least alpha channel attenuation + 2% extra for each depth meter. + base := (int32(c.A) * 100) / 255 + factor := float32(min(100, base+(curr.To-curr.From)*2)) * scale + col = BlendColor(c, col, factor) } return col }