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
Original file line number Diff line number Diff line change
Expand Up @@ -115,16 +115,17 @@ kill-folk:
fi

FOLK_REMOTE_NODE ?= folk-live
FOLK_SYNC_IGNORES_TMP := $(shell git rev-parse --git-path ignores.tmp 2>/dev/null || echo .git/ignores.tmp)

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
> $(FOLK_SYNC_IGNORES_TMP) || true
git ls-files --exclude-standard -oi --directory >> $(FOLK_SYNC_IGNORES_TMP)
rsync --timeout=15 -e "ssh -o StrictHostKeyChecking=no" \
--archive --delete --itemize-changes \
--exclude='/.git' \
--exclude-from='.git/ignores.tmp' \
--exclude-from='$(FOLK_SYNC_IGNORES_TMP)' \
--exclude='vendor/tracy/public/TracyClient.o' \
--include='vendor/tracy/public/***' \
--exclude='vendor/tracy/*' \
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ Use it in an animation:

```
When the clock time is /t/ {
Wish $this draws a circle with offset [list [expr {sin($t) * 50}] 0]
Wish $this draws a circle with offset [list [expr {sin($t) * 0.05}] 0] radius 0.012
}
```

Expand Down
Binary file added assets/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
133 changes: 91 additions & 42 deletions builtin-programs/connections.folk
Original file line number Diff line number Diff line change
Expand Up @@ -3,67 +3,116 @@
# "Wish $tag is connected to $tag2" or "Wish $tag is dynamically connected to $tag2"

When /anyone/ wishes /source/ is connected to /sink/ {
Wish $source is connected to $sink from centroid to centroid
Wish $source is connected to $sink with from centroid to centroid
}
When /anyone/ wishes /source/ is connected to /sink/ from /from/ to /to/ {
Wish $source is connected to $sink with from $from to $to
}
When /anyone/ wishes /source/ is dynamically connected to /sink/ {
Wish $source is dynamically connected to $sink from centroid to centroid
Wish $source is dynamically connected to $sink with from centroid to centroid
}
When /anyone/ wishes /source/ is dynamically connected to /sink/ from /from/ to /to/ {
Wish $source is dynamically connected to $sink with from $from to $to
}

