Created FillRectangleShatter for convenience
This commit is contained in:
parent
fc0a9292d9
commit
f8240fb518
@ -2,6 +2,7 @@ package artist
|
|||||||
|
|
||||||
import "image"
|
import "image"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/canvas"
|
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.
|
// Paste transfers one canvas onto another, offset by the specified point.
|
||||||
func Paste (
|
func Paste (
|
||||||
@ -75,6 +76,23 @@ func FillRectangleClip (
|
|||||||
return
|
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
|
// StrokeRectangle draws the outline of a rectangle with the specified line
|
||||||
// weight and pattern.
|
// weight and pattern.
|
||||||
func StrokeRectangle (
|
func StrokeRectangle (
|
||||||
|
@ -6,7 +6,6 @@ import "git.tebibyte.media/sashakoshka/tomo/theme"
|
|||||||
import "git.tebibyte.media/sashakoshka/tomo/config"
|
import "git.tebibyte.media/sashakoshka/tomo/config"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/canvas"
|
import "git.tebibyte.media/sashakoshka/tomo/canvas"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/artist"
|
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/layouts"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/elements"
|
import "git.tebibyte.media/sashakoshka/tomo/elements"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/elements/core"
|
import "git.tebibyte.media/sashakoshka/tomo/elements/core"
|
||||||
@ -225,14 +224,11 @@ func (element *Container) redoAll () {
|
|||||||
for index, entry := range element.children {
|
for index, entry := range element.children {
|
||||||
rocks[index] = entry.Bounds
|
rocks[index] = entry.Bounds
|
||||||
}
|
}
|
||||||
tiles := shatter.Shatter(element.Bounds(), rocks...)
|
|
||||||
pattern := element.theme.Pattern (
|
pattern := element.theme.Pattern (
|
||||||
theme.PatternBackground,
|
theme.PatternBackground,
|
||||||
theme.PatternState { })
|
theme.PatternState { })
|
||||||
for _, tile := range tiles {
|
artist.FillRectangleShatter (
|
||||||
artist.FillRectangleClip (
|
element.core, pattern, element.Bounds(), rocks...)
|
||||||
element.core, pattern, element.Bounds(), tile)
|
|
||||||
}
|
|
||||||
|
|
||||||
// cut our canvas up and give peices to child elements
|
// cut our canvas up and give peices to child elements
|
||||||
for _, entry := range element.children {
|
for _, entry := range element.children {
|
||||||
|
@ -7,7 +7,6 @@ import "git.tebibyte.media/sashakoshka/tomo/theme"
|
|||||||
import "git.tebibyte.media/sashakoshka/tomo/config"
|
import "git.tebibyte.media/sashakoshka/tomo/config"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/canvas"
|
import "git.tebibyte.media/sashakoshka/tomo/canvas"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/artist"
|
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/core"
|
||||||
|
|
||||||
// List is an element that contains several objects that a user can select.
|
// 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,
|
innerBounds.Dx(), element.contentHeight,
|
||||||
).Add(innerBounds.Min).Intersect(innerBounds)
|
).Add(innerBounds.Min).Intersect(innerBounds)
|
||||||
pattern := element.theme.Pattern(theme.PatternSunken, state)
|
pattern := element.theme.Pattern(theme.PatternSunken, state)
|
||||||
tiles := shatter.Shatter(bounds, covered)
|
artist.FillRectangleShatter (
|
||||||
for _, tile := range tiles {
|
element.core, pattern, bounds, covered)
|
||||||
artist.FillRectangleClip (
|
|
||||||
element.core, pattern, bounds, tile)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@ import "git.tebibyte.media/sashakoshka/tomo/input"
|
|||||||
import "git.tebibyte.media/sashakoshka/tomo/theme"
|
import "git.tebibyte.media/sashakoshka/tomo/theme"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/config"
|
import "git.tebibyte.media/sashakoshka/tomo/config"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/artist"
|
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/core"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/elements/fun/music"
|
import "git.tebibyte.media/sashakoshka/tomo/elements/fun/music"
|
||||||
|
|
||||||
@ -304,11 +303,8 @@ func (element *Piano) draw () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pattern := element.theme.Pattern(theme.PatternPinboard, state)
|
pattern := element.theme.Pattern(theme.PatternPinboard, state)
|
||||||
tiles := shatter.Shatter(element.Bounds(), element.contentBounds)
|
artist.FillRectangleShatter (
|
||||||
for _, tile := range tiles {
|
element.core, pattern, element.Bounds(), element.contentBounds)
|
||||||
artist.FillRectangleClip (
|
|
||||||
element.core, pattern, element.Bounds(), tile)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (element *Piano) drawFlat (
|
func (element *Piano) drawFlat (
|
||||||
|
Reference in New Issue
Block a user