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

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