Added a new FillRectangleClip function
This commit is contained in:
@@ -36,10 +36,28 @@ func FillRectangle (
|
||||
bounds 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()
|
||||
realBounds := bounds
|
||||
bounds = bounds.Canon().Intersect(destination.Bounds()).Canon()
|
||||
bounds =
|
||||
bounds.Canon().
|
||||
Intersect(destination.Bounds()).
|
||||
Intersect(mask)
|
||||
if bounds.Empty() { return }
|
||||
updatedRegion = bounds
|
||||
|
||||
@@ -57,7 +75,6 @@ func FillRectangle (
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
// StrokeRectangle draws the outline of a rectangle with the specified line
|
||||
// weight and pattern.
|
||||
func StrokeRectangle (
|
||||
|
||||
Reference in New Issue
Block a user