From c42b3b404c15491a2032a0e11cef83e39b3470e3 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Tue, 8 Jan 2019 21:51:16 -0500 Subject: render: sprite: Allow nine patches to be tinted. * chickadee/render/sprite.scm (draw-nine-patch*, draw-nine-patch): Add tint keyword argument. * doc/api.texi (Sprites): Document new argument. --- chickadee/render/sprite.scm | 12 ++++++++---- doc/api.texi | 3 ++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/chickadee/render/sprite.scm b/chickadee/render/sprite.scm index 6b6cf2a..708cc78 100644 --- a/chickadee/render/sprite.scm +++ b/chickadee/render/sprite.scm @@ -434,7 +434,8 @@ BLEND-MODE." (bottom-margin margin) (left-margin margin) (right-margin margin) - (blend-mode 'alpha)) + (blend-mode 'alpha) + (tint white)) (let* ((x (rect-x rect)) (y (rect-y rect)) (w (rect-width rect)) @@ -470,7 +471,8 @@ BLEND-MODE." (set-rect-height! texcoords (- t2 t1)) (draw-sprite* texture %rect matrix #:texcoords texcoords - #:blend-mode blend-mode)) + #:blend-mode blend-mode + #:tint tint)) (with-batched-sprites ;; bottom-left (draw-piece border-x1 border-y1 fill-x1 fill-y1 @@ -513,7 +515,8 @@ BLEND-MODE." (origin %null-vec2) (rotation 0.0) (scale %default-scale) - (blend-mode 'alpha)) + (blend-mode 'alpha) + (tint white)) "Draw a \"nine patch\" sprite. A nine patch sprite renders TEXTURE on the rectangular area RECT whose stretchable areas are defined by the given margin measurements. The corners are never @@ -542,4 +545,5 @@ LEFT-MARGIN, and RIGHT-MARGIN arguments may be used." #:bottom-margin bottom-margin #:left-margin left-margin #:right-margin right-margin - #:blend-mode blend-mode)))) + #:blend-mode blend-mode + #:tint tint)))) diff --git a/doc/api.texi b/doc/api.texi index fc1f8dd..6669b5f 100644 --- a/doc/api.texi +++ b/doc/api.texi @@ -1411,7 +1411,8 @@ artifacts. @deffn {Procedure} draw-nine-patch @var{texture} @var{rect} @ [#:margin 0] [#:top-margin margin] [#:bottom-margin margin] @ [#:left-margin margin] [#:right-margin margin] @ - [#:origin] [#:scale] [#:rotation] [#:blend-mode alpha] + [#:origin] [#:scale] [#:rotation] [#:blend-mode alpha] @ + [#:tint white] Draw a nine patch sprite. A nine patch sprite renders @var{texture} as a @var{width} x @var{height} rectangle whose stretchable areas are -- cgit v1.2.3