From 48237f5687361bc588599d88083504a6f1c9288c Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Thu, 23 Feb 2023 17:44:53 -0500 Subject: [PATCH] Add AllocateSample --- artist/pattern.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/artist/pattern.go b/artist/pattern.go index b13b7af..2a41d41 100644 --- a/artist/pattern.go +++ b/artist/pattern.go @@ -39,3 +39,13 @@ func DrawBounds ( source.Draw(cut, clip) } } + +// AllocateSample returns a new canvas containing the result of a pattern. The +// resulting canvas can be sourced from shape drawing functions. I beg of you +// please do not call this every time you need to draw a shape with a pattern on +// it because that is horrible and cruel to the computer. +func AllocateSample (source Pattern, width, height int) (allocated canvas.Canvas) { + allocated = canvas.NewBasicCanvas(width, height) + source.Draw(allocated, allocated.Bounds()) + return +}