From c64ce8da67cc0818e03960557334ff882dd59fbd Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Sat, 11 Feb 2023 21:17:43 -0500 Subject: [PATCH] Container shatters its background before drawing --- elements/basic/container.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/elements/basic/container.go b/elements/basic/container.go index 5697f8c..fabc80c 100644 --- a/elements/basic/container.go +++ b/elements/basic/container.go @@ -6,6 +6,7 @@ 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" @@ -220,11 +221,17 @@ func (element *Container) redoAll () { element.doLayout() // draw a background - bounds := element.Bounds() + rocks := make([]image.Rectangle, len(element.children)) + for index, entry := range element.children { + rocks[index] = entry.Bounds + } + tiles := shatter.Shatter(element.Bounds(), rocks...) pattern := element.theme.Pattern ( theme.PatternBackground, theme.PatternState { }) - artist.FillRectangle(element, pattern, bounds) + for _, tile := range tiles { + artist.FillRectangle(element, pattern, tile) + } // cut our canvas up and give peices to child elements for _, entry := range element.children {