Closed damntourists closed 8 months ago
Conclusion: I had to mess up colors conversion Conclusion 2: unittests are useful... sometimes
After testing I found that there is something wrong with ColorToUint (UintToColor works fine)
ok, found it:
return r&mask<<24 + g&mask<<16 + b&mask<<8 + a&mask
it is reversed
What happend?
It seems I can only render certain colors at the moment. The following example works for red, but not green or blue. I also tried with color.RGBA and color.NRGBA without any success. It seems when I zero out red and try to render green or blue, nothing renders at all, almost like alpha is turned to zero when it is not.
Code example
```golang [ ... ] for _, char := range w.chars { // testColor := g.UintToColor(0xFF0000FF) // c.RGBA{R: 255, G: 0, B: 0, A: 255} // works // testColor := g.UintToColor(0x00FF00FF) // c.RGBA{R: 0, G: 255, B: 0, A: 255} // doesn't work // testColor := g.UintToColor(0x0000FFFF) // c.RGBA{R: 0, G: 0, B: 255, A: 255} // doesn't work testColor := g.UintToColor(0x00FF00FF) // c.RGBA{R: 0, G: 255, B: 0, A: 255} charPos := pos.Add(image.Pt(int(char.X), int(char.Y))) // shadowPos := charPos.Add(image.Pt(1, 1)) // canvas.AddText(shadowPos, c.RGBA{R: 0, G: 0, B: 0, A: uint8(char.A)}, char.Value) canvas.AddText(charPos, testColor, char.Value) } [ ... ] ```pseudo main.go
To Reproduce
Version
master
OS
ubuntu