diff options
author | Thomas White <taw@physics.org> | 2022-06-06 18:41:46 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2022-06-06 18:41:46 +0200 |
commit | b3d3bc0dff448514d172020e25227f5a1c1ef14e (patch) | |
tree | 7f108f02b9e83cb18e23cd42a9f92e34c5f06e8b /guile/starlet | |
parent | 066cd46f297ffbf32b02de11c132f092b6abb10a (diff) |
Rename state-map to state-map->list, add a real state-map
Diffstat (limited to 'guile/starlet')
-rw-r--r-- | guile/starlet/cue-list.scm | 5 | ||||
-rw-r--r-- | guile/starlet/state.scm | 30 |
2 files changed, 26 insertions, 9 deletions
diff --git a/guile/starlet/cue-list.scm b/guile/starlet/cue-list.scm index 1b6c269..db11716 100644 --- a/guile/starlet/cue-list.scm +++ b/guile/starlet/cue-list.scm @@ -95,8 +95,9 @@ (define (fix-attrs-in-state state) - (state-map (lambda (fix attr val) (cons fix attr)) - state)) + (state-map->list + (lambda (fix attr val) (cons fix attr)) + state)) (define (add-fix-attrs-to-list state old-list) diff --git a/guile/starlet/state.scm b/guile/starlet/state.scm index 86e871e..bf0fc0a 100644 --- a/guile/starlet/state.scm +++ b/guile/starlet/state.scm @@ -33,6 +33,7 @@ lighting-state? get-state-name state-for-each + state-map->list state-map copy-state clear-state! @@ -258,7 +259,7 @@ (extract-colour-component col attr)))) -(define (state-map func state) +(define (state-map->list func state) (hash-map->list (lambda (key value) (func (car key) (cdr key) @@ -266,6 +267,21 @@ (atomic-box-ref (get-ht-box state)))) +(define (state-map func state) + (let ((out-state (make-empty-state))) + (hash-for-each + (lambda (key value) + (set-in-state! + out-state + (car key) + (cdr key) + (func (car key) + (cdr key) + value))) + (atomic-box-ref (get-ht-box state))) + out-state)) + + (define (apply-state state) "Apply the contents of 'state' to the current state, on top of the \ pre-existing contents." @@ -323,12 +339,12 @@ pre-existing contents." (define (state-source a) (cons 'lighting-state - (state-map (lambda (fix attr val) - (list 'at - (get-fixture-name fix) - (list 'quote attr) - (clamp-to-attr-range fix attr val))) - a))) + (state-map->list (lambda (fix attr val) + (list 'at + (get-fixture-name fix) + (list 'quote attr) + (clamp-to-attr-range fix attr val))) + a))) ;; Coerce something from a state object into a number for scanout |