applications.collages.collageAlgebra:
  { 
    side-length = const(1),
    height = const(sqrt(3) * #side-length / 2), 
    rope-width = const(#side-length / 6),
    rope-pos = const(#side-length / 5),
    inv-pos = const(#side-length / 2 - #rope-pos - #rope-width),
    delta = const(.05),
    
    gr = colourOperation(r|.06:0,g|.04:0),
    
    rot = rotate(120) . translate(#side-length / 2, #height),
    rot = <rot>,
  
    f1 = rotate(0),
    f2 = rotate(60),
    f3 = rotate(120),
    f4 = rotate(180),
    f5 = rotate(240),
    f6 = rotate(300),
    F = <f1,f2,f3,f4,f5,f6>,
    
    g0 = scale(1),
    g1 = rotate(180) . translate(0, 2 * #height),
    g2 = translate(-#side-length / 2, #height),
    g3 = translate(#side-length / 2, #height),
    G = <g0,g1,g2,g3>,
    H = <g0,g1,g3>,
    I = <g0,g1>,

    background = { filledPolygon((0,0), (#side-length / 2, #height), (-#side-length / 2, #height)) },
    
    part = {
             filledPolygon((-#delta * sin(30), #height - 2*#rope-pos * cos(30) + #delta * cos(30)),
                        (-#rope-pos, #height),
                        (-#rope-pos - #rope-width / cos(30), #height),
                        (- cos(30) * #rope-width - #delta * sin(30), #height - #rope-width / 2 - 2*#rope-pos * cos(30) + #delta * cos(30))
                        )<1>,
             polyline((0, #height - 2*#rope-pos * cos(30)),
                        (-#rope-pos, #height)),
             polyline((-#rope-pos - #rope-width / cos(30), #height),
                        (- cos(30) * #rope-width, #height - #rope-width / 2 - 2*#rope-pos * cos(30))
                        )
                        },

    part2 = {
              filledPolygon((0, #height - 2*#rope-pos * cos(30)),
                        (-#rope-pos, #height),
                        (-#rope-pos - #rope-width / cos(30), #height),
                        (- cos(30) * #rope-width, #height - #rope-width / 2 - 2*#rope-pos * cos(30)),
                        (0, #height - 2*#rope-pos * cos(30) - #rope-width)
                        )<1>,
             polyline((0, #height - 2*#rope-pos * cos(30)),
                        (-#rope-pos, #height)),
             polyline((-#rope-pos - #rope-width / cos(30), #height),
                        (- cos(30) * #rope-width, #height - #rope-width / 2 - 2*#rope-pos * cos(30)),
                        (0, #height - 2*#rope-pos * cos(30) - #rope-width)
                        )
                        },

    part3 = {
              filledPolygon((-#rope-pos, #height),
                       (-#rope-pos - (#side-length / 2 - #rope-pos) / 2, #height - (#height / #side-length * (#side-length / 2 - #rope-pos))),
                       (-#rope-pos - #rope-width / cos(30) - (#side-length / 2 - #rope-pos - #rope-width / cos(30)) / 2, #height - (#height / #side-length * (#side-length / 2 - #rope-pos - #rope-width / cos(30)))),
                       (-#rope-pos - #rope-width / cos(30), #height)
                       )<1>,
              polyline((-#rope-pos, #height),
                       (-#rope-pos - (#side-length / 2 - #rope-pos) / 2, #height - (#height / #side-length * (#side-length / 2 - #rope-pos)))),
              polyline((-#rope-pos - #rope-width / cos(30), #height),
                       (-#rope-pos - #rope-width / cos(30) - (#side-length / 2 - #rope-pos - #rope-width / cos(30)) / 2, #height - (#height / #side-length * (#side-length / 2 - #rope-pos - #rope-width / cos(30))))
                       )
                       },
    
    c2 = rotate(120) . translate(#side-length / 2, #height),
    c3 = rotate(240) . translate(-#side-length / 2, #height),
    c4 = scale(-1,1),
    c5 = scale(-1,1) . rotate(120) . translate(#side-length / 2, #height),
    c6 = scale(-1,1) . rotate(240) . translate(-#side-length / 2, #height),
    
    tile1 = #background +
      #part +
      #part transformed by c2 +
      #part transformed by c3 +
      #part transformed by c4 +
      #part transformed by c5 +
      #part transformed by c6
      ,
    tile2 = #background +
      #part3 +
      #part transformed by c2 +
      #part2 transformed by c3 +
      #part transformed by c4 +
      #part3 transformed by c5 +
      #part2 transformed by c6,
    tile3 = #background +
      #part3 +
      #part3 transformed by c2 +
      #part3 transformed by c3 +
      #part3 transformed by c4 +
      #part3 transformed by c5 +
      #part3 transformed by c6,

    outer =  #background + {
              filledPolygon((#rope-pos, #height),
                        (0, #height - 2*#rope-pos * cos(30)),
                        (-#rope-pos, #height),
                        (-#rope-pos - #rope-width / cos(30), #height),
                        (- cos(30) * #rope-width, #height - #rope-width / 2 - 2*#rope-pos * cos(30)),
                        (0, #height - 2*#rope-pos * cos(30) - #rope-width),
                        (cos(30) * #rope-width, #height - #rope-width / 2 - 2*#rope-pos * cos(30)),
                        (#rope-pos + #rope-width / cos(30), #height)
                        )<1>,
             polyline((#rope-pos, #height),
                        (0, #height - 2*#rope-pos * cos(30)),
                        (-#rope-pos, #height)),
             polyline((-#rope-pos - #rope-width / cos(30), #height),
                        (- cos(30) * #rope-width, #height - #rope-width / 2 - 2*#rope-pos * cos(30)),
                        (0, #height - 2*#rope-pos * cos(30) - #rope-width),
                        (cos(30) * #rope-width, #height - #rope-width / 2 - 2*#rope-pos * cos(30)),
                        (#rope-pos + #rope-width / cos(30), #height)
                        )
                        },

    frame = { polygon((0,0), (#side-length / 2, #height), (-#side-length / 2, #height))<0,1,0> },
    S = { polyline((-1,0),(1,0))<0,1,0>, polyline((0,-1),(0,1))<0,1,0> },
    A = { filledPolygon((0,0), (#side-length / 2, #height), (-#side-length / 2, #height))<.7,0,.2> }
        + #frame,
    B = { filledPolygon((0,0), (#side-length / 2, #height), (-#side-length / 2, #height))<.4,0,.5> }
        + #frame,
    T = { filledPolygon((0,0), (#side-length / 2, #height), (-#side-length / 2, #height))<.7,.2,0> }
        + #frame,
    N = { filledPolygon((0,0), (#side-length / 2, #height), (-#side-length / 2, #height))<.5,.2,.2> }
        + #frame
  }
