Skip to content

Revive drawing capabilities (new and improved!)#261

Open
cwervo wants to merge 6 commits into
mainfrom
ac/drawing-may-2026
Open

Revive drawing capabilities (new and improved!)#261
cwervo wants to merge 6 commits into
mainfrom
ac/drawing-may-2026

Conversation

@cwervo
Copy link
Copy Markdown
Collaborator

@cwervo cwervo commented May 7, 2026

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 remote when 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):

IMG_5693 Small IMG_5694 Small IMG_5695 Small IMG_5696 Small IMG_5697 Small IMG_5698 Small IMG_5699 Small IMG_5700 Small IMG_5701 Small

@cwervo cwervo requested review from osnr and ppkn and removed request for osnr May 7, 2026 00:48
Comment thread builtin-programs/draw/shapes.folk Outdated
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}]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm slightly surprised that there's no PI (or TAU) constants. Only slightly surprised though.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah, I should definitely just expose PI and Tau globals

@ppkn
Copy link
Copy Markdown
Collaborator

ppkn commented May 7, 2026

I plan to test this out on my system today.

Copy link
Copy Markdown
Collaborator

@ppkn ppkn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 white

@cwervo cwervo force-pushed the ac/drawing-may-2026 branch 2 times, most recently from 23d2434 to e5e18de Compare May 20, 2026 23:58
@cwervo cwervo force-pushed the ac/drawing-may-2026 branch 7 times, most recently from 7833d2c to 201c035 Compare May 29, 2026 01:37
@cwervo cwervo force-pushed the ac/drawing-may-2026 branch 6 times, most recently from b48d29f to 7056a3e Compare May 29, 2026 22:24
…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
@cwervo cwervo force-pushed the ac/drawing-may-2026 branch from 7056a3e to 2282866 Compare May 29, 2026 22:33
@cwervo
Copy link
Copy Markdown
Collaborator Author

cwervo commented May 29, 2026

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)

@osnr
Copy link
Copy Markdown
Collaborator

osnr commented May 29, 2026 via email

@cwervo
Copy link
Copy Markdown
Collaborator Author

cwervo commented May 29, 2026

@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 \
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(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/ &\
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This stuff is really ugly:

Image

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
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What bug is fixed by this?

}

When /someone/ wishes /program/ runs demo code from /filename/ {
Hold! -key "active-demo-$program" Claim $program running demo code from $filename
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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" \
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rather let this error out

@@ -1,4 +1,5 @@
# Terminal
return; # TODO: FIXME
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rather let this error out

Comment thread db.c
// Will be NULL if not running in an Atomically
// convergence-tracking subgraph.
AtomicallyVersion* _Atomic atomicallyVersion;
_Atomic bool isAtomicallyRootMatch;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What bug does this fix? / why do we need this?

Comment thread Makefile
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; \
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Comment thread Makefile
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)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does this fix?

fn drawLabelDefaultScale {text} {
set maxLength [drawLabelMaxLineLength $text]
if {$maxLength == 0} { return 0.02 }
::math::min 0.02 [/ 0.45 $maxLength]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be better style to use explicit return

::math::min 0.02 [/ 0.45 $maxLength]
}

fn drawLabelDefaultOptions {text width height} {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/ {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/ {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to bring back the -atomicallyWithKey here to stop titles from blinking

Copy link
Copy Markdown
Collaborator

@osnr osnr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@cwervo
Copy link
Copy Markdown
Collaborator Author

cwervo commented May 30, 2026

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants