Artist and test examples work

This commit is contained in:
Sasha Koshka 2023-02-03 18:32:22 -05:00
parent f8ebe5b1e4
commit 0bdbaa39ca
2 changed files with 17 additions and 3 deletions

View File

@ -4,6 +4,7 @@ import "fmt"
import "time"
import "image"
import "image/color"
import "git.tebibyte.media/sashakoshka/tomo/theme"
import "git.tebibyte.media/sashakoshka/tomo/artist"
import "git.tebibyte.media/sashakoshka/tomo/defaultfont"
import "git.tebibyte.media/sashakoshka/tomo/elements/core"
@ -19,13 +20,16 @@ type Artist struct {
// NewArtist creates a new artist test element.
func NewArtist () (element *Artist) {
element = &Artist { }
element.Core, element.core = core.NewCore(element.draw)
element.Core, element.core = core.NewCore (
element.draw, nil, nil, theme.C("testing", "artist"))
element.core.SetMinimumSize(480, 600)
return
}
func (element *Artist) draw () {
bounds := element.Bounds()
artist.FillRectangle(element, artist.NewUniform(hex(0)), bounds)
element.cellBounds.Max.X = bounds.Min.X + bounds.Dx() / 5
element.cellBounds.Max.Y = bounds.Min.Y + (bounds.Dy() - 48) / 8

View File

@ -20,15 +20,25 @@ type Mouse struct {
// NewMouse creates a new mouse test element.
func NewMouse () (element *Mouse) {
element = &Mouse { }
element.Core, element.core = core.NewCore(element.draw)
element.Core, element.core = core.NewCore (
element.draw,
element.redo,
element.redo,
theme.C("testing", "mouse"))
element.core.SetMinimumSize(32, 32)
element.color = artist.NewUniform(color.Black)
return
}
func (element *Mouse) redo () {
if !element.core.HasImage() { return }
element.draw()
element.core.DamageAll()
}
func (element *Mouse) draw () {
bounds := element.Bounds()
pattern, _ := theme.AccentPattern(theme.PatternState { })
pattern := element.core.Pattern(theme.PatternAccent, theme.PatternState { })
artist.FillRectangle(element, pattern, bounds)
artist.StrokeRectangle (
element,