Skip to content

Commit

Permalink
add: remove transparency by the first color in the palette
Browse files Browse the repository at this point in the history
  • Loading branch information
Jerome Le Saux committed May 5, 2024
1 parent 0a02afa commit d8fbffb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
9 changes: 8 additions & 1 deletion convert/image/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,14 @@ func downgradeWithPalette(in *image.NRGBA, p color.Palette) *image.NRGBA {
if cc := cache[c]; cc != nil {
in.Set(x, y, cc)
} else {
cPalette := p.Convert(c)
var cPalette color.Color
// check value transparency
r, g, b, a := c.RGBA()
if r == 0 && g == 0 && b == 0 && a == 0 {
cPalette = p[0]
} else {
cPalette = p.Convert(c)
}
in.Set(x, y, cPalette)
cache[c] = cPalette
}
Expand Down
6 changes: 5 additions & 1 deletion ui/martine-ui/sprite_tab.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,11 @@ func (m *MartineUI) newSpriteTab(s *menu.SpriteMenu) *fyne.Container {
),
),
container.New(
layout.NewGridLayoutWithRows(2),
layout.NewGridLayoutWithRows(3),
container.New(layout.NewVBoxLayout(),
widget.NewCheck("Use this palette", func(b bool) {
s.UsePalette = b
})),
container.New(
layout.NewVBoxLayout(),
widget.NewLabel("Palette"),
Expand Down

0 comments on commit d8fbffb

Please sign in to comment.