applications.collages.collageAlgebra:
  {
  ntColour = const(.8),
  ntColour2 = const(.6),
  
  sq1 = { filledPolygon((.5,0), (0,.5), (-.5,0), (0,-.5))[#ntColour, #ntColour, #ntColour],
           polygon((.5,0), (0,.5), (-.5,0), (0,-.5)) },
  sq2 = { filledPolygon((.5,0), (0,.5), (-.5,0), (0,-.5))[#ntColour2, #ntColour2, #ntColour2],
           polygon((.5,0), (0,.5), (-.5,0), (0,-.5)) },
  arrow = { filledPolygon((-.1,.25),(0,.3),(.1,.25),(0,.4)) },

  id = scale(1),
    tl = rotate(90),
  L = #sq1 + #arrow transformed by tl,
  L = <id, #L>,
    tr = rotate(-90),
  TLR = #sq2 + #arrow transformed by tl + #arrow transformed by tr,
  TLR = <id, #TLR>,
  TL = #sq2 + #arrow transformed by tl,
  TL = <id, #TL>,
  TR = #sq2 + #arrow transformed by tr,
  TR = <id, #TR>,
    tud = rotate(180),
  UD = #sq1 + #arrow + #arrow transformed by tud,
  UD = <id, #UD>,
  U = #sq1 + #arrow,
  U = <id, #U>,
  U2 = #sq2 + #arrow,
  U2 = <id, #U2>,
    teu = rotate(45) . translate(.075,-.075),
  EU = #sq1 + #arrow transformed by teu,
  EU = <id, #EU>,
    ted = rotate(-225) . translate(.075,.075),
  ED = #sq1 + #arrow transformed by ted,
  ED = <id, #ED>,
           
           
  background = { filledPolygon((.5,0), (0,.5), (-.5,0), (0,-.5)) },
  border-background = {
                        filledPolygon((.5,0), (-.2,.7), (-.2,-.7)),
                        polyline((-.3,.825), (-.3,-.825)) width .05
                      },
  
  upStrand = {
    polyline((-.25, -.25), (.25, .25)) width .4,
    polyline((-.2501, -.2501), (.2501, .2501))[1] width .3
   },
  downStrand = {
    polyline((.25, -.25), (-.25, .25)) width .4,
    polyline((.2501, -.2501), (-.2501, .2501))[1] width .3
  },
  
  inner1 = #background + #upStrand + #downStrand,
  inner2 = #background + #downStrand + #upStrand,
  
  h-breakline = #background + {
    curve((-.25,.25) right (.075,-.075),
          (0,.18) left (-.02,0) right (.02,0),
          (.25,.25) left (-.075,-.075)) width .4,
    curve((-.2501,.2501) right (.075,-.075),
          (0,.18) left (-.02,0) right (.02,0),
          (.2501,.2501) left (-.075,-.075))[1] width .3,
    curve((-.25,-.25) right (.075,.075),
          (0,-.18) left (-.02,0) right (.02,0),
          (.25,-.25) left (-.075,.075)) width .4,
    curve((-.2501,-.2501) right (.075,.075),
          (0,-.18) left (-.02,0) right (.02,0),
          (.2501,-.2501) left (-.075,.075))[1] width .3
  },
  
  edge = #border-background +
         { 
    curve((.25, -.25) right (-.1,.1),
          (.15, 0) left (0,-.01) right (0,.01),
          (.25, .25) left (-.1,-.1)) width .4,
    curve((.2501, -.2501) right (-.1,.1),
          (.15, 0) left (0,-.01) right (0,.01),
          (.2501, .2501) left (-.1,-.1))[1] width .3
         },
  corner = #border-background +
         {
      filledCurve((.25 - .15 / sqrt(2),-.25 - .15 / sqrt(2))
                    left (0,0) right (-.1,.1),
         (0, 0) left (-0, -.2) right (-0, .2),
         (0,.5),
         (.35,.15) left (0,0) right (-.07,-.07),
         (.25 + .15 / sqrt(2),-.25 + .15 / sqrt(2))
                    left (-.1,.1) right (0,0))[1]
         },
  
  rot = rotate(-90),
  rot = <rot>,
  
  mir = scale(1,-1),
  mir = <mir>,

  i1 = translate(0,.5),
  i2 = use(i1) . rotate(180),
  i3 = translate(-.5,0),
  i4 = use(i3) . rotate(180),
  init = <i1,i2,i3,i4>,
  
  up = translate(0,1),
  down = translate(0,-1),
  left = translate(-1,0),
  right = translate(1,0),
  
  up = <id, up>, down = <id, down>, left = <id, left>, right = <id, right>,
  up-down = <id, up, down>, left-right = < id, left, right >
}
