summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--guix.scm8
-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
5 files changed, 63 insertions, 48 deletions
diff --git a/guix.scm b/guix.scm
index 41901fc..f6380cd 100644
--- a/guix.scm
+++ b/guix.scm
@@ -90,7 +90,7 @@
(invoke "autoreconf" "-vfi")))))))))
(define guile-sdl2
- (let ((commit "1b7cdecf240859baa497f10215f3ebf72ec46963"))
+ (let ((commit "ed821d76b70a1454285d415dfae7db9394c535f2"))
(package
(name "guile-sdl2")
(version (string-append "0.5.0-1." (string-take commit 7)))
@@ -101,7 +101,7 @@
(commit commit)))
(sha256
(base32
- "1rpxbpfxz3lan70lcfmi1kbapsjnj52s6vy6p0bqj7way6535sq6"))))
+ "1kh3hzf2lmpf773hbxzb0g7c0ghqydp9s969sigg58l8wbr85iyf"))))
(build-system gnu-build-system)
(arguments
'(#:make-flags '("GUILE_AUTO_COMPILE=0")
@@ -128,7 +128,7 @@ SDL2 C shared library via the foreign function interface.")
(license license:lgpl3+))))
(define chickadee
- (let ((commit "5ff661f1e191ce486000b727d6c979779e24efe8"))
+ (let ((commit "5610b6a4a23855680d0d105b85f35a79d4015124"))
(package
(name "chickadee")
(version (string-append "0.5.0-1." (string-take commit 7)))
@@ -139,7 +139,7 @@ SDL2 C shared library via the foreign function interface.")
(commit commit)))
(sha256
(base32
- "1fr22ilnvxld4npsvdw79gsgnhn8a8rl7g0bd5kp3bqz7ldy5d43"))))
+ "0kki4lr5qbirikfa3axdn330iczzxczf67vmizl6xj7pkgk0kxgv"))))
(build-system gnu-build-system)
(arguments
'(#:make-flags '("GUILE_AUTO_COMPILE=0")
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