blob: 48f8a1b1d32273caf8fd751efa23c9026f3d192b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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 to draw an image with center $center image $subimage radians $angle
}
}
Claim $this has demo {
Wish $this draws sprite $path with 8 frames and 4 columns
}
|