help

(help define-actor)
(help!)                 ; quick reference
(list-commands)
(tutorial)

keyboard shortcuts

eval line

shift+enter

eval block

ctrl+enter

toggle control window

ctrl+p

print help for word under cursor

ctrl+h

animations

(assets-path)
(assets-path-set! "user://assets/animations")        ; default
(assets-path-set! "/home/you/Documents/animations")  ; MacOS + Linux
(assets-path-set! "C:/Projects/Animations")          ; Windows
(list-assets)   ; available on disk ready to load
(define-animation some-anim)            ; folder named "some-anim" in the assets folder
(define-animation my-anim "other-anim") ; load "other-anim" but name it 'my-animation'
(list-animations)                       ; loaded to memory

actors

add / remove

(define-actor foo some-anim)	        ; create an actor with a name + loaded animation
(define-actor foo some-anim LAYER_2)	; add to group (LAYER_1-4, BG, FG)
(actor-find "foo")		                ; returns the actor object by NAME
(actor-remove! foo)
(list-actors)		                    ; prints actor names
(animation! foo "another-animation")    ; change the animation

play/stop

(play! foo)
(play-backwards! foo)
(stop! foo)
(speed! foo 0.5)
(loop! foo)		; loop an ACTOR's animation
(noloop! foo)       ; play an ACTOR's animation once and stop at the last frame
(pingpong! foo)     ; play an ACTOR's animation back and forth
(frame! foo 3)
(next-frame! foo)
(start-frame! foo 2)        ; loop's first frame
(end-frame! foo 4)          ; loop's last frame
(play-range! foo 2 4)

color

(color! foo COLOR-RED)
(color! foo (make-color 1 0 0))
(color! foo (make-color 1 0 0 0.5)) ; with opacity
(color-r! foo 0.5)
(color-g! foo 0.7)
(color-b! foo 0.1)
(color-rgb! foo 1 0 0)
(color-rgb! foo 1 0 0 0.5)  ; with opacity
(opacity! foo 0.2)
(fade-out! foo 3)       ; seconds
(fade-in! foo 2)
(fade-in! foo 1 0.5)    ; opacity other than 1
(list-colors)
(define COLOR-MY-BEAUTIFUL-BLUE (make-color 1.0 0.3 0.45)) ; add a custom color

show / hide

(show! foo)
(hide! foo)
(opacity! foo 0.2)

rotate

(angle! foo 45)
(rotate! foo 10)    ; relative (run several times to see the effect)

transform

(size! foo 0.5)
(position! actor 0.7 0.2)   ; normalized coords (0-1).
                            ; XY = 0 0 = top-lef
                            ; XY = 1 1 = bottom-right
(center! foo)
(move! foo 0.1 -0.2)    ; relative to the current position
(move-x! foo -0.3)
(move-y! foo 250)
(move-up! foo 0.1)
(move-down! foo 0.2)
(move-left! foo 0.3)
(move-right! foo 0.4)
(offset! foo 0.1 0)   ; offset the animation relative to the actor's center
(offset-x! foo -0.1)
(offset-y! foo 0.3)
(flip-h! foo)
(flip-v! foo)

parenting

(define-actor bar "my-animation")
(add-child! foo bar)    ; parent + child
(remove-child! bar)     ; only the child is needed

text

(text! foo "write text on foo")     ; write text on actor
(text-visible-characters! foo 3)
(text-visible-ratio! foo 0.5)       ; ratio of visible characters
(text-color! foo COLOR-YELLOW)

arrange

(front! foo bar)    ; move foo in front of bar
(behind! foo bar)   ; move foo behind bar

fx

(mask! foo bar)             ; bar is mask
(blend-multiply! foo 1)     ; 0, 1
(blend-add! foo 1)          ; 0-1 (or more for aberrations)
(color-invert! foo 1)
(color-to-alpha! foo COLOR-WHITE)
(color-to-alpha! foo COLOR-WHITE 0.5)       ; with similarity tolerance
(color-to-alpha! foo COLOR-WHITE 0.8)       ; 0 disable, 1 full, >1 disappear

tweening

(tween! foo "x" 500.0 1.0)      ; actor, target-value, time linear, default ease
(tween! foo "opacity" 0.0 2.0 TRANS_SINE)          ; custom transition
(tween! foo "y" 300.0 1.0 TRANS_BOUNCE EASE_OUT)   ; full control
(tween! foo "size" 1 4 TRANS-BOUNCE)
(tween! foo "color" COLOR-PURE-RED 4)
(list-transitions)
(list-ease-types)

speech bubbles

(say! my-bubble "say something first..." "...and then something else")
(set! *speech-bubble-showing-time-per-word* 0.1)   ; and say again

groups

