summaryrefslogtreecommitdiff
path: root/chickadee/graphics/sprite.scm
diff options
context:
space:
mode:
Diffstat (limited to 'chickadee/graphics/sprite.scm')
-rw-r--r--chickadee/graphics/sprite.scm130
1 files changed, 0 insertions, 130 deletions
diff --git a/chickadee/graphics/sprite.scm b/chickadee/graphics/sprite.scm
index 0d6f838..8ab12f9 100644
--- a/chickadee/graphics/sprite.scm
+++ b/chickadee/graphics/sprite.scm
@@ -365,133 +365,3 @@ may be specified via the TEXTURE-REGION argument."
#:rotation rotation
#:scale scale)
(draw-sprite-batch* batch matrix #:blend-mode blend-mode)))
-
-
-;;;
-;;; Nine Patches
-;;;
-
-(define draw-nine-patch*
- (let ((%rect (make-rect 0.0 0.0 0.0 0.0))
- (texcoords (make-rect 0.0 0.0 0.0 0.0)))
- (lambda* (texture
- rect
- matrix
- #:key
- (margin 0.0)
- (top-margin margin)
- (bottom-margin margin)
- (left-margin margin)
- (right-margin margin)
- (blend-mode blend:alpha)
- (tint white))
- (let* ((x (rect-x rect))
- (y (rect-y rect))
- (w (rect-width rect))
- (h (rect-height rect))
- (border-x1 x)
- (border-y1 y)
- (border-x2 (+ x w))
- (border-y2 (+ y h))
- (fill-x1 (+ border-x1 left-margin))
- (fill-y1 (+ border-y1 bottom-margin))
- (fill-x2 (- border-x2 right-margin))
- (fill-y2 (- border-y2 top-margin))
- (prect (texture-gl-rect texture))
- (trect (texture-gl-tex-rect texture))
- (tw (rect-width prect))
- (th (rect-height prect))
- (border-s1 (rect-x trect))
- (border-t1 (rect-y trect))
- (border-s2 (+ (rect-x trect) (rect-width trect)))
- (border-t2 (+ (rect-y trect) (rect-height trect)))
- (fill-s1 (+ border-s1 (/ left-margin tw)))
- (fill-t1 (+ border-t1 (/ top-margin th)))
- (fill-s2 (- border-s2 (/ right-margin tw)))
- (fill-t2 (- border-t2 (/ bottom-margin th))))
- (define (draw-piece x1 y1 x2 y2 s1 t1 s2 t2)
- (set-rect-x! %rect x1)
- (set-rect-y! %rect y1)
- (set-rect-width! %rect (- x2 x1))
- (set-rect-height! %rect (- y2 y1))
- (set-rect-x! texcoords s1)
- (set-rect-y! texcoords t1)
- (set-rect-width! texcoords (- s2 s1))
- (set-rect-height! texcoords (- t2 t1))
- (draw-sprite* texture %rect matrix
- #:texcoords texcoords
- #:blend-mode blend-mode
- #:tint tint))
- ;; bottom-left
- (draw-piece border-x1 border-y1 fill-x1 fill-y1
- border-s1 fill-t2 fill-s1 border-t2)
- ;; bottom-center
- (draw-piece fill-x1 border-y1 fill-x2 fill-y1
- fill-s1 fill-t2 fill-s2 border-t2)
- ;; bottom-right
- (draw-piece fill-x2 border-y1 border-x2 fill-y1
- fill-s2 fill-t2 border-s2 border-t2)
- ;; center-left
- (draw-piece border-x1 fill-y1 fill-x1 fill-y2
- border-s1 fill-t2 fill-s1 fill-t1)
- ;; center
- (draw-piece fill-x1 fill-y1 fill-x2 fill-y2
- fill-s1 fill-t2 fill-s2 fill-t1)
- ;; center-right
- (draw-piece fill-x2 fill-y1 border-x2 fill-y2
- fill-s2 fill-t2 border-s2 fill-t1)
- ;; top-left
- (draw-piece border-x1 fill-y2 fill-x1 border-y2
- border-s1 border-t1 fill-s1 fill-t1)
- ;; top-center
- (draw-piece fill-x1 fill-y2 fill-x2 border-y2
- fill-s1 border-t1 fill-s2 fill-t1)
- ;; top-right
- (draw-piece fill-x2 fill-y2 border-x2 border-y2
- fill-s2 border-t1 border-s2 fill-t1)))))
-
-(define draw-nine-patch
- (let ((position (vec2 0.0 0.0))
- (%rect (make-rect 0.0 0.0 0.0 0.0))
- (matrix (make-null-matrix4)))
- (lambda* (texture
- rect
- #:key
- (margin 0.0)
- (top-margin margin) (bottom-margin margin)
- (left-margin margin) (right-margin margin)
- (origin %null-vec2)
- (rotation 0.0)
- (scale %default-scale)
- (blend-mode blend: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
-stretched, the left and right edges may be stretched vertically, the
-top and bottom edges may be stretched horizontally, and the center may
-be stretched in both directions. This rendering technique is
-particularly well suited for resizable windows and buttons in
-graphical user interfaces.
-
-MARGIN specifies the margin size for all sides of the nine patch. To
-make margins of differing sizes, the TOP-MARGIN, BOTTOM-MARGIN,
-LEFT-MARGIN, and RIGHT-MARGIN arguments may be used."
- (set-rect-x! %rect 0.0)
- (set-rect-y! %rect 0.0)
- (set-rect-width! %rect (rect-width rect))
- (set-rect-height! %rect (rect-height rect))
- (set-vec2-x! position (rect-x rect))
- (set-vec2-y! position (rect-y rect))
- (matrix4-2d-transform! matrix
- #:origin origin
- #:position position
- #:rotation rotation
- #:scale scale)
- (draw-nine-patch* texture %rect matrix
- #:top-margin top-margin
- #:bottom-margin bottom-margin
- #:left-margin left-margin
- #:right-margin right-margin
- #:blend-mode blend-mode
- #:tint tint))))