From bb50c7d7a73a94dbe691ab2a0426eb48106c7c50 Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Sat, 15 Apr 2023 18:30:22 -0400 Subject: [PATCH] Lol --- elements/fun/clock.go | 10 +++++----- elements/testing/artist.go | 12 +++++++----- elements/testing/mouse.go | 7 ++++--- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/elements/fun/clock.go b/elements/fun/clock.go index a23e828..0b4468d 100644 --- a/elements/fun/clock.go +++ b/elements/fun/clock.go @@ -8,7 +8,6 @@ import "git.tebibyte.media/sashakoshka/tomo" import "git.tebibyte.media/sashakoshka/tomo/canvas" import "git.tebibyte.media/sashakoshka/tomo/artist/shapes" import "git.tebibyte.media/sashakoshka/tomo/default/theme" -import "git.tebibyte.media/sashakoshka/tomo/default/config" // AnalogClock can display the time of day in an analog format. type AnalogClock struct { @@ -22,7 +21,7 @@ func NewAnalogClock (newTime time.Time) (element *AnalogClock) { element = &AnalogClock { } element.theme.Case = tomo.C("tomo", "clock") element.entity = tomo.NewEntity(element) - element.core.SetMinimumSize(64, 64) + element.entity.SetMinimumSize(64, 64) return } @@ -33,12 +32,12 @@ func (element *AnalogClock) Entity () tomo.Entity { // Draw causes the element to draw to the specified destination canvas. func (element *AnalogClock) Draw (destination canvas.Canvas) { - bounds := element.Bounds() + bounds := element.entity.Bounds() state := tomo.State { } pattern := element.theme.Pattern(tomo.PatternSunken, state) padding := element.theme.Padding(tomo.PatternSunken) - pattern.Draw(element.core, bounds) + pattern.Draw(destination, bounds) bounds = padding.Apply(bounds) @@ -47,6 +46,7 @@ func (element *AnalogClock) Draw (destination canvas.Canvas) { for hour := 0; hour < 12; hour ++ { element.radialLine ( + destination, foreground, 0.8, 0.9, float64(hour) / 6 * math.Pi) } @@ -90,5 +90,5 @@ func (element *AnalogClock) radialLine ( max := bounds.Min.Add(image.Pt ( int(math.Cos(radian) * outer * width + width), int(math.Sin(radian) * outer * height + height))) - shapes.ColorLine(element.core, source, 1, min, max) + shapes.ColorLine(destination, source, 1, min, max) } diff --git a/elements/testing/artist.go b/elements/testing/artist.go index 91faa0a..a7546a2 100644 --- a/elements/testing/artist.go +++ b/elements/testing/artist.go @@ -20,13 +20,15 @@ type Artist struct { } // NewArtist creates a new artist test element. -func NewArtist () *Artist { - return &Artist { } +func NewArtist () (element *Artist) { + element = &Artist { } + element.entity = tomo.NewEntity(element) + element.entity.SetMinimumSize(240, 240) + return } -func (element *Artist) Bind (entity tomo.Entity) { - element.entity = entity - if entity != nil { entity.SetMinimumSize(240, 240) } +func (element *Artist) Entity () tomo.Entity { + return element.entity } func (element *Artist) Draw (destination canvas.Canvas) { diff --git a/elements/testing/mouse.go b/elements/testing/mouse.go index 56e09d7..fa22b9a 100644 --- a/elements/testing/mouse.go +++ b/elements/testing/mouse.go @@ -24,12 +24,13 @@ type Mouse struct { func NewMouse () (element *Mouse) { element = &Mouse { } element.theme.Case = tomo.C("tomo", "mouse") + element.entity = tomo.NewEntity(element) + element.entity.SetMinimumSize(32, 32) return } -func (element *Mouse) Bind (entity tomo.Entity) { - element.entity = entity - entity.SetMinimumSize(32, 32) +func (element *Mouse) Entity () tomo.Entity { + return element.entity } func (element *Mouse) Draw (destination canvas.Canvas) {