Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
9864b19
Don't add confusing params to config example, tweak params too
smj-edison Feb 7, 2025
8d21f81
Add bidirectional editor support
smj-edison Feb 11, 2025
89dfad0
Make saving work from webpage
smj-edison Feb 11, 2025
bcaa8cc
Merge pull request #194 from smj-edison/main
osnr Feb 20, 2025
5b0c0d5
Add support for groups
smj-edison Feb 11, 2025
89661cc
Remove unneeded code
smj-edison Feb 21, 2025
5e5657f
Merge pull request #199 from smj-edison/bidirectional-web-editor
cwervo Feb 21, 2025
1d7abf8
Add exposure slider to /calibrate and exposure wish to camera.folk
osnr Feb 24, 2025
a30c545
calibrate: Max out exposure at 2x 60Hz; hold the wish properly
osnr Feb 24, 2025
83cc155
claibrate: Show live exposure value; restore autoexposure on unmatch
osnr Feb 25, 2025
718f31f
calibrate: Update troubleshooting section
osnr Feb 25, 2025
75325d1
Add auto refresh, linked exposure number input
cwervo Feb 25, 2025
204730a
Merge pull request #200 from FolkComputer/osnr/camera-usb-set-exposure
cwervo Feb 25, 2025
4e0d50f
Fix shape rotation relative to parent region
cwervo Mar 3, 2025
f894082
Fix var clashing and clean-up shape functions
cwervo Mar 3, 2025
2b9c697
Add rect shifting
cwervo Mar 3, 2025
cb8245d
Use region utils, refactor shape drawing options
cwervo Mar 3, 2025
3a6aea9
Shape syntax simplified, made shifting easier
cwervo Mar 3, 2025
8732ec0
Fix single object "draw shape" typo in shapes.folk
cwervo Mar 7, 2025
2b8ae03
Add point and polyline drawing to shapes
cwervo Mar 10, 2025
99cd4d0
Add points & polyline; format shapes.folk
cwervo Mar 11, 2025
c385aae
Standardize on angle and thickness for shape args
cwervo Mar 13, 2025
20b54bd
Refactor shapes to use offsets simplify structure
cwervo Mar 13, 2025
add6b0e
Remove conflicting When
cwervo Mar 13, 2025
077517c
Merge pull request #198 from smj-edison/groups-without-other-commits
osnr Mar 14, 2025
431a0e5
Merge pull request #201 from FolkComputer/ac/shapes-tune-up
osnr Mar 14, 2025
911003d
Add wishes page draws text
rooprob Apr 24, 2025
33b4a92
wish highlights region
rooprob Apr 28, 2025
5db94b2
PR
rooprob Apr 28, 2025
d95d9b6
fix compile
rooprob Apr 28, 2025
853b8a4
renable laser.folk
rooprob Apr 28, 2025
be1ac8c
Merge pull request #203 from rooprob/rooprob/shapes-text
cwervo Apr 29, 2025
ef39fc0
Add overridable angle to text wishes
cwervo Apr 29, 2025
bb9f2ff
Merge pull request #205 from rooprob/rooprob/blobdetection
cwervo Apr 30, 2025
e81a2a5
Use options dictionary defaults strategy
cwervo Apr 30, 2025
6f13e0e
Merge pull request #204 from rooprob/rooprob/more-regions
cwervo Apr 30, 2025
65b154e
Update /keyboards layout
cwervo May 1, 2025
937f4f0
laser: Disable laser blob detection by default
osnr May 1, 2025
f7bd9c0
fix esc-pos geom file
ppkn May 3, 2025
39d9c6b
Wrap geom in braces
ppkn May 3, 2025
09f8152
Merge pull request #206 from FolkComputer/dpip/esc-pos-geom-fix
osnr May 3, 2025
bcf097d
Add anchor option to relative text
smj-edison May 12, 2025
61a9e5a
Also add font as a parameter
smj-edison May 13, 2025
5a700e7
Merge pull request #207 from smj-edison/add-anchor-option-to-relative…
cwervo May 15, 2025
3e17eae
Change default size for reciept printer
ppkn May 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix var clashing and clean-up shape functions
Additional improvements:
- Streamlined shape generation logic
- Ensured consistent parameter handling
- Added proper width parameter support for shape outlines
  • Loading branch information
cwervo committed Mar 3, 2025
commit f894082d06b2cef7f6b33b5b02cbd912ccfbbf3c
52 changes: 28 additions & 24 deletions virtual-programs/shapes.folk
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# sides 2 => line
# sides 3 => triangle
# sides 4 => square
# Dictionary mapping shape names to number of sides
set shapes [dict create triangle 3 square 4 pentagon 5 hexagon 6 \
septagon 7 octagon 8 nonagon 9]

