summaryrefslogtreecommitdiff
path: root/starling
diff options
context:
space:
mode:
Diffstat (limited to 'starling')
-rw-r--r--starling/kernel.scm44
-rw-r--r--starling/minibuffer.scm12
-rw-r--r--starling/node-2d.scm37
-rw-r--r--starling/repl.scm10
4 files changed, 59 insertions, 44 deletions
diff --git a/starling/kernel.scm b/starling/kernel.scm
index db78932..e302df1 100644
--- a/starling/kernel.scm
+++ b/starling/kernel.scm
@@ -29,6 +29,7 @@
#:use-module (chickadee graphics color)
#:use-module (chickadee graphics font)
#:use-module (chickadee graphics gpu)
+ #:use-module (chickadee graphics path)
#:use-module (chickadee graphics viewport)
#:use-module (chickadee math rect)
#:use-module (chickadee math vector)
@@ -85,23 +86,24 @@
(box-width (+ (font-line-width font "60.0")
(* padding 2.0)))
(box-height (+ (font-line-height font) (* padding 2.0))))
- (match (current-window-size)
- ((_ window-height)
- (attach-to canvas
- (make <filled-rect>
- #:region (make-rect 0.0
- (- window-height box-height)
- box-width
- box-height)
- #:color (make-color 0.0 0.0 0.0 0.5))
- (make <label>
- #:name 'fps-label
- #:rank 9
- #:text "60.0"
- #:font font
- #:position (vec2 padding
- (+ (- window-height box-height)
- padding))))))
+ (call-with-values current-window-size
+ (lambda (window-width window-height)
+ (attach-to canvas
+ (make <path>
+ #:painter (with-style ((fill-color (make-color 0 0 0 0.5)))
+ (fill
+ (rectangle (vec2 0.0
+ (- window-height box-height))
+ box-width
+ box-height))))
+ (make <label>
+ #:name 'fps-label
+ #:rank 9
+ #:text "60.0"
+ #:font font
+ #:position (vec2 padding
+ (+ (- window-height box-height)
+ padding))))))
(attach-to fps-display canvas)))
(define-method (update-fps (fps-display <fps-display>) fps)
@@ -116,7 +118,7 @@
(define-class <window-config> ()
(width #:accessor window-width #:init-form 640 #:init-keyword #:width)
(height #:accessor window-height #:init-form 480 #:init-keyword #:height)
- (title #:accessor window-title #:init-form "Lisparuga"
+ (title #:accessor window-title #:init-form "Starling"
#:init-keyword #:title)
(fullscreen? #:accessor window-fullscreen? #:init-form #f
#:init-keyword #:fullscreen?))
@@ -210,9 +212,9 @@
(define (invert-y y)
;; SDL's origin is the top-left, but our origin is the bottom
;; left so we need to invert Y coordinates that SDL gives us.
- (match (sdl2:window-size (window kernel))
- ((_ height)
- (- height y))))
+ (call-with-values (lambda () (sdl2:window-size (window kernel)))
+ (lambda (width height)
+ (- height y))))
(define (process-event event)
(cond
((quit-event? event)
diff --git a/starling/minibuffer.scm b/starling/minibuffer.scm
index 690445f..2515604 100644
--- a/starling/minibuffer.scm
+++ b/starling/minibuffer.scm
@@ -23,6 +23,7 @@
(define-module (starling minibuffer)
#:use-module (chickadee graphics color)
#:use-module (chickadee graphics font)
+ #:use-module (chickadee graphics path)
#:use-module (chickadee math rect)
#:use-module (chickadee math vector)
#:use-module (chickadee scripting)
@@ -92,11 +93,12 @@
(line-height (font-line-height font))
(padding 8.0))
(attach-to minibuffer
- (make <filled-rect>
- #:region (make-rect 0.0 0.0
- (vec2-x res)
- (+ line-height (* padding 2.0)))
- #:color (make-color 0.0 0.0 0.0 0.7))
+ (make <path>
+ #:painter (with-style ((fill-color (make-color 0 0 0 0.7)))
+ (fill
+ (rectangle (vec2 0.0 0.0)
+ (vec2-x res)
+ (+ line-height (* padding 2.0))))))
(make <label>
#:name 'text-entry
#:rank 9
diff --git a/starling/node-2d.scm b/starling/node-2d.scm
index 142da31..6d83da2 100644
--- a/starling/node-2d.scm
+++ b/starling/node-2d.scm
@@ -31,7 +31,7 @@
#:use-module (chickadee graphics font)
#:use-module (chickadee graphics framebuffer)
#:use-module (chickadee graphics particles)
- #:use-module (chickadee graphics shapes)
+ #:use-module (chickadee graphics path)
#:use-module (chickadee graphics sprite)
#:use-module (chickadee graphics texture)
#:use-module (chickadee graphics tiled)
@@ -99,9 +99,8 @@
<sprite-batch>
batch
- <filled-rect>
- region
- color
+ <path>
+ painter
<label>
font
@@ -123,13 +122,13 @@
;; node and follow it around.
(define (default-resolution)
- (match (current-window-size)
- ((width height)
- (vec2 width height))))
+ (call-with-values current-window-size
+ (lambda (width height)
+ (vec2 width height))))
(define (default-viewport)
- (match (current-window-size)
- ((width height)
+ (call-with-values current-window-size
+ (lambda (width height)
(make-viewport 0 0 width height))))
(define-class <camera-2d> ()
@@ -533,15 +532,23 @@
;;;
-;;; Filled Rectangle
+;;; Vector Path
;;;
-(define-class <filled-rect> (<node-2d>)
- (region #:accessor region #:init-keyword #:region)
- (color #:accessor color #:init-form black #:init-keyword #:color))
+(define-class <path> (<node-2d>)
+ (painter #:accessor painter #:init-keyword #:painter)
+ (canvas #:accessor canvas #:init-thunk make-empty-canvas))
-(define-method (render (r <filled-rect>) alpha)
- (draw-filled-rect (region r) (color r) #:matrix (world-matrix r)))
+(define-method (initialize (path <path>) args)
+ (next-method)
+ (set-canvas-painter! (canvas path) (painter path)))
+
+(define-method ((setter painter) (path <path>) p)
+ (slot-set! path 'painter p)
+ (set-canvas-painter! (canvas path) p))
+
+(define-method (render (path <path>) alpha)
+ (draw-canvas* (canvas path) (world-matrix path)))
;;;
diff --git a/starling/repl.scm b/starling/repl.scm
index 7c05cb6..66139ed 100644
--- a/starling/repl.scm
+++ b/starling/repl.scm
@@ -24,6 +24,7 @@
#:use-module (chickadee array-list)
#:use-module (chickadee graphics color)
#:use-module (chickadee graphics font)
+ #:use-module (chickadee graphics path)
#:use-module (chickadee math rect)
#:use-module (chickadee math vector)
#:use-module (chickadee scripting)
@@ -157,9 +158,12 @@
#:vertical-align 'top))
(iota nlines))))
(attach-to repl
- (make <filled-rect>
- #:region (make-rect 0.0 0.0 (vec2-x res) (vec2-y res))
- #:color (make-color 0.0 0.0 0.0 0.7))
+ (make <path>
+ #:painter (with-style ((fill-color (make-color 0 0 0 0.7)))
+ (fill
+ (rectangle (vec2 0.0 0.0)
+ (vec2-x res)
+ (vec2-y res)))))
(make <label>
#:rank 9
#:name 'prompt