Revive drawing capabilities (new and improved!)#261
Conversation
| lassign $center cx cy | ||
| set points [list] | ||
| for {set i 0} {$i < $sides} {incr i} { | ||
| set theta [expr {$radians + $i * 2.0 * 3.141592653589793 / $sides - 1.5707963267948966}] |
There was a problem hiding this comment.
I'm slightly surprised that there's no PI (or TAU) constants. Only slightly surprised though.
There was a problem hiding this comment.
Oh yeah, I should definitely just expose PI and Tau globals
|
I plan to test this out on my system today. |
ppkn
left a comment
There was a problem hiding this comment.
This looks good. The drawSpaceLib api feels a little clunky always having to pass poselib and display. I wonder if there is a cleaner way we could do that in the future.
I wrote a small way to preview all of the drawing demos every 2 seconds so I could quickly preview them. It didn't work for shapes.folk though so I had to check that out separately.
When the clock time is /t/ {
set demos {arc circle curve dashed-line fill image line shapes space text}
set i $(int($t)/2 % [llength $demos])
set demo [lindex $demos $i]
Wish $this runs demo code from builtin-programs/draw/${demo}.folk
}
Wish $this is outlined white23d2434 to
e5e18de
Compare
7833d2c to
201c035
Compare
b48d29f to
7056a3e
Compare
…s overhaul - Replaces old CPU-based connection arrows with high-performance Vulkan shaders - Animates dynamic connections natively using injected GPU float time - Overhauls basic shapes, polygons, arcs, and curves to use GPU canvases - Fixes various drawing pipeline memory bounds corruption bugs - Reorganizes the builtin-programs/draw module - Adds forgiving error handlers to prevent terminal UI log spam from malformed syntax
7056a3e to
2282866
Compare
|
Finally going to merge this, it's looking very stable on folk-convivial: folk_shapes_may_29_2026.mp4(Will address bringing back connections.folk and resolving the issues in terminal/terminal-ui.folk in future PRs) |
|
Can you hold off on merging until I can review? Way too many deep changes here for me to be comfortable landing it
…On Fri, May 29, 2026, at 7:41 PM, Andrés Cuervo wrote:
*cwervo* left a comment (FolkComputer/folk#261) <#261 (comment)>
Finally going to merge this, it's looking very stable on folk-convivial:
https://github.com/user-attachments/assets/0cbe158b-4208-4547-999d-ca80ee7ec8ac
(Will address bringing back connections.folk and resolving the issues in terminal/terminal-ui.folk in future PRs)
—
Reply to this email directly, view it on GitHub <#261?email_source=notifications&email_token=AAAXUWKKRDTF5Z6CJLYYEPT45INY3A5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTINJYGA3DQMJXGY3KM4TFMFZW63VQOJSXM2LFO5PXEZLROVSXG5DFMSSWK5TFNZ2KYZTPN52GK4S7MNWGSY3L#issuecomment-4580681766>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AAAXUWNUICAOHPQXBHRYCU345INY3AVCNFSM6AAAAACYT3FNYWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHM2DKOBQGY4DCNZWGY>.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS <https://github.com/notifications/mobile/ios/AAAXUWIRV363ICFY2SC4PXD45INY3A5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTINJYGA3DQMJXGY3KM4TFMFZW63VQOJSXM2LFO5PXEZLROVSXG5DFMSSWK5TFNZ2KUZTPN52GK4S7NFXXG> and Android <https://github.com/notifications/mobile/android/AAAXUWKTQBK5J7ZV4MSSUA345INY3A5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTINJYGA3DQMJXGY3KM4TFMFZW63VQOJSXM2LFO5PXEZLROVSXG5DFMSSWK5TFNZ2K4ZTPN52GK4S7MFXGI4TPNFSA>. Download it today!
You are receiving this because your review was requested.Message ID: ***@***.***>
|
|
@osnr yes, of course! Happy to wait for your review — thanks! |
| layer $layer | ||
| } | ||
|
|
||
| Hold! -on builtin-programs/draw/apriltags.folk -key draw-apriltags-demo-code \ |
There was a problem hiding this comment.
You should just do Claim $this has demo code ... here -- you definitely shouldn't be using Hold! or spelling out the file path.
(in fact, I don't think you should need to use Hold! at all in this entire PR, since it's all purely functional drawing code?)
There was a problem hiding this comment.
(and this comment applies to all the demo code in the PR, none of them should use Hold!)
| width $outlineWidth color $color layer $layer | ||
| } | ||
|
|
||
| When /thing/ has resolved geometry /geom/ &\ |
There was a problem hiding this comment.
This stuff is really ugly:
I would rather standardize on one variant (even if we have to break compatibility) and/or add some syntax sugar (maybe so one handler can deal with both with and non-with variants?) than have all of this stuff all over the codebase -- it's very low-information-density and hard to read.
| // mostly for debugging: | ||
| char* description; | ||
|
|
||
| // Image-wish cache metadata. Cached textures stay resident after the |
| } | ||
|
|
||
| When /someone/ wishes /program/ runs demo code from /filename/ { | ||
| Hold! -key "active-demo-$program" Claim $program running demo code from $filename |
There was a problem hiding this comment.
shouldn't need to use Hold! ; also not a proper English sentence
| # network, or broadcasting out, and getting pages from | ||
| # there. | ||
| exec curl --output "$saveDir/$obj.folk" \ | ||
| exec curl -f --output "$saveDir/$obj.folk" \ |
There was a problem hiding this comment.
good addition -- can you document what this fixes? were we not properly faulting?
| @@ -1,4 +1,5 @@ | |||
| # Manage terminal UI for Folk. | |||
| return; # TODO: FIXME | |||
There was a problem hiding this comment.
I would rather let this error out
| @@ -1,4 +1,5 @@ | |||
| # Terminal | |||
| return; # TODO: FIXME | |||
There was a problem hiding this comment.
I would rather let this error out
| // Will be NULL if not running in an Atomically | ||
| // convergence-tracking subgraph. | ||
| AtomicallyVersion* _Atomic atomicallyVersion; | ||
| _Atomic bool isAtomicallyRootMatch; |
There was a problem hiding this comment.
What bug does this fix? / why do we need this?
| lldb -o "process handle -p true -s false SIGUSR1" -- ./folk; \ | ||
| else \ | ||
| DEBUGINFOD_URLS="" gdb -ex "handle SIGUSR1 nostop" -ex "handle SIGPIPE nostop" ./folk; \ | ||
| gdb -ex "handle SIGUSR1 nostop" -ex "handle SIGPIPE nostop" ./folk; \ |
There was a problem hiding this comment.
Why was this removed? The debuginfod suppression is there because it would hang in gdb on accessing it for me (can add a comment about that)
| fi | ||
|
|
||
| FOLK_REMOTE_NODE ?= folk-live | ||
| FOLK_SYNC_IGNORES ?= $(shell git rev-parse --git-path ignores.tmp 2>/dev/null || printf '%s\n' .git/ignores.tmp) |
| fn drawLabelDefaultScale {text} { | ||
| set maxLength [drawLabelMaxLineLength $text] | ||
| if {$maxLength == 0} { return 0.02 } | ||
| ::math::min 0.02 [/ 0.45 $maxLength] |
There was a problem hiding this comment.
would be better style to use explicit return
| ::math::min 0.02 [/ 0.45 $maxLength] | ||
| } | ||
|
|
||
| fn drawLabelDefaultOptions {text width height} { |
There was a problem hiding this comment.
In general, I don't really like all these utility functions, but I could be convinced otherwise. @ppkn @smj-edison what do you think?
Lots of repetition since you need to restate and pass in all the parameters, and it doesn't fit the style we use in existing drawing programs. I think a straight-line When body is easier to read than having like 4 functions in each file.
There was a problem hiding this comment.
I'm not opposed to utility functions, as long as they're used multiple times and don't cause indirection fatigue. I think in this case it might be clearer inline, since they're not used that often.
| /p/ has canvas projection /surfaceToClip/ { | ||
|
|
||
| set query [list /someone/ wishes to draw a circle onto $p with /...options/] | ||
| When the collected results for $query are /results/ { |
There was a problem hiding this comment.
Why do we need to collect here? Why not use a When?
|
|
||
| When /someone/ wishes /p/ draws a /shape/ with radius /radius/ { | ||
| Wish $p draws a $shape with radius $radius | ||
| } |
There was a problem hiding this comment.
why do we have these radius/width/height variants? aren't they just subsumed by the options handler anyway?
|
|
||
| When /someone/ wishes /p/ draws a polygon with points /points/ /...options/ { | ||
| # Forgiving syntax for users who write 'draws a polygon with points $points color white' | ||
| # and use ( ) instead of { } for points. |
There was a problem hiding this comment.
Does this actually work? I feel like this wouldn't work unless you did "( ...points )" in quotes?
| set paddingMeters 0.02 | ||
| set offset [scale $paddingMeters [unitLengthVector $physicalDir]] | ||
| set physicalPos [add $physicalPos $offset] | ||
| When -atomically $thing has quad /q/ { |
There was a problem hiding this comment.
need to bring back the -atomicallyWithKey here to stop titles from blinking
osnr
left a comment
There was a problem hiding this comment.
Broadly, I think there are too many changes here that need individual review. There are a lot of changes that aren't clearly motivated and that touch really tricky/complicated parts of the code where I'd want to be convinced that we know why we're making the change and why it works.
It might be better to split into a remove-dead-modules PR, an image PR, a shapes PR, a textures PR, a titles PR, and a demos PR, or something like that. Then most of the PRs that just add a new drawing feature are easy to clear through (even if they blink, go magenta occasionally, etc) and we can focus on the trickier stuff separately.
|
Fair — I’ll strip this PR down to just shapes then and make PR’s of the other batches of work with more proof/documentation. Thanks! |
This PR is a little large because it touches a bunch of drawing files. We get back a suite of drawing capabilities. This PR also has an unrelated change to running
make remotewhen working out of a git worktree, happy to splice this into another PR.Some examples of running the demo code via
Wish $this runs demo code from builtin-programs/title.folk(which is a new wish added in this PR):