applications.collages.collageAlgebra:
  attributes r,g,b, r0,g0;
  { 
  
    ntColour = const(.8),
    ntColour2 = const(.6),
    c1r = const(.5),
    c1g = const(.5),
    c1b = const(1),
    c2r = const(.3),
    c2g = const(1),
    c2b = const(.6),
    c3r = const(.2),
    c3g = const(.3),
    c3b = const(0),
    c4r = const(.5),
    c4g = const(.2),
    c4b = const(0),
    w = const(tan(22.5)),
    
    f1 = rotate(0),
    f2 = rotate(45),
    f3 = rotate(90),
    f4 = rotate(135),
    f5 = rotate(180),
    f6 = rotate(225),
    f7 = rotate(270),
    f8 = rotate(315),
    F = <f1, f2, f3, f4, f5, f6, f7, f8>,
    
    g1 = scale(.5),
    g2 = scale(.5) . translate(-(sqrt(1/2) - 1/2),.5),
    g3 = scale(.5,-.5) . translate(0,1),
    g4 = scale(.5) . translate(sqrt(1/2) - 1/2,.5),
    G = <g1, g2, g3, g4>,
    
    tri = { filledPolygon((0,0),(-#w,1),(#w,1))[#ntColour,#ntColour,#ntColour],
            polygon((0,0),(-#w,1),(#w,1)) },
    A = #tri,
    B = #tri,
    
    A2 = { filledPolygon((0,0),(-#w,1),(#w,1))[#ntColour2,#ntColour2,#ntColour2],
            polygon((0,0),(-#w,1),(#w,1)) },
    B2 = #A2,

    p1 = {
      filledPolygon((0,0),(-#w / 3,1/3), (#w / 3,1/3))<r,g,b; r=#c1r,g=#c1g,b=#c1b>,
      filledPolygon((-#w,1),(#w,1),(2/3*#w,2/3),(-2/3*#w,2/3))<r,g,b;r=#c2r,g=#c2g,b=#c2b>,
      filledPolygon((-#w / 3,1/3), (#w / 3,1/3), (2/3*#w,2/3), (0,1),
                    (-2/3*#w,2/3))<r0,g0,b;r0=#c3r,g0=#c3g,b=#c3b>,
      polygon((0,0),(-#w,1),(#w,1))
    },
    
    p2 = {
      filledPolygon((0,0),(-#w / 3,1/3), (#w / 3,1/3))<r,g,b;r=#c2r,g=#c2g,b=#c2b>,
      filledPolygon((-#w,1),(#w,1),(2/3*#w,2/3),(-2/3*#w,2/3))<r,g,b; r=#c1r,g=#c1g,b=#c1b>,
      filledPolygon((-#w / 3,1/3), (#w / 3,1/3), (2/3*#w,2/3), (0,1),
                    (-2/3*#w,2/3))<r0,g0,b;r0=#c4r,g0=#c4g,b=#c4b>,
      polygon((0,0),(-#w,1),(#w,1))
    },
    
    flipA = colourOperation(r0||1/2:0,g0||1/2:0),
    flipB = colourOperation(r0||1/5:1,g0||1/5:1)
    
  }
