From 1f0082feceffdc73532ab6736edc8a750dc85a09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Cuervo?= Date: Sat, 24 Jun 2023 23:47:45 -0400 Subject: Add filled polygons --- virtual-programs/shapes.folk | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) (limited to 'virtual-programs') diff --git a/virtual-programs/shapes.folk b/virtual-programs/shapes.folk index b693220e..25c615c5 100644 --- a/virtual-programs/shapes.folk +++ b/virtual-programs/shapes.folk @@ -3,18 +3,6 @@ set sizeDict [dict create small 1 medium 4 large 10] proc isSizeWord {word} { expr {[lsearch [list small medium large] $word] >= 0} } -proc polyline {points {strokeWeight 5} {color white} args} { - set i 0 - set pointsLength [llength $points] - set PL_less_one [expr {$pointsLength - 1}] - while {$i < $pointsLength} { - if {$i eq $PL_less_one} { return } - set current [lindex $points $i] - incr i - set next [lindex $points $i] - Display::stroke [list $current $next] $strokeWeight $color - } -} proc rectangle {x y w h {strokeWeight 5} {color "white"}} { set start [list $x $y] @@ -26,7 +14,7 @@ proc rectangle {x y w h {strokeWeight 5} {color "white"}} { lappend points [list [expr {$x + $w}] [expr {$y + $h}]] lappend points [list $x [expr {$y + $h}]] lappend points $start - polyline $points $strokeWeight $color + Display::stroke $points $strokeWeight $color } proc square {x y w {strokeWeight 5} {color "white"} args} { @@ -51,7 +39,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 @@ -62,7 +50,11 @@ 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} { + Display::fillPolygon $points $color + } else { + Display::stroke $points 5 $color + } } When /someone/ wishes /p/ draws a /color/ /shape/ offset /offsetVector/ & /p/ has region /r/ { @@ -76,8 +68,6 @@ When /someone/ wishes /p/ draws a /color/ /shape/ offset /offsetVector/ & /p/ ha set y [expr {$y + $offsetY}] } - puts "drawing $shape at $x $y" - set adjustedWidth [expr {$width * 0.25}] set x [expr { $x * 1.3}] set y [expr { $y * 1.25}] -- cgit v1.2.3 From 62325ce503b8f47c5fe8f80dae3198bdeb119853 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Cuervo?= Date: Mon, 26 Jun 2023 16:00:28 -0400 Subject: Left-align labels, watch for .folk.temp files --- virtual-programs/label.folk | 7 +++++++ virtual-programs/tags-and-calibration.folk | 12 +++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) (limited to 'virtual-programs') diff --git a/virtual-programs/label.folk b/virtual-programs/label.folk index 30787555..d18bdd02 100644 --- a/virtual-programs/label.folk +++ b/virtual-programs/label.folk @@ -4,10 +4,17 @@ When /thing/ has region /region/ { set width [boxWidth $bbox] set height [boxHeight $bbox] + set radians [lindex $region 2] if {$radians eq ""} {set radians 0} set upsidedown [expr {abs($radians) < 1.57}] + if ($upsidedown) { + set x [expr {$x + $width * 0.4}] + set y [expr {$y - $height * 0.2}] + } else { + set x [expr {$x - $width * 0.4}] + } if {$::isLaptop} {set upsidedown false} When the collected matches for [list /someone/ wishes $thing is labelled /text/] are /matches/ { diff --git a/virtual-programs/tags-and-calibration.folk b/virtual-programs/tags-and-calibration.folk index c624614a..f3155612 100644 --- a/virtual-programs/tags-and-calibration.folk +++ b/virtual-programs/tags-and-calibration.folk @@ -79,9 +79,15 @@ When (non-capturing) tag /tag/ has center /c/ size /size/ { When (non-capturing) tag /tag/ is a tag { puts "Added tag $tag" - set fp [open "$::env(HOME)/folk-printed-programs/$tag.folk" r] - set code [read $fp] - close $fp + set tempPath "$::env(HOME)/folk-printed-programs/$tag.folk.temp" + + if {[file exists $tempPath]} { + set path [open "$::env(HOME)/folk-printed-programs/$tag.folk.temp" r] + } else { + set path [open "$::env(HOME)/folk-printed-programs/$tag.folk" r] + } + set code [read $path] + close $path # Wish $tag is outlined green Claim $tag has program code $code -- cgit v1.2.3 From 7de278406eb1488f5bee5e12337de6443cf4c371 Mon Sep 17 00:00:00 2001 From: Omar Rizwan Date: Mon, 10 Jul 2023 13:10:34 -0400 Subject: Hack to prevent multiple whiskers intersecting --- virtual-programs/points-at.folk | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'virtual-programs') diff --git a/virtual-programs/points-at.folk b/virtual-programs/points-at.folk index b0937495..773d42b3 100644 --- a/virtual-programs/points-at.folk +++ b/virtual-programs/points-at.folk @@ -4,16 +4,16 @@ When when /rect/ points /direction/ at /someone/ /lambda/ with environment /e/ { When /someone/ wishes /rect/ points /direction/ & /rect/ has region /region/ { if {$direction eq "up"} { - set whiskerRegion [region move [region scale $region width 0.01px] up 50%] + set whiskerRegion [region move [region scale $region width 0.01px] up 51%] set color blue } elseif {$direction eq "left"} { - set whiskerRegion [region move [region scale $region height 0.01px] left 50%] + set whiskerRegion [region move [region scale $region height 0.01px] left 51%] set color red } elseif {$direction eq "right"} { - set whiskerRegion [region move [region scale $region height 0.01px] right 50%] + set whiskerRegion [region move [region scale $region height 0.01px] right 51%] set color green } elseif {$direction eq "down"} { - set whiskerRegion [region move [region scale $region width 0.01px] down 50%] + set whiskerRegion [region move [region scale $region width 0.01px] down 51%] set color white } set whisker [list $rect whisker $direction] -- cgit v1.2.3