# Core shape drawing function - creates regular polygons
When /someone/ wishes to draw a shape with /...options/ {
set numPoints [dict get $options sides]
set c [dict get $options center]
Expand All @@ -9,24 +11,24 @@ When /someone/ wishes to draw a shape with /...options/ {
set color [dict_getdef $options color white]
set filled [dict_getdef $options filled false]
set layer [dict_getdef $options layer 0]
set width [dict_getdef $options width 1]

set p [list 0 0]
set center $p
set centerPoint $p
set points [list $p]

set incr [expr {2 * 3.14159 / $numPoints}]
set a [expr {$incr + 3.14159}]
for {set i 0} {$i < $numPoints} {incr i} {
set p [vec2 add $p [vec2 scale [list [expr {cos($a)}] [expr {sin($a)}]] $r]]
lappend points $p
# Accumulate center
set center [vec2 add $center $p]
set centerPoint [vec2 add $centerPoint $p]
set a [expr {$a + $incr}]
}
set center [vec2 scale $center [expr {1.0/$numPoints}]]
set centerPoint [vec2 scale $centerPoint [expr {1.0/$numPoints}]]

set points [lmap v $points {
set v [vec2 sub $v $center]
set v [vec2 sub $v $centerPoint]
set v [vec2 rotate $v $radians]
set v [vec2 add $v $c]
set v
Expand All @@ -35,61 +37,63 @@ When /someone/ wishes to draw a shape with /...options/ {
if {$filled} {
Wish to draw a polygon with points $points color $color layer $layer
} else {
Wish to draw a stroke with points $points width 1 color $color layer $layer
Wish to draw a stroke with points $points width $width color $color layer $layer
}
}

set shapes [dict create triangle 3 square 4 pentagon 5 hexagon 6 \
septagon 7 octagon 8 nonagon 9]
When /someone/ wishes /p/ draws a /shape/ {
# TODO: This is a hack because rest pattern doesn't match empty
# sequence at end.
Wish $p draws a $shape with color white
}
When /someone/ wishes /p/ draws an /shape/ { Wish $p draws a $shape }

When /someone/ wishes /p/ draws an /shape/ {
Wish $p draws a $shape
}

When /someone/ wishes /p/ draws a /shape/ with /...options/ & /p/ has region /r/ {
# Get the region's properties
lassign [region centroid $r] cx cy
set angle [region angle $r]

set width [region width $r]
set height [region height $r]
# Extract parameters
set radius [dict_getdef $options radius 50]
set color [dict_getdef $options color white]
set filled [dict_getdef $options filled false]
set thickness [dict_getdef $options thickness 5]
set layer [dict_getdef $options layer 0]

# Rotate offset vector by region's angle for consistent positioning
lassign [dict_getdef $options offset {0 0}] offsetX offsetY
set rawOffset [list $offsetX $offsetY]

set rotatedOffset [vec2 rotate $rawOffset $angle]
set rotatedOffset [vec2 rotate [list $offsetX $offsetY] $angle]

# Calculate final center position
set finalCenter [vec2 add [list $cx $cy] $rotatedOffset]

# Draw appropriate shape
if {$shape eq "circle"} {
Wish to draw a circle with \
center $finalCenter radius $radius thickness $thickness \
color $color filled $filled layer $layer
} elseif {[dict exists $shapes $shape]} {
Wish to draw a shape with sides [dict get $shapes $shape] \
center $finalCenter radius $radius radians $angle \
color $color filled $filled layer $layer
color $color filled $filled width $thickness layer $layer
} else {
Wish to draw a shape with sides 2 \
center $finalCenter radius $radius radians $angle \
color $color filled $filled layer $layer
color $color filled $filled width $thickness layer $layer
}
}

When /someone/ wishes /p/ draws an /shape/ with /...options/ {
Wish $p draws a $shape with {*}$options
}

Claim $this has demo {
Wish $this draws a circle
Wish $this draws a triangle with color skyblue
Wish $this draws a triangle with color green offset {280 0}
Wish $this draws a pentagon with color gold offset {200 0}
Wish $this draws an octagon with color red offset {250 80}
Wish $this draws a triangle with color green offset {-280 0}
Wish $this draws a pentagon with color gold offset {-200 0}
Wish $this draws an octagon with color magenta offset {-250 80}

When the clock time is /t/ {
set offsetVector [list [sin $t] [cos $t]]
Expand Down