When /anyone/ wishes /source/ is connected to /sink/ /...options/ & \
/source/ has region /source_region/ & \
/sink/ has region /sink_region/ {
if {$source == $sink} {return}
fn drawConnectionArrowPoints {center radius radians} {
lassign $center cx cy
set dx [expr {cos($radians)}]
set dy [expr {sin($radians)}]
set spread [expr {$radius * 0.8}]
set baseX [expr {$cx - $dx * $radius}]
set baseY [expr {$cy - $dy * $radius}]
set tip [list [expr {$cx + $dx * $radius}] [expr {$cy + $dy * $radius}]]
set rearLeft [list [expr {$baseX + $dy * $spread}] [expr {$baseY - $dx * $spread}]]
set rearRight [list [expr {$baseX - $dy * $spread}] [expr {$baseY + $dx * $spread}]]
list $tip $rearLeft $rearRight
}

set p1 [dict_getdef $options from centroid]
set p2 [dict_getdef $options to centroid]
set source [region $p1 $source_region]
set sink [region $p2 $sink_region]
fn drawConnectionArrow {disp center radius radians color layer} {
if {$radius <= 0.0} { return }
lassign [drawConnectionArrowPoints $center $radius $radians] p0 p1 p2
Wish to draw a triangle onto $disp with \
p0 $p0 p1 $p1 p2 $p2 color $color layer $layer
}

set direction [vec2 sub $sink $source]
set color [dict_getdef $options color grey]
set layer [dict_getdef $options layer 0]
When the draw space library is /drawSpaceLib/ &\
the quad library is /quadLib/ &\
the pose library is /poseLib/ &\
the quad changer is /quadChange/ &\
display /disp/ has width /displayWidth/ height /displayHeight/ &\
display /disp/ has intrinsics /displayIntrinsics/ &\
/anyone/ wishes /source/ is connected to /sink/ with /...options/ &\
/source/ has quad /sourceQuad/ &\
/sink/ has quad /sinkQuad/ {
if {$source eq $sink} { return }
fn quadChange

set c [vec2 scale [vec2 add $source $sink] 0.5]
set angle [expr {atan2(-[lindex $direction 1], [lindex $direction 0]) - 3.14159/2}]
set p1 [$drawSpaceLib quadPoint $quadLib \
[quadChange $sourceQuad "display $disp"] \
[dict getdef $options from centroid]]
set p2 [$drawSpaceLib quadPoint $quadLib \
[quadChange $sinkQuad "display $disp"] \
[dict getdef $options to centroid]]
set from [$drawSpaceLib project $poseLib $displayIntrinsics $displayWidth $displayHeight $p1]
set to [$drawSpaceLib project $poseLib $displayIntrinsics $displayWidth $displayHeight $p2]

Wish to draw a stroke with points [list $source $sink] width 2 color $color layer $layer
Wish to draw a shape with sides 3 center $c radius 30 radians $angle color $color filled true layer $layer
set direction [$drawSpaceLib vectorSub $to $from]
if {[$drawSpaceLib vectorDistance $to $from] == 0.0} { return }
set color [dict getdef $options color grey]
set layer [dict getdef $options layer 0]

set c [$drawSpaceLib vectorMidpoint $from $to]
set angle [expr {atan2([lindex $direction 1], [lindex $direction 0])}]

Wish to draw a line onto $disp with \
points [list $from $to] width 2 color $color layer $layer
drawConnectionArrow $disp $c 30 $angle $color $layer
}

set speed 75
set spacing 50
set maxsize 25

When /anyone/ wishes /source/ is dynamically connected to /sink/ /...options/ & \
/source/ has region /source_region/ & \
/sink/ has region /sink_region/ {

if {$source == $sink} {return}
When the draw space library is /drawSpaceLib/ &\
the quad library is /quadLib/ &\
the pose library is /poseLib/ &\
the quad changer is /quadChange/ &\
display /disp/ has width /displayWidth/ height /displayHeight/ &\
display /disp/ has intrinsics /displayIntrinsics/ &\
/anyone/ wishes /source/ is dynamically connected to /sink/ with /...options/ &\
/source/ has quad /sourceQuad/ &\
/sink/ has quad /sinkQuad/ {

set p1 [dict_getdef $options from centroid]
set p2 [dict_getdef $options to centroid]
set source [region $p1 $source_region]
set sink [region $p2 $sink_region]
if {$source eq $sink} { return }
fn quadChange

set direction [vec2 normalize [vec2 sub $sink $source]]
set distance [vec2 distance $sink $source]
set angle [expr {atan2(-[lindex $direction 1], [lindex $direction 0]) - 3.14159/2}]
set p1 [$drawSpaceLib quadPoint $quadLib \
[quadChange $sourceQuad "display $disp"] \
[dict getdef $options from centroid]]
set p2 [$drawSpaceLib quadPoint $quadLib \
[quadChange $sinkQuad "display $disp"] \
[dict getdef $options to centroid]]
set from [$drawSpaceLib project $poseLib $displayIntrinsics $displayWidth $displayHeight $p1]
set to [$drawSpaceLib project $poseLib $displayIntrinsics $displayWidth $displayHeight $p2]

set color [dict_getdef $options color white]
set layer [dict_getdef $options layer 0]
set direction [$drawSpaceLib vectorSub $to $from]
set distance [$drawSpaceLib vectorDistance $to $from]
if {$distance == 0.0} { return }
set direction [$drawSpaceLib vectorScale $direction [expr {1.0 / $distance}]]
set angle [expr {atan2([lindex $direction 1], [lindex $direction 0])}]

lassign [vec2 scale [vec2 add $source $sink] 0.5] cx cy
set color [dict getdef $options color white]
set layer [dict getdef $options layer 0]

Wish to draw a stroke with points [list $source $sink] width 1 color $color layer $layer

When the clock time is /t/ {
set offset [expr {round($t*$speed) % $spacing}]
set count [expr {round($distance / $spacing)}]
Wish to draw a line onto $disp with \
points [list $from $to] width 1 color $color layer $layer

for {set p $offset} {$p < $distance} {incr p $spacing} {
set c [vec2 add $source [vec2 scale $direction $p]]
set s [expr {min($maxsize, 0.20*min($p, $distance - $p))}]
Wish to draw a shape with sides 3 center $c radius $s radians $angle color $color filled true layer $layer
}
When the clock time is /t/ {
set offset [expr {round($t*$speed) % $spacing}]
for {set p $offset} {$p < $distance} {incr p $spacing} {
set c [$drawSpaceLib vectorAdd $from [$drawSpaceLib vectorScale $direction $p]]
set s [expr {min($maxsize, 0.20*min($p, $distance - $p))}]
drawConnectionArrow $disp $c $s $angle $color $layer
}
}
}
4 changes: 2 additions & 2 deletions builtin-programs/demos.folk
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Claim 45001 has demo code {
Claim 45002 has demo code {
When /actor/ is cool {
Wish $this is labelled "$actor is pretty cool"
Wish $actor is outlined red
Wish $actor is outlined red
}
}
Claim 45003 has demo code {
Expand All @@ -24,7 +24,7 @@ Claim 45004 has demo code {
}
Claim 45005 has demo code {
When the clock time is /t/ {
Wish $this draws a circle offset [list expr {sin($t) * 50} 0]
Wish $this draws a circle with offset [list [expr {sin($t) * 0.05}] 0] radius 0.012
}
}
Claim 45006 has demo code {
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.

Loading