blob: 4e002910d04892cef68e2b4037ebfba6a698c029 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# Connection wish fulfillment
# for wishes of the form:
# "Wish $tag is connected to $tag2" or "Wish $tag is dynamically connected to $tag2"
When /anyone/ wishes /source/ is connected to /sink/ & \
/source/ has region /source_region/ & \
/sink/ has region /sink_region/ {
if {$source == $sink} {return}
set source [region centroid $source_region]
set sink [region centroid $sink_region]
set direction [vec2 sub $sink $source]
set c [vec2 scale [vec2 add $source $sink] 0.5]
set angle [expr {atan2(-[lindex $direction 1], [lindex $direction 0]) - 3.14159/2}]
set color grey
Wish to draw a stroke with points [list $source $sink] width 2 color $color
Wish to draw a shape with sides 3 center $c radius 30 radians $angle color $color filled true
}
set speed 75
set spacing 50
set maxsize 25
When /anyone/ wishes /source/ is dynamically connected to /sink/ & \
/source/ has region /source_region/ & \
/sink/ has region /sink_region/ {
if {$source == $sink} {return}
set source [region centroid $source_region]
set sink [region centroid $sink_region]
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}]
lassign [vec2 scale [vec2 add $source $sink] 0.5] cx cy
Wish to draw a stroke with points [list $source $sink] width 1 color white
When the clock time is /t/ {
set offset [expr {round($t*$speed) % $spacing}]
set count [expr {round($distance / $spacing)}]
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 white filled true
}
}
}
|