Code compiles

This commit is contained in:
Sasha Koshka 2023-08-29 21:40:31 -04:00
parent e7c5b2d5b9
commit 1b489485da
2 changed files with 9 additions and 10 deletions

View File

@ -1,18 +1,17 @@
package aluminum package aluminum
import "os"
import "fs"
import "fmt" import "fmt"
import "io/fs"
import "image" import "image"
import "image/png" import _ "image/png"
import "git.tebibyte.media/tomo/tomo"
import "git.tebibyte.media/tomo/tomo/data" import "git.tebibyte.media/tomo/tomo/data"
import "git.tebibyte.media/tomo/tomo/theme" import "git.tebibyte.media/tomo/tomo/theme"
import "git.tebibyte.media/tomo/tomo/input"
import "git.tebibyte.media/tomo/tomo/canvas" import "git.tebibyte.media/tomo/tomo/canvas"
type iconSet struct { type iconSet struct {
fs fs.FS fs fs.FS
icons: map[theme.IconSize] map[string] canvas.Texture icons map[theme.IconSize] map[string] canvas.Texture
} }
func (this *iconSet) get (size theme.IconSize, name string) canvas.Texture { func (this *iconSet) get (size theme.IconSize, name string) canvas.Texture {
@ -24,11 +23,13 @@ func (this *iconSet) get (size theme.IconSize, name string) canvas.Texture {
defer func () { this.icons[size][name] = texture } () defer func () { this.icons[size][name] = texture } ()
file, err := this.fs.Open(fmt.Sprint(size, "/", name, ".png")) file, err := this.fs.Open(fmt.Sprint(size, "/", name, ".png"))
if err != nil { return nil } if err != nil { return texture }
defer file.Close() defer file.Close()
image, _, err := image.Decode(file) image, _, err := image.Decode(file)
if err != nil { return nil } if err != nil { return texture }
texture = tomo.NewTexture(image) texture = tomo.NewTexture(image)
return texture
} }
} }
@ -50,6 +51,6 @@ func (this *iconSet) ApplicationIcon (id theme.ApplicationIcon, size theme.IconS
if texture != nil { if texture != nil {
return texture return texture
} else { } else {
return this.get(size, fmt.Sprint("app-generic/", app.Role)) return this.get(size, fmt.Sprint("app-generic/", id.Role))
} }
} }

View File

@ -4,11 +4,9 @@ import "image"
import "image/color" import "image/color"
import "git.tebibyte.media/tomo/tomo" import "git.tebibyte.media/tomo/tomo"
import "golang.org/x/image/font/basicfont" import "golang.org/x/image/font/basicfont"
import "git.tebibyte.media/tomo/tomo/data"
import "git.tebibyte.media/tomo/tomo/theme" import "git.tebibyte.media/tomo/tomo/theme"
import "git.tebibyte.media/tomo/tomo/input" import "git.tebibyte.media/tomo/tomo/input"
import "git.tebibyte.media/tomo/tomo/event" import "git.tebibyte.media/tomo/tomo/event"
import "git.tebibyte.media/tomo/tomo/canvas"
func hex (color uint32) (c color.RGBA) { func hex (color uint32) (c color.RGBA) {
c.A = uint8(color) c.A = uint8(color)