From c7f6843ea2dfe31dbd4e3edfd09e5ad230e2af24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Cuervo?= Date: Mon, 3 Apr 2023 13:17:40 -0400 Subject: Add circle to pi Display, center shapes correctly --- virtual-programs/shapes.folk | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) (limited to 'virtual-programs') diff --git a/virtual-programs/shapes.folk b/virtual-programs/shapes.folk index 176f765b..f5bbaf41 100644 --- a/virtual-programs/shapes.folk +++ b/virtual-programs/shapes.folk @@ -40,11 +40,10 @@ proc regionToInnerRect {region} { lassign $vertices a b c d lassign $a aX aY lassign $c cX cY - set shrinkConstant 0.65 - set width [expr {($cX - $aX) * $shrinkConstant}] - set height [expr {($cY - $aY) * $shrinkConstant}] - set x [expr {$aX + $width * 0.25}] - set y [expr {$aY + $height * 0.25}] + set width [expr {($cX - $aX)}] + set height [expr {($cY - $aY)}] + set x [expr {$aX + $width * 0.5}] + set y [expr {$aY + $height * 0.5}] return [list $x $y $width $height] } @@ -53,7 +52,7 @@ proc regionToInnerRect {region} { # numPoints 2 => line # numPoints 3 => triangle # numPoints 4 => square -proc shape {numPoints x y r {color white} args} { +proc shape {numPoints x y r {color white} {filled false} args} { set start [list $x $y] set points [list $start] set i 0 @@ -64,13 +63,18 @@ proc shape {numPoints x y r {color white} args} { set y [expr {$y + $r * sin($angle)}] lappend points [list $x $y] } - polyline $points 5 $color + if {$filled} { + polyline $points 5 $color + } else { + polyline $points 10 $color + } } When /someone/ wishes /p/ draws a /color/ /shape/ offset /offsetVector/ & /p/ has region /r/ { lassign [regionToInnerRect $r] x y width height lassign $offsetVector offsetX offsetY - + + set filled false if {$offsetX != 0} { set x [expr {$x + $offsetX}] } @@ -81,21 +85,22 @@ When /someone/ wishes /p/ draws a /color/ /shape/ offset /offsetVector/ & /p/ ha puts "drawing $shape at $x $y" set adjustedWidth [expr {$width * 0.25}] - set x [expr { $x * 1.3}] - set y [expr { $y * 1.25}] + set x [expr { $x + $offsetX}] + set y [expr { $y + $offsetY}] + switch -nocase $shape { triangle { - shape 3 $x $y $adjustedWidth $color + shape 3 $x $y $adjustedWidth $color $filled } square { - shape 4 $x $y $adjustedWidth $color + shape 4 $x $y $adjustedWidth $color $filled } # TODO: cwervo - fix magic numbers here circle { - shape 10 [expr {$x * 0.98}] $y [expr {$adjustedWidth * 0.4}] $color + shape 10 [expr {$x * 0.98}] $y [expr {$adjustedWidth * 0.4}] $color $filled } default { - shape 5 $x $y $adjustedWidth $color + shape 5 $x $y $adjustedWidth $color $filled } } } @@ -112,4 +117,4 @@ When /someone/ wishes /p/ draws a /shape/ offset /offsetVector/ { Wish $p draws a white $shape offset $offsetVector } -# --- TODO: Wish table has ... ---- \ No newline at end of file +# --- TODO: Wish table has ... ---- -- cgit v1.2.3 From 217dc9121284cc8b07b1c4f53fa07fe4cfee2104 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Cuervo?= Date: Mon, 3 Apr 2023 13:23:07 -0400 Subject: Thin out default shapes --- virtual-programs/shapes.folk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'virtual-programs') diff --git a/virtual-programs/shapes.folk b/virtual-programs/shapes.folk index f5bbaf41..f5c913aa 100644 --- a/virtual-programs/shapes.folk +++ b/virtual-programs/shapes.folk @@ -64,9 +64,9 @@ proc shape {numPoints x y r {color white} {filled false} args} { lappend points [list $x $y] } if {$filled} { - polyline $points 5 $color - } else { polyline $points 10 $color + } else { + polyline $points 2 $color } } -- cgit v1.2.3 From a448849ad16b9857aa5f315283e184a5b2ef8bd3 Mon Sep 17 00:00:00 2001 From: Omar Rizwan Date: Sun, 23 Apr 2023 01:41:27 -0400 Subject: Don't project id onto tag corners. Works in the dark! --- virtual-programs/tags-and-calibration.folk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'virtual-programs') diff --git a/virtual-programs/tags-and-calibration.folk b/virtual-programs/tags-and-calibration.folk index dd0622be..531ed087 100644 --- a/virtual-programs/tags-and-calibration.folk +++ b/virtual-programs/tags-and-calibration.folk @@ -92,7 +92,7 @@ When tag /tag/ is a tag { When tag /tag/ has corners /corners/ { set tagcorners [lmap p $corners {cameraToProjector $p}] - foreach tagcorner $tagcorners { Display::text fb {*}$tagcorner 10 "$tag" } + #foreach tagcorner $tagcorners { Display::text fb {*}$tagcorner 10 "$tag" } set tagbottom [sub [lindex $tagcorners 1] [lindex $tagcorners 0]] set tagright [sub [lindex $tagcorners 2] [lindex $tagcorners 1]] -- cgit v1.2.3 From 5d28f7b6b3bfd48bc9b8710b0c4f215fc8cdbe61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Cuervo?= Date: Mon, 24 Apr 2023 15:11:47 -0400 Subject: Add halo message --- virtual-programs/label.folk | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'virtual-programs') diff --git a/virtual-programs/label.folk b/virtual-programs/label.folk index 52bfae11..036e8752 100644 --- a/virtual-programs/label.folk +++ b/virtual-programs/label.folk @@ -23,3 +23,17 @@ When /thing/ has region /region/ { } } } + +proc text {coords text angle} { + Display::text Display::fb [lindex $coords 0] [lindex $coords 1] _ $text $angle +} + +When /anyone/ wishes /p/ has halo message /message/ { + When $p has region /r/ { + lassign [lindex $r 0] a b c d + lassign $a x y + text $a $message 0 + text $d $message 180 + Wish $this is labelled TEST + } +} \ No newline at end of file -- cgit v1.2.3 From a7063b5672e2e152faa979837d72b744520bdece Mon Sep 17 00:00:00 2001 From: Omar Rizwan Date: Mon, 24 Apr 2023 18:20:59 -0400 Subject: Some moderate performance improvements from the C branch Reduce scope that's carried into critical-path Whens, don't evaluate Display commit twice --- virtual-programs/tags-and-calibration.folk | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'virtual-programs') diff --git a/virtual-programs/tags-and-calibration.folk b/virtual-programs/tags-and-calibration.folk index 531ed087..bc39033e 100644 --- a/virtual-programs/tags-and-calibration.folk +++ b/virtual-programs/tags-and-calibration.folk @@ -71,12 +71,12 @@ proc ::projectorToCamera {projectorPoint} { } # Wish $this is highlighted white -When tag /tag/ has center /c/ size /size/ { +Say when tag /tag/ has center /c/ size /size/ { Claim tag $tag is a tag 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 { puts "Added tag $tag" @@ -90,7 +90,7 @@ When tag /tag/ is a tag { } -When tag /tag/ has corners /corners/ { +Say when tag /tag/ has corners /corners/ { set tagcorners [lmap p $corners {cameraToProjector $p}] #foreach tagcorner $tagcorners { Display::text fb {*}$tagcorner 10 "$tag" } set tagbottom [sub [lindex $tagcorners 1] [lindex $tagcorners 0]] @@ -105,4 +105,8 @@ When tag /tag/ has corners /corners/ { 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 } -- cgit v1.2.3