Existing shape routines have been reimplemented

This commit is contained in:
Sasha Koshka 2023-02-24 02:26:34 -05:00
parent d167559830
commit 79ab1c8ac0
4 changed files with 128 additions and 142 deletions

View File

@ -1,6 +1,6 @@
// Package shapes provides some basic shape drawing routines. // Package shapes provides some basic shape drawing routines.
// //
// A word about patterns: // A word about using patterns with shape routines:
// //
// Most drawing routines have a version that samples from other canvases, and a // Most drawing routines have a version that samples from other canvases, and a
// version that samples from a solid color. None of these routines can use // version that samples from a solid color. None of these routines can use

View File

@ -3,19 +3,25 @@ package shapes
import "math" import "math"
import "image" import "image"
import "image/color" import "image/color"
import "git.tebibyte.media/sashakoshka/tomo/artist" // import "git.tebibyte.media/sashakoshka/tomo/artist"
import "git.tebibyte.media/sashakoshka/tomo/canvas" import "git.tebibyte.media/sashakoshka/tomo/canvas"
// FillEllipse draws a filled ellipse with the specified pattern. // FillEllipse draws the content of one canvas onto another, clipped by an
// ellipse stretched to the bounds of the source canvas. The offset point
// defines where the origin point of the source canvas is positioned in relation
// to the origin point of the destination canvas. To prevent the entire source
// canvas's bounds from being used, it must be cut with canvas.Cut().
func FillEllipse ( func FillEllipse (
destination canvas.Canvas, destination canvas.Canvas,
source artist.Pattern, source canvas.Canvas,
bounds image.Rectangle, offset image.Point,
) ( ) (
updatedRegion image.Rectangle, updatedRegion image.Rectangle,
) { ) {
bounds = bounds.Canon() dstData, dstStride := destination.Buffer()
data, stride := destination.Buffer() srcData, srcStride := source.Buffer()
bounds := source.Bounds()
realWidth, realHeight := bounds.Dx(), bounds.Dy() realWidth, realHeight := bounds.Dx(), bounds.Dy()
bounds = bounds.Intersect(destination.Bounds()).Canon() bounds = bounds.Intersect(destination.Bounds()).Canon()
if bounds.Empty() { return } if bounds.Empty() { return }