summaryrefslogtreecommitdiff
path: root/examples/9-patch.scm
blob: 1fa5b85cac61c90df48867d04a5b36f8609d123a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
(use-modules (chickadee)
             (chickadee math rect)
             (chickadee math vector)
             (chickadee graphics 9-patch)
             (chickadee graphics sprite)
             (chickadee graphics text)
             (chickadee graphics texture))

(define texture #f)
(define sprite1 #f)
(define sprite2 #f)
(define area1 (make-rect 192.0 192.0 256.0 96.0))
(define area2 (make-rect 192.0 50.0 256.0 96.0))
(define text-position (vec2 204.0 266.0))

(define (load)
  (set! texture (texture-view (load-image "images/dialog-box.png")))
  (set! sprite1 (make-sprite texture (make-rect 0.0 0.0 78.0 39.0)))
  (set! sprite2 (make-sprite texture (make-rect 78.0 0.0 41.0 18.0))))

(define (draw alpha)
  (draw-9-patch sprite1 area1 #:margin 7.0)
  (draw-9-patch sprite2 area2 #:margin 4.0)
  (draw-text "This is the 9-patch test." text-position))

(run-game #:load load #:draw draw)