Added a new FillRectangleClip function
This commit is contained in:
parent
dcaf9919e4
commit
fa42cf1f5f
@ -36,10 +36,28 @@ func FillRectangle (
|
|||||||
bounds image.Rectangle,
|
bounds image.Rectangle,
|
||||||
) (
|
) (
|
||||||
updatedRegion image.Rectangle,
|
updatedRegion image.Rectangle,
|
||||||
|
) {
|
||||||
|
return FillRectangleClip(destination, source, bounds, bounds)
|
||||||
|
}
|
||||||
|
|
||||||
|
// FillRectangleClip is similar to FillRectangle, but it clips the pattern to
|
||||||
|
// a specified rectangle mask. That is—the pattern will be queried as if it
|
||||||
|
// were drawn without the mask, but only the area specified by the intersection
|
||||||
|
// of bounds and mask will be drawn to.
|
||||||
|
func FillRectangleClip (
|
||||||
|
destination canvas.Canvas,
|
||||||
|
source Pattern,
|
||||||
|
bounds image.Rectangle,
|
||||||
|
mask image.Rectangle,
|
||||||
|
) (
|
||||||
|
updatedRegion image.Rectangle,
|
||||||
) {
|
) {
|
||||||
data, stride := destination.Buffer()
|
data, stride := destination.Buffer()
|
||||||
realBounds := bounds
|
realBounds := bounds
|
||||||
bounds = bounds.Canon().Intersect(destination.Bounds()).Canon()
|
bounds =
|
||||||
|
bounds.Canon().
|
||||||
|
Intersect(destination.Bounds()).
|
||||||
|
Intersect(mask)
|
||||||
if bounds.Empty() { return }
|
if bounds.Empty() { return }
|
||||||
updatedRegion = bounds
|
updatedRegion = bounds
|
||||||
|
|
||||||
@ -57,7 +75,6 @@ func FillRectangle (
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 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 (
|
||||||
|
@ -3,6 +3,8 @@ package main
|
|||||||
import "git.tebibyte.media/sashakoshka/tomo"
|
import "git.tebibyte.media/sashakoshka/tomo"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/elements/testing"
|
import "git.tebibyte.media/sashakoshka/tomo/elements/testing"
|
||||||
import _ "git.tebibyte.media/sashakoshka/tomo/backends/x"
|
import _ "git.tebibyte.media/sashakoshka/tomo/backends/x"
|
||||||
|
import _ "net/http/pprof"
|
||||||
|
import "net/http"
|
||||||
|
|
||||||
func main () {
|
func main () {
|
||||||
tomo.Run(run)
|
tomo.Run(run)
|
||||||
@ -14,4 +16,7 @@ func run () {
|
|||||||
window.Adopt(testing.NewArtist())
|
window.Adopt(testing.NewArtist())
|
||||||
window.OnClose(tomo.Stop)
|
window.OnClose(tomo.Stop)
|
||||||
window.Show()
|
window.Show()
|
||||||
|
go func () {
|
||||||
|
http.ListenAndServe("localhost:6060", nil)
|
||||||
|
} ()
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,8 @@ import "git.tebibyte.media/sashakoshka/tomo/layouts/basic"
|
|||||||
import "git.tebibyte.media/sashakoshka/tomo/elements/basic"
|
import "git.tebibyte.media/sashakoshka/tomo/elements/basic"
|
||||||
import "git.tebibyte.media/sashakoshka/tomo/elements/fun/music"
|
import "git.tebibyte.media/sashakoshka/tomo/elements/fun/music"
|
||||||
import _ "git.tebibyte.media/sashakoshka/tomo/backends/x"
|
import _ "git.tebibyte.media/sashakoshka/tomo/backends/x"
|
||||||
|
import _ "net/http/pprof"
|
||||||
|
import "net/http"
|
||||||
|
|
||||||
const sampleRate = 44100
|
const sampleRate = 44100
|
||||||
const bufferSize = 256
|
const bufferSize = 256
|
||||||
@ -147,6 +149,9 @@ func run () {
|
|||||||
piano.Focus()
|
piano.Focus()
|
||||||
window.OnClose(tomo.Stop)
|
window.OnClose(tomo.Stop)
|
||||||
window.Show()
|
window.Show()
|
||||||
|
go func () {
|
||||||
|
http.ListenAndServe("localhost:6060", nil)
|
||||||
|
} ()
|
||||||
}
|
}
|
||||||
|
|
||||||
type Patch struct {
|
type Patch struct {
|
||||||
|
Reference in New Issue
Block a user