blob: ed3fb8eb1eee13c60cb1cfdeca3f8bb7ec782b0f (
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
|
When when /rect/ points /direction/ with length /l/ at /someone/ /lambda/ with environment /e/ {
if {[string match "/*" $rect]} { return }
Wish $rect points $direction with length $l
}
When when /rect/ points /direction/ at /someone/ /lambda/ with environment /e/ {
if {[string match "/*" $rect]} { return }
Wish $rect points $direction with length 1
}
When /someone/ wishes /rect/ points /direction/ with length /l/ & /rect/ has region /region/ {
set scale $l
if {$direction eq "up"} {
set whiskerRegion [region scale $region width 0.01px height $scale]
set whiskerRegion [region move $whiskerRegion up \
[vec2 distance [region bottom $whiskerRegion] [region top $region]]px]
set color blue
} elseif {$direction eq "left"} {
set whiskerRegion [region scale $region height 0.01px width $scale]
set whiskerRegion [region move $whiskerRegion left \
[vec2 distance [region right $whiskerRegion] [region left $region]]px]
set color gold
} elseif {$direction eq "right"} {
set whiskerRegion [region scale $region height 0.01px width $scale]
set whiskerRegion [region move $whiskerRegion right \
[vec2 distance [region right $whiskerRegion] [region left $region]]px]
set color green
} elseif {$direction eq "down"} {
set whiskerRegion [region scale $region width 0.01px height $scale]
set whiskerRegion [region move $whiskerRegion down \
[vec2 distance [region bottom $whiskerRegion] [region top $region]]px]
set color white
}
set whisker [list $rect whisker $direction]
Claim $whisker has region $whiskerRegion
Wish $whisker is outlined $color
When /target/ has region /r2/ {
if {$target != $rect && $target != $whisker && \
[region intersects $whiskerRegion $r2]} {
Claim $rect points $direction at $target
Claim $rect points $direction with length $l at $target
}
}
}
|