Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 4 additions & 3 deletions Makefile
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.

Will remove this from this PR tomorrow, accidentally mixed unrelated work back into this branch, apologies!

Original file line number Diff line number Diff line change
Expand Up @@ -115,19 +115,20 @@ kill-folk:
fi

FOLK_REMOTE_NODE ?= folk-live
GIT_DIR := $(shell git rev-parse --git-dir 2>/dev/null || echo .git)

sync:
ssh $(FOLK_REMOTE_NODE) -t \
'cd ~/folk && git init > /dev/null && git ls-files --exclude-standard -oi --directory' \
> .git/ignores.tmp || true
git ls-files --exclude-standard -oi --directory >> .git/ignores.tmp
> $(GIT_DIR)/ignores.tmp || true
git ls-files --exclude-standard -oi --directory >> $(GIT_DIR)/ignores.tmp
rsync --timeout=15 -e "ssh -o StrictHostKeyChecking=no" \
--archive --delete --itemize-changes \
--exclude='/.git' \
--exclude='vendor/tracy/public/TracyClient.o' \
--include='vendor/tracy/public/***' \
--exclude='vendor/tracy/*' \
--exclude-from='.git/ignores.tmp' \
--exclude-from='$(GIT_DIR)/ignores.tmp' \
./ $(FOLK_REMOTE_NODE):~/folk/

remote-setup:
Expand Down
40 changes: 24 additions & 16 deletions builtin-programs/decorations/label.folk
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,39 @@ When /thing/ has resolved geometry /geom/ {
set text [join [lmap result $results {dict get $result text}] "\n"]
if {$text eq ""} { return }

# Split text into lines and find the longest line.
set lines [split $text "\n"]
set width [dict get $geom width]
set height [dict get $geom height]

set maxLength 0
foreach line $lines {
foreach line [split $text "\n"] {
set lineLength [string length $line]
if {$lineLength > $maxLength} {
set maxLength $lineLength
}
}
if {$maxLength == 0} {
set scale 0.02
} else {
set scale [::math::min 0.02 [/ 0.45 $maxLength]]
}
set position [list [expr {$width / 2.0}] [expr {$height / 2.0}]]
set options [dict create \
position $position \
scale $scale \
anchor center \
font "PTSans-Regular"]

# Set default scale based on longest line length.
# Scale inversely with length to keep text readable.
set defaultScale [::math::min 0.02 [/ 0.45 $maxLength]]
if {[dict exists $geom top] &&
[dict exists $geom tagSize] &&
[dict exists $geom bottom]} {
dict set options position \
[list [expr {$width / 2.0}] \
[expr {[dict get $geom top] + [dict get $geom tagSize] + [dict get $geom bottom] / 2.0}]]
}

set x [/ $geom(width) 2.0]
try {
set y $($geom(top) + $geom(tagSize) + $geom(bottom)/2.0)
} on error e {
set y [/ $geom(height) 2.0]
foreach result $results {
set options [dict merge $options [dict get $result options]]
}
set options [dict create x $x y $y scale $defaultScale]
# FIXME: support per-label options; right now, this just
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.

We probably still need this FIXME comment?

# applies an arbitrary label's options to all of them
# together.
set options [dict merge $options [dict get $result options]]
dict set options text $text
Wish to draw text onto $thing with {*}$options
}
Expand Down
39 changes: 0 additions & 39 deletions builtin-programs/display/arc.folk

This file was deleted.

135 changes: 0 additions & 135 deletions builtin-programs/display/curve.folk

This file was deleted.

53 changes: 53 additions & 0 deletions builtin-programs/draw/arc.folk
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/ &\
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.

Weird indentation here

/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
}
Loading