summaryrefslogtreecommitdiffstats
path: root/virtual-programs
diff options
context:
space:
mode:
authorAndrés Cuervo <andrescuervor@gmail.com>2023-09-20 22:06:03 +0000
committerAndrés Cuervo <andrescuervor@gmail.com>2023-09-20 22:06:03 +0000
commit686f55e24da346622df4eb32faebaa60cd1fa066 (patch)
tree767c9b6f6fe222547106aabfab47c4f5eb230348 /virtual-programs
parentMerge branch 'main' into osnr/operation-log (diff)
parentOrient images to their pages (diff)
downloadfolk-686f55e24da346622df4eb32faebaa60cd1fa066.tar.gz
folk-686f55e24da346622df4eb32faebaa60cd1fa066.zip
Merge branch 'main' into osnr/operation-log
Diffstat (limited to 'virtual-programs')
-rw-r--r--virtual-programs/sprites.folk32
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
+}