aboutsummaryrefslogtreecommitdiff
path: root/virtual-programs/intersect.folk
blob: 1aea9695175baf2984628825e3d8e001aeac65e6 (plain) (blame)
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
#Wish $this is outlined white

When $this has neighbor /n/ {
  Wish $this is labelled $n
}

#Wish $this has neighbors

When /someone/ wishes /p/ has neighbors & /p/ has region /r/ & /p2/ has region /r2/ {
  if {$p eq $p2} { return }
  lassign [regionToBbox $r] bMinX bMinY bMaxX bMaxY
  lassign [regionToBbox $r2] b2MinX b2MinY b2MaxX b2MaxY
  
  set hasIntersections [rectanglesOverlap [list $bMinX $bMinY] \
              [list $bMaxX $bMaxY]\
              [list $b2MinX $b2MinY]\
              [list $b2MaxX $b2MaxY]\
  false ]
  #Display::stroke [list [list $bMinX $bMinY] {500 500}] 3 blue
  #Display::stroke [list [list $bMaxX $bMaxY] {500 500}] 3 red

  if {$hasIntersections} {
    Claim $p has neighbor $p2
    #Display::stroke [list [list $b2MinX $b2MinY] {500 500}] 3 red
    #Display::stroke [list [list $b2MaxX $b2MaxY] {500 500}] 3 white
    #Display::stroke [list [list $b2MinX $b2MinY] [list $b2MaxX $b2MaxY]] 10 blue
  }
}

When when /p/ has neighbor /n/ /lambda/ with environment /e/ {
  Wish $p has neighbors
}