-
-
Notifications
You must be signed in to change notification settings - Fork 23
Revive drawing capabilities (new and improved!) #261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
ab19c26
Scope PR down to just shape drawing
cwervo 15b5ef6
Inline label fns
cwervo 2c20d3d
Scope PR down to just shape drawing
cwervo 7301724
Fix circle rendering via branchless float bounds shader and fill.folk…
cwervo 93f13c6
Merge branch 'split-drawing-pr-refactor' into ac/drawing-may-2026
cwervo dd1d121
Fix indendation, weird options hack, label comment
cwervo 7816cf2
Coerce shader values
cwervo 12033dd
Early return from empty lines of text
cwervo 37cf0f3
Simplify shape wishes, remove errant "with pinned" for text
cwervo 9c1edde
Merge main
cwervo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| Wish the GPU compiles pipeline "arc" [list \ | ||
| {vec2 viewport mat3 surfaceToClip | ||
| vec2 center float radius float thickness float start float arclen vec4 color} { | ||
| float r = radius + thickness; | ||
| vec2 vertices[6] = vec2[6]( | ||
| center - r, | ||
| vec2(center.x + r, center.y - r), | ||
| vec2(center.x - r, center.y + r), | ||
| vec2(center.x + r, center.y - r), | ||
| center + r, | ||
| vec2(center.x - r, center.y + r) | ||
| ); | ||
| vec3 v = surfaceToClip * vec3(vertices[gl_VertexIndex], 1.0); | ||
| return vec4(v.xy / v.z, 0.0, 1.0); | ||
| } [subst { | ||
| vec2 clipXy = (gl_FragCoord.xy / viewport) * 2.0 - 1.0; | ||
| vec3 surfaceXy = inverse(surfaceToClip) * vec3(clipXy, 1.0); | ||
| surfaceXy /= surfaceXy.z; | ||
| const float TAU = $::TAU; | ||
| float c_start = clamp(start, 0.0, TAU); | ||
| float c_arclen = clamp(arclen, 0.0, TAU); | ||
| float dist = length(surfaceXy.xy - center) - radius; | ||
| float angle = atan(-(surfaceXy.y - center.y), surfaceXy.x - center.x); | ||
| angle = (angle < 0.0) ? (angle + TAU) : angle; | ||
| float end = c_start + c_arclen; | ||
| if (dist < thickness && dist > 0.0) { | ||
| if ((end < TAU && angle > c_start && angle < end) || | ||
| (end >= TAU && (angle > c_start || angle < end - TAU))) { | ||
| return color; | ||
| } | ||
| } | ||
| return vec4(0.0); | ||
| }]] | ||
|
|
||
| When the color map is /colorMap/ &\ | ||
| /p/ has canvas /id/ with /...wiOptions/ &\ | ||
| /p/ has canvas projection /surfaceToClip/ &\ | ||
| /someone/ wishes to draw an arc onto /p/ with /...options/ { | ||
| set center [dict getdef $options center ""] | ||
| if {$center eq ""} { set center [list [dict get $options x] [dict get $options y]] } | ||
| set radius [dict get $options radius] | ||
| set thickness [dict get $options thickness] | ||
| set start [dict get $options start] | ||
| set arclen [dict get $options arclen] | ||
| set color [dict get $options color] | ||
| set color [dict getdef $colorMap $color $color] | ||
| set layer [dict getdef $options layer 0] | ||
| set wiResolution [list [dict get $wiOptions width] [dict get $wiOptions height]] | ||
| Wish the GPU draws pipeline "arc" onto canvas $id with arguments \ | ||
| [list $wiResolution $surfaceToClip \ | ||
| $center $radius $thickness $start $arclen $color] \ | ||
| layer $layer | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,47 +1,55 @@ | ||
| Wish the GPU compiles pipeline "circle" { | ||
| {vec2 viewport mat3 surfaceToClip | ||
| vec2 center float radius float thickness vec4 color int filled} { | ||
| float r = radius + thickness; | ||
| vec2 vertices[6] = vec2[6]( | ||
| center - r, | ||
| vec2(center.x + r, center.y - r), | ||
| vec2(center.x - r, center.y + r), | ||
| vec2 center float innerRadius float outerRadius vec4 color} { | ||
| float r = outerRadius; | ||
| vec2 vertices[6] = vec2[6]( | ||
| vec2(center.x - r, center.y - r), | ||
| vec2(center.x + r, center.y - r), | ||
| vec2(center.x - r, center.y + r), | ||
|
|
||
| vec2(center.x + r, center.y - r), | ||
| center + r, | ||
| vec2(center.x - r, center.y + r) | ||
| ); | ||
| vec3 v = surfaceToClip * vec3(vertices[gl_VertexIndex], 1.0); | ||
| return vec4(v.xy/v.z, 0.0, 1.0); | ||
| } { | ||
| vec2 clipXy = (gl_FragCoord.xy / viewport) * 2.0 - 1.0; | ||
| vec3 surfaceXy = inverse(surfaceToClip) * vec3(clipXy, 1.0); | ||
| surfaceXy /= surfaceXy.z; | ||
| vec2(center.x + r, center.y - r), | ||
| vec2(center.x + r, center.y + r), | ||
| vec2(center.x - r, center.y + r) | ||
| ); | ||
| vec3 v = surfaceToClip * vec3(vertices[gl_VertexIndex], 1.0); | ||
| return vec4(v.xy/v.z, 0.0, 1.0); | ||
| } { | ||
| vec2 clipXy = (gl_FragCoord.xy / viewport) * 2.0 - 1.0; | ||
| vec3 surfaceXy = inverse(surfaceToClip) * vec3(clipXy, 1.0); | ||
| surfaceXy /= surfaceXy.z; | ||
|
|
||
| float dist = length(surfaceXy.xy - center) - radius; | ||
| if (filled == 1) { | ||
| return (dist < thickness) ? color : vec4(0.0); | ||
| } else { | ||
| return (dist < thickness && dist > 0.0) ? color : vec4(0.0); | ||
| float dist = length(surfaceXy.xy - center); | ||
| return (dist > innerRadius && dist < outerRadius) ? color : vec4(0.0); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| When the color map is /colorMap/ &\ | ||
| /p/ has canvas /id/ with /...wiOptions/ &\ | ||
| /p/ has canvas projection /surfaceToClip/ &\ | ||
| /someone/ wishes to draw a circle onto /p/ with /...options/ { | ||
| When the color map is /colorMap/ &\ | ||
| /p/ has canvas /id/ with /...wiOptions/ &\ | ||
| /p/ has canvas projection /surfaceToClip/ &\ | ||
| /someone/ wishes to draw a circle onto /p/ with /...options/ { | ||
| set wiResolution [list [dict get $wiOptions width] [dict get $wiOptions height]] | ||
|
|
||
| set center [dict getdef $options center ""] | ||
| if {$center eq ""} { | ||
| set center [list [dict get $options x] [dict get $options y]] | ||
| } | ||
|
|
||
| set center [dict getdef $options center ""] | ||
| if {$center eq ""} { set center [list [dict get $options x] [dict get $options y]] } | ||
| set radius [dict get $options radius] | ||
| set thickness [dict get $options thickness] | ||
| set color [dict get $options color] | ||
| set color [dict getdef $colorMap $color $color] | ||
| set filled [dict getdef $options filled false] | ||
| set radius [dict get $options radius] | ||
| set thickness [dict getdef $options thickness 0] | ||
| set color [dict get $options color] | ||
| set color [dict getdef $colorMap $color $color] | ||
| set filled [dict getdef $options filled false] | ||
| set layer [dict getdef $options layer 0] | ||
|
|
||
| set wiResolution [list [dict get $wiOptions width] [dict get $wiOptions height]] | ||
| Wish the GPU draws pipeline "circle" onto canvas $id with arguments \ | ||
| [list $wiResolution $surfaceToClip \ | ||
| $center $radius $thickness $color [expr {$filled eq false ? 0 : 1}]] | ||
| } | ||
| if {$filled} { | ||
| set innerRadius 0.0 | ||
| } else { | ||
| set innerRadius $radius | ||
| } | ||
| set outerRadius [expr {$radius + $thickness}] | ||
|
|
||
| Wish the GPU draws pipeline "circle" onto canvas $id with arguments \ | ||
| [list $wiResolution $surfaceToClip \ | ||
| $center $innerRadius $outerRadius $color] \ | ||
| layer $layer | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably still need this FIXME comment?