diff options
| author | Omar Rizwan <omar@omar.website> | 2022-11-07 22:07:01 +0000 |
|---|---|---|
| committer | Omar Rizwan <omar@omar.website> | 2022-11-07 22:07:18 +0000 |
| commit | a7ae511906f7fbfe0c41a4ac2750d1a92ad7ff1d (patch) | |
| tree | eb4bf0a255b1be66d50de41b34c8de2a0fbc14b5 /virtual-programs | |
| parent | Fix other colors on NUC display (diff) | |
| download | folk-a7ae511906f7fbfe0c41a4ac2750d1a92ad7ff1d.tar.gz folk-a7ae511906f7fbfe0c41a4ac2750d1a92ad7ff1d.zip | |
Move to using regions and outlining
instead of axis-aligned rectangles and highlighting
Diffstat (limited to 'virtual-programs')
| -rw-r--r-- | virtual-programs/archive/highlight.folk (renamed from virtual-programs/highlight.folk) | 4 | ||||
| -rw-r--r-- | virtual-programs/label.folk | 9 | ||||
| -rw-r--r-- | virtual-programs/outline.folk | 14 | ||||
| -rw-r--r-- | virtual-programs/tags-and-calibration.folk | 13 |
4 files changed, 31 insertions, 9 deletions
diff --git a/virtual-programs/highlight.folk b/virtual-programs/archive/highlight.folk index ad19b86c..d4206622 100644 --- a/virtual-programs/highlight.folk +++ b/virtual-programs/archive/highlight.folk @@ -1,7 +1,7 @@ Wish $this has filename "highlight.folk" -When /someone/ wishes /rect/ is highlighted /color/ { - When $rect is a rectangle with x /x/ y /y/ width /width/ height /height/ { +When /someone/ wishes /thing/ is highlighted /color/ { + When $thing has region /region/ { # it's not really correct to just stick a side-effect in the # When handler like this. but we did it in Realtalk, and it # was ok, so whatever for now diff --git a/virtual-programs/label.folk b/virtual-programs/label.folk index 26b3f7ef..2c2ef0f0 100644 --- a/virtual-programs/label.folk +++ b/virtual-programs/label.folk @@ -1,7 +1,12 @@ Wish $this has filename "label.folk" -When /someone/ wishes /rect/ is labelled /text/ { - When $rect is a rectangle with x /x/ y /y/ width /width/ height /height/ { +When /someone/ wishes /thing/ is labelled /text/ { + When $thing has region /region/ { + set bbox [regionToBbox $region] + lassign [boxCentroid $bbox] x y + set width [boxWidth $bbox] + set height [boxHeight $bbox] + set lines [split $text "\n"] set longestLineLength [tcl::mathfunc::max {*}[lmap line $lines {string length $line}]] set fontSize [expr {$width / $longestLineLength}] diff --git a/virtual-programs/outline.folk b/virtual-programs/outline.folk new file mode 100644 index 00000000..a4ca20a5 --- /dev/null +++ b/virtual-programs/outline.folk @@ -0,0 +1,14 @@ +Wish $this has filename "outline.folk" + +When /someone/ wishes /thing/ is outlined /color/ { + When $thing has region /region/ { + # FIXME: assumes path + lassign $region vertices edges + foreach edge $edges { + set from [lindex $vertices [lindex $edge 0]] + set to [lindex $vertices [lindex $edge 1]] + Display::stroke [list $from $to] 2 $color + } + } +} + diff --git a/virtual-programs/tags-and-calibration.folk b/virtual-programs/tags-and-calibration.folk index b1975bc5..03f3eeaa 100644 --- a/virtual-programs/tags-and-calibration.folk +++ b/virtual-programs/tags-and-calibration.folk @@ -62,16 +62,19 @@ When tag /tag/ is a tag { set code [read $fp] close $fp - Wish $tag is highlighted green + Wish $tag is outlined green Claim $tag has program code $code } When tag /tag/ has corners /corners/ { set corners [lmap p $corners {cameraToProjector $p}] - # Display::stroke [list {*}$corners [lindex $corners 0]] 2 green - foreach corner $corners { - lassign $corner x y - # Display::fillRect fb $x $y [expr $x+10] [expr $y+10] white + set edges [list] + for {set i 0} {$i < [llength $corners]} {incr i} { + lassign [lindex $corners $i] x y Display::text fb $x $y 10 $tag + if {$i > 0} { lappend edges [list [expr {$i - 1}] $i] } } + lappend edges [list [expr {[llength $corners] - 1}] 0] + set region [list $corners $edges] + Claim $tag has region $region } |
