From 0ba3c982c4264a5dd11aa4aca8e03e519925b078 Mon Sep 17 00:00:00 2001
From: Sasha Koshka <supergriffin64@gmail.com>
Date: Thu, 23 Feb 2023 15:00:44 -0500
Subject: [PATCH] Added some utility functions to pattern

---
 artist/pattern.go | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/artist/pattern.go b/artist/pattern.go
index d3fce47..b13b7af 100644
--- a/artist/pattern.go
+++ b/artist/pattern.go
@@ -14,3 +14,28 @@ type Pattern interface {
 	// destination before passing it to Draw().
 	Draw (destination canvas.Canvas, clip image.Rectangle)
 }
+
+// Draw lets you use several clipping rectangles to draw a pattern.
+func Draw (
+	destination canvas.Canvas,
+	source      Pattern,
+	clips       ...image.Rectangle,
+) {
+	for _, clip := range clips {
+		source.Draw(destination, clip)
+	}
+}
+
+// DrawBounds is like Draw, but lets you specify an overall bounding rectangle
+// for the pattern. The destination is cut to this rectangle.
+func DrawBounds (
+	destination canvas.Canvas,
+	bounds      image.Rectangle,
+	source      Pattern,
+	clips       ...image.Rectangle,
+) {
+	cut := canvas.Cut(destination, bounds)
+	for _, clip := range clips {
+		source.Draw(cut, clip)
+	}
+}