Fix for issue #10. Set transparency level of pixels based on the alpha channel of colors.txt.

This commit is contained in:
Sascha L. Teichmann 2015-07-20 14:56:41 +02:00
parent ecd599e44d
commit 80113b885f
2 changed files with 9 additions and 6 deletions

View File

@ -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

View File

@ -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
}