summaryrefslogtreecommitdiffstats
path: root/virtual-programs/title.folk
blob: a430cc16de25619eefd93ee165a0f27b6ab09161 (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
33
34
35
36
37
38
39
40
41
42
43
44
# Title/footnote wish fulfillment
# for wishes of the form:
# "Wish $tag is titled "This is a tag"" or "Wish $tag is footnoted "This is a footnote""

When /thing/ has region /region/ {
    set radians [region angle $region]

    When the collected matches for [list /someone/ wishes $thing is titled /text/] are /matches/ {
        set text [join [lmap match $matches {dict get $match text}] "\n"]
        if {$text eq ""} { return }
    
        set scale [dict_getdef $match scale 1.0]
        set pos [region top [region move $region up 10px]]
        Wish to draw text with position $pos scale $scale text $text radians $radians anchor bottom
    }

    When the collected matches for [list /someone/ wishes $thing is footnoted /text/] are /matches/ {
        set text [join [lmap match $matches {dict get $match text}] "\n"]
        if {$text eq ""} { return }

        set scale [dict_getdef $match scale 0.75]
        set pos [region bottomleft [region move $region down 20px]]
        Wish to draw text with position $pos scale $scale text $text radians $radians anchor topleft
    }
    
    When the collected matches for [list /someone/ wishes $thing is right-margined /text/] are /matches/ {
        set text [join [lmap match $matches {dict get $match text}] "\n"]
        if {$text eq ""} { return }
    
        set scale [dict_getdef $match scale 0.75]
        set pos [region right [region move $region right 10px]]
        Wish to draw text with position $pos scale $scale text $text radians $radians anchor left
    }

    When the collected matches for [list /someone/ wishes $thing is left-margined /text/] are /matches/ {
        set text [join [lmap match $matches {dict get $match text}] "\n"]
        if {$text eq ""} { return }
    
        set scale [dict_getdef $match scale 0.75]
        set pos [region left [region move $region left 10px]]
        Wish to draw text with position $pos scale $scale text $text radians $radians anchor right
    }
}