summaryrefslogtreecommitdiffstats
path: root/virtual-programs
diff options
context:
space:
mode:
authorCristobal Sciutto <cristobal.sciutto@gmail.com>2023-06-02 19:11:23 +0000
committerCristobal Sciutto <cristobal.sciutto@gmail.com>2023-06-02 19:11:23 +0000
commita01ce95ff3e6cb3b32079bcfef05bc26904978fe (patch)
tree0249286d015fcbcae2bed619b580bcc4c0c3c04b /virtual-programs
parent& instead of nest (diff)
parentMerge pull request #30 from FolkComputer/osnr/c-evaluator (diff)
downloadfolk-a01ce95ff3e6cb3b32079bcfef05bc26904978fe.tar.gz
folk-a01ce95ff3e6cb3b32079bcfef05bc26904978fe.zip
merge master
Diffstat (limited to 'virtual-programs')
-rw-r--r--virtual-programs/label.folk2
-rw-r--r--virtual-programs/tags-and-calibration.folk45
2 files changed, 22 insertions, 25 deletions
diff --git a/virtual-programs/label.folk b/virtual-programs/label.folk
index 58eccc40..002eeca5 100644
--- a/virtual-programs/label.folk
+++ b/virtual-programs/label.folk
@@ -28,7 +28,7 @@ When /thing/ has region /region/ {
}
}
-proc text {coords text angle} {
+fn text {coords text angle} {
Display::text Display::fb [lindex $coords 0] [lindex $coords 1] 2 $text $angle
}
diff --git a/virtual-programs/tags-and-calibration.folk b/virtual-programs/tags-and-calibration.folk
index d6c4fad7..0d52edf7 100644
--- a/virtual-programs/tags-and-calibration.folk
+++ b/virtual-programs/tags-and-calibration.folk
@@ -71,14 +71,14 @@ proc ::projectorToCamera {projectorPoint} {
}
# Wish $this is highlighted white
-Say when tag /tag/ has center /c/ size /size/ {
+When (non-capturing) tag /tag/ has center /c/ size /size/ {
Claim tag $tag is a tag
- lassign [cameraToProjector $c] px py
+ lassign [::cameraToProjector $c] px py
Claim $tag is a rectangle with x [expr $px-20] y [expr $py-10] width [expr $size*2] height [expr $size*2]
-} with environment {}
+}
-When tag /tag/ is a tag {
+When (non-capturing) tag /tag/ is a tag {
puts "Added tag $tag"
set fp [open "$::env(HOME)/folk-printed-programs/$tag.folk" r]
@@ -90,24 +90,21 @@ When tag /tag/ is a tag {
}
-Say when tag /tag/ has corners /corners/ {
- set tagcorners [lmap p $corners {cameraToProjector $p}]
- #foreach tagcorner $tagcorners { Display::text fb {*}$tagcorner 10 "$tag" }
- Display::fillQuad {*}$tagcorners white
- set tagbottom [sub [lindex $tagcorners 1] [lindex $tagcorners 0]]
- set tagright [sub [lindex $tagcorners 2] [lindex $tagcorners 1]]
-
- set offsets {{-4.7 -3.5} {1 -3.5} {1 0.8} {-4.7 0.8}}
- set corners [add $tagcorners [matmul $offsets [list $tagbottom $tagright]]]
- set edges [list]
- for {set i 0} {$i < [llength $corners]} {incr i} {
- if {$i > 0} { lappend edges [list [expr {$i - 1}] $i] }
- }
- lappend edges [list [expr {[llength $corners] - 1}] 0]
- set region [list $corners $edges [::tcl::mathfunc::atan2 {*}$tagright]]
- Claim $tag has region $region
-} with environment {
- %matmul ::math::linearalgebra::matmul
- %sub ::math::linearalgebra::sub
- %add ::math::linearalgebra::add
+When (non-capturing) tag /tag/ has corners /corners/ {
+ set tagcorners [lmap p $corners {::cameraToProjector $p}]
+ # foreach tagcorner $tagcorners { Display::text fb {*}$tagcorner 10 "$tag" }
+ Display::fillQuad {*}$tagcorners white
+
+ set tagbottom [sub [lindex $tagcorners 1] [lindex $tagcorners 0]]
+ set tagright [sub [lindex $tagcorners 2] [lindex $tagcorners 1]]
+
+ set offsets {{-4.7 -2.6} {1 -2.6} {1 0.8} {-4.7 0.8}}
+ set corners [add $tagcorners [matmul $offsets [list $tagbottom $tagright]]]
+ set edges [list]
+ for {set i 0} {$i < [llength $corners]} {incr i} {
+ if {$i > 0} { lappend edges [list [expr {$i - 1}] $i] }
+ }
+ lappend edges [list [expr {[llength $corners] - 1}] 0]
+ set region [list $corners $edges [::tcl::mathfunc::atan2 {*}$tagright]]
+ Claim $tag has region $region
}