From 82e92f1e2e6ba869bbdbcd7dc133c6c3de015806 Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Sun, 12 Feb 2023 10:55:32 -0500 Subject: [PATCH] Icons are now no longer patterns, they are images --- canvas/canvas.go | 6 ++++++ theme/default.go | 5 +++-- theme/theme.go | 17 +++++++++++++---- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/canvas/canvas.go b/canvas/canvas.go index cb2da2a..436dcd1 100644 --- a/canvas/canvas.go +++ b/canvas/canvas.go @@ -4,6 +4,12 @@ import "image" import "image/draw" import "image/color" +// Image represents an immutable canvas. +type Image interface { + image.Image + RGBAAt (x, y int) color.RGBA +} + // Canvas is like draw.Image but is also able to return a raw pixel buffer for // more efficient drawing. This interface can be easily satisfied using a // BasicCanvas struct. diff --git a/theme/default.go b/theme/default.go index 107cffd..2e5afa8 100644 --- a/theme/default.go +++ b/theme/default.go @@ -3,6 +3,7 @@ package theme import "image" import "golang.org/x/image/font" import "git.tebibyte.media/sashakoshka/tomo/artist" +import "git.tebibyte.media/sashakoshka/tomo/canvas" import "git.tebibyte.media/sashakoshka/tomo/defaultfont" // Default is the default theme. @@ -23,9 +24,9 @@ func (Default) FontFace (style FontStyle, size FontSize, c Case) font.Face { } // Icon returns an icon from the default set corresponding to the given name. -func (Default) Icon (string, Case) artist.Pattern { +func (Default) Icon (string, Case, IconSize) canvas.Image { // TODO - return uhex(0) + return nil } // Pattern returns a pattern from the default theme corresponding to the given diff --git a/theme/theme.go b/theme/theme.go index 5f9f8ce..64aef72 100644 --- a/theme/theme.go +++ b/theme/theme.go @@ -3,6 +3,15 @@ package theme import "image" import "golang.org/x/image/font" import "git.tebibyte.media/sashakoshka/tomo/artist" +import "git.tebibyte.media/sashakoshka/tomo/canvas" + +// IconSize is a type representing valid icon sizes. +type IconSize int + +const ( + IconSizeSmall IconSize = 16 + IconSizeLarge IconSize = 48 +) // Pattern lists a number of cannonical pattern types, each with its own ID. // This allows custom elements to follow themes, even those that do not @@ -52,8 +61,8 @@ type Theme interface { // FontFace returns the proper font for a given style, size, and case. FontFace (FontStyle, FontSize, Case) font.Face - // Icon returns an appropriate icon given an icon name and case. - Icon (string, Case) artist.Pattern + // Icon returns an appropriate icon given an icon name, size, and case. + Icon (string, IconSize, Case) canvas.Image // Pattern returns an appropriate pattern given a pattern name, case, // and state. @@ -84,9 +93,9 @@ func (wrapped Wrapped) FontFace (style FontStyle, size FontSize) font.Face { } // Icon returns an appropriate icon given an icon name. -func (wrapped Wrapped) Icon (name string) artist.Pattern { +func (wrapped Wrapped) Icon (name string, size IconSize) canvas.Image { real := wrapped.ensure() - return real.Icon(name, wrapped.Case) + return real.Icon(name, size, wrapped.Case) } // Pattern returns an appropriate pattern given a pattern name and state.