applications.collages.collageAlgebra:
{
  ntColour = const(.8),
  ntColour2 = const(.6),
  w = const(sqrt(1/8)),
  
  S = {
    filledPolygon((-.5,-.5),(.5,-.5),(.5,.5),(-.5,.5))[#ntColour,#ntColour,#ntColour],
    polygon((-.5,-.5),(.5,-.5),(.5,.5),(-.5,.5))
  },
  S** = #S + {
    closedCurve((0,.25) right (.15,0), (.25,0) right (0,-.15), (0,-.25) right (-.15,0), (-.25,0) right (0,.15)) width .1
  },
  blankSq = {
    polygon((0,0),(1,0),(1,-1),(0,-1))
  },
  sq = {
    filledPolygon((0,0),(1,0),(1,-1),(0,-1))[#ntColour,#ntColour,#ntColour]
  } + #blankSq,
  
  D = #sq + { polyline((.95,0),(.95,-1)) width .1, polyline((1,-.95),(0,-.95)) width .1 },
  H = #sq + { polyline((.95,0),(.95,-1)) width .1 },
  D** = #sq + { curve((0,-.95),(.5,-.95) left (0,0) right (0,.3), (.95,-.5) left (-.3,0) right (0,0), (.95,0)) width .1 },
  D* = #sq + { curve((0,-.5) right (.3,0), (.5,0) left (0,-.3)) width .1 },
  H* = #sq + { polyline((.5,0),(.5,-1)) width .1 },
  Ha* = #sq + { curve((.5,-1) right (0,.3), (.95,-.5) left (-.3,0) right (0,0), (.95,0)) width .1 },
  Hb* = #sq + { curve((.95,-1), (.95,-.5) left (0,0) right (-.3,0), (.5,0) left (0,-.3)) width .1 },
  Dh = #blankSq + { curve((0,-.5) right (.3,0), (.5,0) left (0,-.3)) width .1 },
  Hh = #blankSq + { polyline((.5,0),(.5,-1)) width .1 },
  Hah = #blankSq + { curve((.5,-1) right (0,.3), (.95,-.5) left (-.3,0) right (0,0), (.95,0)) width .1 },
  Hbh = #blankSq + { curve((.95,-1), (.95,-.5) left (0,0) right (-.3,0), (.5,0) left (0,-.3)) width .1 },
  
  inner = {
    polyline((0,-1/4), (1/4,0), (3/4,-1/2)),
    polyline((3/4,0), (1,-1/4), (1/2, -3/4)),
    polyline((1,-3/4), (3/4, -1), (1/4, -1/2)),
    polyline((1/4,-1), (0,-3/4), (1/2,-1/4))
  },
  edge = {
    curve((0,-1/4), (1/4 - #w / 2, 0) left (0, -.175) ),
    curve((0,-3/4), (1/4, -1/2), (1/4 + #w / 2, 0) left (0, -.35)),
    curve((0,-3/4), (1/4 - #w / 2, -1) left (0, .175)),
    curve((1/4, -1/2), (1/4 + #w / 2, -1) left (0, .35))
  },
  edge2 = {
    curve(
      (0,-1/4),
      (1/4,0),
      (1/2,-1/4),
      (3/4 - #w / 2, -1/2) left (0, .175),
      (1/2,-3/4)),
    polyline((1/4,-1), (0,-3/4), (1/2,-1/4)),
    curve((3/4, 0), (3/4 + #w / 2, -1/2) left (0, .35), (3/4, -1), (1/4, -1/2))
  },
  edges = {
    curve(
      (1/4,-1),
      (1/4 - #w / 2, -1/2) right (0,.35),
      (1/4,0),
      (1/2,-1/4),
      (3/4 - #w / 2, -1/2) left (0, .175),
      (1/2,-3/4)),
    curve(
      (3/4, 0),
      (3/4 + #w / 2, -1/2) left (0, .35),
      (3/4, -1),
      (1/2, -3/4),
      (1/4 + #w / 2, -1/2) right (0, .175),
      (1/2, -1/4))
  },
  corner = {
    curve((0,-1/4 + #w / 2) right (.05,0), (1/4 - #w / 2,0) left (0,-.05)),
    polyline((0,-1/4 - #w / 2), (1/4 + #w / 2,-1/4 - #w / 2), (1/4 + #w / 2,0))
  },
  corner2 = {
    curve(
      (0,-1/4),
      (1/4,0),
      (1/2,-1/4),
      (3/4 - #w / 2, -1/2) left (0, .175) right (0,-.05),
      (1/2, -3/4 + #w / 2) left (.05,0) right (-.175, 0),
      (1/4, -1/2)),
    curve(
      (3/4, 0),
      (3/4 + #w / 2, -1/2) left (0, .35) right (0,0),
      (3/4 + #w / 2, -3/4 - #w / 2),
      (1/2, -3/4 - #w / 2) left (0,0) right (-.35, 0),
      (0, -3/4),
      (1/2, -1/4)
    )
  },
  hole-corner = {
    curve((0,-1/4), (1/4,0), (1/2,-1/4), (1, -1/4 - #w / 2) left (-.35,0)),
    curve((3/4, 0), (1, -1/4 + #w / 2) left (-.175,0)),
    polyline((0,-3/4), (1/2,-1/4)),
    curve((0,-3/4), (1/4 - #w / 2, -1) left (0,.175)),
    curve((1/4, -1/2), (1/4 + #w / 2, -1) left (0,.35))
  },
  
  id = scale(1),
  d = translate(1,-1),
  v = translate(0,1) . rotate(-90) . translate(0,-1),
  h = translate(1,0),
  
  d = <id, v, h, d>,
  h = <id, h>,
  
  q1 = rotate(90),
  q2 = rotate(180),
  q3 = rotate(270),
  q = <id, q1, q2, q3>,
  
  rot90 = rotate(90) . translate(0,-1),
  rot90 = <rot90>,
  
  rot180 = rotate(180) . translate(1,-1),
  rot180 = <rot180>,
  
  rot270 = rotate(270) . translate(1,0),
  rot270 = <rot270>,
  
  flip = scale(1,-1) . translate(0,-1),
  flip = <flip>
  
}
