diff --git a/artist/rectangle.go b/artist/rectangle.go index a3fd714..5adbe72 100644 --- a/artist/rectangle.go +++ b/artist/rectangle.go @@ -2,6 +2,7 @@ package artist import "image" import "git.tebibyte.media/sashakoshka/tomo/canvas" +import "git.tebibyte.media/sashakoshka/tomo/shatter" // Paste transfers one canvas onto another, offset by the specified point. func Paste ( @@ -75,6 +76,23 @@ func FillRectangleClip ( return } +// FillRectangleShatter shatters a bounding rectangle and draws its tiles in one +// fell swoop. +func FillRectangleShatter ( + destination canvas.Canvas, + source Pattern, + glass image.Rectangle, + rocks ...image.Rectangle, +) ( + updatedRegions []image.Rectangle, +) { + tiles := shatter.Shatter(glass, rocks...) + for _, tile := range tiles { + FillRectangleClip(destination, source, glass, tile) + } + return tiles +} + // StrokeRectangle draws the outline of a rectangle with the specified line // weight and pattern. func StrokeRectangle ( diff --git a/elements/basic/container.go b/elements/basic/container.go index 5fb9906..b4bb5b0 100644 --- a/elements/basic/container.go +++ b/elements/basic/container.go @@ -6,7 +6,6 @@ import "git.tebibyte.media/sashakoshka/tomo/theme" import "git.tebibyte.media/sashakoshka/tomo/config" import "git.tebibyte.media/sashakoshka/tomo/canvas" import "git.tebibyte.media/sashakoshka/tomo/artist" -import "git.tebibyte.media/sashakoshka/tomo/shatter" import "git.tebibyte.media/sashakoshka/tomo/layouts" import "git.tebibyte.media/sashakoshka/tomo/elements" import "git.tebibyte.media/sashakoshka/tomo/elements/core" @@ -225,14 +224,11 @@ func (element *Container) redoAll () { for index, entry := range element.children { rocks[index] = entry.Bounds } - tiles := shatter.Shatter(element.Bounds(), rocks...) pattern := element.theme.Pattern ( theme.PatternBackground, theme.PatternState { }) - for _, tile := range tiles { - artist.FillRectangleClip ( - element.core, pattern, element.Bounds(), tile) - } + artist.FillRectangleShatter ( + element.core, pattern, element.Bounds(), rocks...) // cut our canvas up and give peices to child elements for _, entry := range element.children { diff --git a/elements/basic/list.go b/elements/basic/list.go index 0219e76..7fdaa87 100644 --- a/elements/basic/list.go +++ b/elements/basic/list.go @@ -7,7 +7,6 @@ import "git.tebibyte.media/sashakoshka/tomo/theme" import "git.tebibyte.media/sashakoshka/tomo/config" import "git.tebibyte.media/sashakoshka/tomo/canvas" import "git.tebibyte.media/sashakoshka/tomo/artist" -import "git.tebibyte.media/sashakoshka/tomo/shatter" import "git.tebibyte.media/sashakoshka/tomo/elements/core" // List is an element that contains several objects that a user can select. @@ -461,9 +460,6 @@ func (element *List) draw () { innerBounds.Dx(), element.contentHeight, ).Add(innerBounds.Min).Intersect(innerBounds) pattern := element.theme.Pattern(theme.PatternSunken, state) - tiles := shatter.Shatter(bounds, covered) - for _, tile := range tiles { - artist.FillRectangleClip ( - element.core, pattern, bounds, tile) - } + artist.FillRectangleShatter ( + element.core, pattern, bounds, covered) } diff --git a/elements/fun/piano.go b/elements/fun/piano.go index a3ea0a0..e116c1d 100644 --- a/elements/fun/piano.go +++ b/elements/fun/piano.go @@ -5,7 +5,6 @@ import "git.tebibyte.media/sashakoshka/tomo/input" import "git.tebibyte.media/sashakoshka/tomo/theme" import "git.tebibyte.media/sashakoshka/tomo/config" import "git.tebibyte.media/sashakoshka/tomo/artist" -import "git.tebibyte.media/sashakoshka/tomo/shatter" import "git.tebibyte.media/sashakoshka/tomo/elements/core" import "git.tebibyte.media/sashakoshka/tomo/elements/fun/music" @@ -304,11 +303,8 @@ func (element *Piano) draw () { } pattern := element.theme.Pattern(theme.PatternPinboard, state) - tiles := shatter.Shatter(element.Bounds(), element.contentBounds) - for _, tile := range tiles { - artist.FillRectangleClip ( - element.core, pattern, element.Bounds(), tile) - } + artist.FillRectangleShatter ( + element.core, pattern, element.Bounds(), element.contentBounds) } func (element *Piano) drawFlat (