diff options
| author | Andrés Cuervo <andrescuervor@gmail.com> | 2023-09-20 22:06:03 +0000 |
|---|---|---|
| committer | Andrés Cuervo <andrescuervor@gmail.com> | 2023-09-20 22:06:03 +0000 |
| commit | 686f55e24da346622df4eb32faebaa60cd1fa066 (patch) | |
| tree | 767c9b6f6fe222547106aabfab47c4f5eb230348 /virtual-programs | |
| parent | Merge branch 'main' into osnr/operation-log (diff) | |
| parent | Orient images to their pages (diff) | |
| download | folk-686f55e24da346622df4eb32faebaa60cd1fa066.tar.gz folk-686f55e24da346622df4eb32faebaa60cd1fa066.zip | |
Merge branch 'main' into osnr/operation-log
Diffstat (limited to 'virtual-programs')
| -rw-r--r-- | virtual-programs/sprites.folk | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/virtual-programs/sprites.folk b/virtual-programs/sprites.folk new file mode 100644 index 00000000..0e4fc87e --- /dev/null +++ b/virtual-programs/sprites.folk @@ -0,0 +1,32 @@ +######## +# Could extend this to draw from camera with: +# Wish $this has thumbnail grid with 8 frames and 4 columns +# When $this has thumbnail grid /thumbnails/ { +# Wish $this draws $thumbnails; # Would need to query $thumnails for its frameCount and columns +# } +####### + +# - path get prepended with ~/folk-images/ +When /anyone/ wishes /p/ draws sprite /path/ with /frameCount/ frames and /columns/ columns { + set im [image load $path] + set sheetwidth [image width $im] + set sheetHeight [image height $im] + set spriteWidth [/ $sheetwidth $columns] + set rows [/ $frameCount $columns] + set spriteHeight [/ $sheetHeight $rows] + + When the clock time is /t/ & $p has region /r/ { + set frameNumber [expr {round ($t * 60 / $columns) % $frameCount}] + set x [* [% $frameNumber $columns] $spriteWidth] + set y [* [% $frameNumber $rows] $spriteHeight] + + set subimage [image subimage $im $x $y $spriteWidth $spriteHeight] + set center [region centroid $r] + set angle [region angle $r] + Wish display runs [list Display::image {*}$center $subimage $angle 1] + } +} + +Claim $this has demo { + Wish $this draws sprite $path with 8 frames and 4 columns +} |
