Artist and test examples work
This commit is contained in:
parent
f8ebe5b1e4
commit
0bdbaa39ca
@ -4,6 +4,7 @@ import "fmt"
|
|||||||
import "time"
|
import "time"
|
||||||
import "image"
|
import "image"
|
||||||
import "image/color"
|
import "image/color"
|
||||||
|
import "git.tebibyte.media/sashakoshka/tomo/theme"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/artist"
|
import "git.tebibyte.media/sashakoshka/tomo/artist"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/defaultfont"
|
import "git.tebibyte.media/sashakoshka/tomo/defaultfont"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/elements/core"
|
import "git.tebibyte.media/sashakoshka/tomo/elements/core"
|
||||||
@ -19,13 +20,16 @@ type Artist struct {
|
|||||||
// NewArtist creates a new artist test element.
|
// NewArtist creates a new artist test element.
|
||||||
func NewArtist () (element *Artist) {
|
func NewArtist () (element *Artist) {
|
||||||
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)
|
element.core.SetMinimumSize(480, 600)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (element *Artist) draw () {
|
func (element *Artist) draw () {
|
||||||
bounds := element.Bounds()
|
bounds := element.Bounds()
|
||||||
|
artist.FillRectangle(element, artist.NewUniform(hex(0)), bounds)
|
||||||
|
|
||||||
element.cellBounds.Max.X = bounds.Min.X + bounds.Dx() / 5
|
element.cellBounds.Max.X = bounds.Min.X + bounds.Dx() / 5
|
||||||
element.cellBounds.Max.Y = bounds.Min.Y + (bounds.Dy() - 48) / 8
|
element.cellBounds.Max.Y = bounds.Min.Y + (bounds.Dy() - 48) / 8
|
||||||
|
|
||||||
|
@ -20,15 +20,25 @@ type Mouse struct {
|
|||||||
// NewMouse creates a new mouse test element.
|
// NewMouse creates a new mouse test element.
|
||||||
func NewMouse () (element *Mouse) {
|
func NewMouse () (element *Mouse) {
|
||||||
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.core.SetMinimumSize(32, 32)
|
||||||
element.color = artist.NewUniform(color.Black)
|
element.color = artist.NewUniform(color.Black)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (element *Mouse) redo () {
|
||||||
|
if !element.core.HasImage() { return }
|
||||||
|
element.draw()
|
||||||
|
element.core.DamageAll()
|
||||||
|
}
|
||||||
|
|
||||||
func (element *Mouse) draw () {
|
func (element *Mouse) draw () {
|
||||||
bounds := element.Bounds()
|
bounds := element.Bounds()
|
||||||
pattern, _ := theme.AccentPattern(theme.PatternState { })
|
pattern := element.core.Pattern(theme.PatternAccent, theme.PatternState { })
|
||||||
artist.FillRectangle(element, pattern, bounds)
|
artist.FillRectangle(element, pattern, bounds)
|
||||||
artist.StrokeRectangle (
|
artist.StrokeRectangle (
|
||||||
element,
|
element,
|
||||||
|
Reference in New Issue
Block a user