From c7e44633b1c8c599be1ef35a7a09ddb48e833e99 Mon Sep 17 00:00:00 2001 From: Sasha Koshka <supergriffin64@gmail.com> Date: Thu, 23 Feb 2023 14:44:54 -0500 Subject: [PATCH] Updated Pattern interface --- artist/pattern.go | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/artist/pattern.go b/artist/pattern.go index ef87caa..d3fce47 100644 --- a/artist/pattern.go +++ b/artist/pattern.go @@ -1,12 +1,16 @@ package artist -import "image/color" +import "image" +import "git.tebibyte.media/sashakoshka/tomo/canvas" -// Pattern is capable of generating a pattern pixel by pixel. +// Pattern is capable of drawing to a canvas within the bounds of a given +// clipping rectangle. type Pattern interface { - // AtWhen returns the color of the pixel located at (x, y) relative to - // the origin point of the pattern (0, 0), when the pattern has the - // specified width and height. Patterns may ignore the width and height - // parameters, but it may be useful for some patterns such as gradients. - AtWhen (x, y, width, height int) (color.RGBA) + // Draw draws to destination, using the bounds of destination as a width + // and height for things like gradients, bevels, etc. The pattern may + // not draw outside the union of destination.Bounds() and clip. The + // clipping rectangle effectively takes a subset of the pattern. To + // change the bounds of the pattern itself, use canvas.Cut() on the + // destination before passing it to Draw(). + Draw (destination canvas.Canvas, clip image.Rectangle) }