(group-add! g foo)      ; add 'foo' to the group 'g'
(group-remove! g foo)
(group-set! g "color" COLOR-RED-PURE)
(group-call g "rotate" 10)
(all)                   ; get all the objects
(any)                   ; get any object
(all g)                 ; get all the objects in G
(any-from g)            ; get any object in G
(map (lambda (n) (offset-x! n (random 1.0))) (all))
; batch create group 'zee with 10 zee-NN actors, starting with zee-00
(define-many-actors 'zee 10 some-anim)

routines

(define-routine
    my-routine                  ; name of the routine
    5                           ; repeats (INF = -1 = forever)
    0.5                         ; interval between repeats (seconds)
    (lambda (tick)              ; proc - `tick` is a counter of calls
        (displayln tick)))
; in one line
(define-routine my-routine 5 0.5 (lambda (tick) (displayln tick)))
(define-routine my-routine INF 0.5 (lambda (tick) (displayln tick)))
(routine-stop! my-routine)
(list-routines)

schedule

(schedule
    2.0                                             ; delay (seconds)
    (lambda () (displayln "fired once after 2s")))  ; proc
(schedule 2.0 (lambda () (displayln "hello")))                  ; one-shot
(make-timer 1.0 (lambda () (displayln "tick")) #t)                  ; one-shot
(define t (make-timer 1.0 (lambda () (displayln "tick")) #f))       ; repeating
(timer-stop! t)
(timer-start! t)

fx

(fx-mix! 1)                     ; 0-1
(fx-feedback! 0.8)              ; 0-1 (or more for aberrations)
(fx-feedback-offset-x! 0.05)    ; 0±1: negative left, positive right
(fx-feedback-offset-y! -0.05)   ; 0±1: positive up, negative down
(fx-feedback-scale! -0.01)      ; 0±1: 0 original size, positive scale up, negative scale down
(fx-noise! -0.2)                ; 0±1: 0 no noise, positive add, negative subtract
(fx-invert! 1)                  ; anything other than 0 (with feedback flashes a lot!)

window

(window-fullscreen!)
(window-windowed!)
(window-width)              ; pixels
(window-height)
(window-center-width)
(window-center-height)
(window-size-set! 1920 1080)
(control-window-show!)
(control-window-hide!)

editor

(editor-set! "(displayln \"replace text\")")
(editor-append! "(displayln \"add text\")")
(editor-clear!)

control window

(control-window-show!)
(control-window-hide!)

osc

(osc-send "127.0.0.1" 9000 "/trigger" 1 "foo" 3.2) ; ip port addr args ...

receiving OSC on port 56101

(define (bla . args) (message args))  ; simple receiver for OSC message
(osc-add-input-command! "/bla" bla)    ; call `bla` from OSC
(list-osc-input-commands)             ; already added

logging

(log-level-set! LOG-DEBUG)   ; set verbosity (FATAL, ERROR, WARNING, INFO, VERBOSE, DEBUG)
(log-info "hello")           ; log-fatal, log-error, log-warn, log-info, log-verbose, log-debug

utils

(vec x y . z)   ; floats
(veci x y . z)  ; ints
(random-range 0 100)                ; min, max
(coin 0.5)                          ; 0 = always #f, 1 = always #t
(load "/path/to/file.scm")          ; load scheme file and evaluate it - this is not an addition
(displayln "hello")                 ; print with a line break
(display-list "one" "two" "three")  ; prints elements in different lines
(filter odd? '(1 2 3 4))            ; => (1 3)
(hash-table-keys my-table)          ; returns the list of keys in the hash-table (dictionary)
(hash-table-has-key? my-table 'my-key)
(hash-table-remove! my-table 'my-key)
(degrees-to-radians 90)
(list-find "my-*")          ; '*' = any number of characters, '?' = any ONE character
(find-defined "COLOR-*")    ; search defined symbols with a wildcard
(choose '(0 1 2 3))         ; choose one of ...
(choosen 10 '(0 1 2 3))     ; choose 10 of ...
(series 10 0 0.1)           ; size, start, step
(range 10 20)               ; min, max

scheme basics

(+ 1 2)                             ; use PREFIX notation

; define a variable named MY-VARIABLE and assing a string to it
(define my-variable "value")

; define a function named MY-FUNC with one required ARG and any number of OPTIONAL arguments
(define (my-func arg . optional)
    (display "arg: ")
    (display arg)
    (newline)
    (display "opt: ")
    (display optional))

(my-func "with" "some" "args")      ; call function with 3 args

(lambda () (display "a lambda was called")) ; anonymous function that is called immediately
                                            ; and doesn't have a name (so we can't call it
                                            ; again). You can put lambdas as arguments of
                                            ; other procedures if you want to evaluate
                                            ; something before passing it as an argument

my-variable                     ; no parenthesis, returns the variable value
'(0 1 2 3)                      ; list - notice leading apostrophe (no tailing one)
'my-symbol                      ; symbol - notice the leading apostrophe (no tailing one)
"this is a string"              ; double quotes, can contain spaces
*my-global*                     ; global variable
MY-CONSTANT                     ; SHOULD NOT be changed
(my-setter! ...)                ; `!` means it changes the state of something
(my-predicate? ...)             ; `?` means it returns a boolean that can be checked against the args