aboutsummaryrefslogtreecommitdiff
path: root/virtual-programs/label.folk
blob: 88a86c183ed292c4793f22803f723880cf6a804f (plain) (blame)
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
When /thing/ has region /region/ {
    lassign [region centroid $region] x y
    set radians [region angle $region]

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

        Wish to draw text with x $x y $y text $text radians $radians font [dict get $match font]
    }
}

When /someone/ wishes /thing/ is labelled /text/ {
  # Set the default font
  Wish $thing is labelled $text with font "PTSans-Regular"
}

fn text {coords text angle} {
  Display::text [lindex $coords 0] [lindex $coords 1] 2 $text $angle
}

When /anyone/ wishes /p/ has halo message /message/ & /p/ has region /r/ {
  lassign [lindex $r 0] a b c d
  set angle [region angle $r]
  lassign $a x y
  text [list [lindex $a 0] [expr {[lindex $a 1] - 50}]] $message $angle
  text [list [lindex $d 0] [expr {[lindex $d 1] + 50}]] $message [+ 3.1415 $angle]
}