Tuesday, January 29, 2019

Truchet

Truchet, then rotated 12

//https://en.wikipedia.org/wiki/Truchet_tiles

// try EOS, EPM, EPZ, AAZsa
startshape truchet4
CF::Impure = 1
CF::Symmetry = CF::Cyclic, 11 //  n-fold symmetry

xwide = 26
ytall    = xwide-1

shape truchet4 {
  loop i = xwide  [ ] {
    loop j = ytall  [ ] {
      tuch(i,j)[ rotate (0 )  ]
      }  
   }
}
  
shape tuch(number i  , number  j  ) {
   sq()  [x  (i +.5)   y (j) ]
    tr2(i,j)  [ x (i)  y (-0.5+ j) z 1 rotate 0  ]
    tr4 (i,j)  [ x (i)  y (-0.5+ j) z 4 rotate 0  ]
}


shape sq {
  SQUARE () [  h 0.00 sat 0.0000 b 0  ]
}

shape tr(xx,yy)
rule   { if (mod(xx,2) )  
              tr1 (xx,yy) [ s 1.0 z 3 ]
          else
             tr1(xx,yy) [ s 1.0 z 3 ] }
rule   { if (mod(xx,2) )  
             tr1 (xx,yy) [ s 1.0 z 3 ]
          else
             tr2(xx,yy) [ s 1.0 z 3 ] }

rule   {
          if (mod(xx,2) )  
             tr2 (xx,yy) [ s 1.0 z 3 ]
          else
             tr3(xx,yy) [ s 1.0 z 3 ]
          }
rule { if ( mod(xx,2)  )  
             tr3(xx,yy) [ s 1.0 z 3 ]
          else
             tr4(xx,yy) [ s 1.0 z 3 ] } 


path tr1(xx,yy) {
  MOVETO(0,0)
  LINETO(0,1)
  LINETO(1,1)
  LINETO(0,0)
  CLOSEPOLY()
  STROKE(.01)[]
  FILL()[ hue Colfunc(xx,yy)  sat (rand(1,10)*0.1) b 1.0  ]
}
path tr2(xx,yy)  {
  MOVETO(0,0)
  LINETO(1,1)
  LINETO(1,0)
  LINETO(0,0)
  CLOSEPOLY()
  STROKE(.01)[]
  FILL()[ hue  Colfunc(xx,yy)  sat (rand(1,10)*0.1) b 1.0  ]
}

path tr3(xx,yy)  {
  MOVETO(1,0)
  LINETO(1,1)
  LINETO(0,1)
  LINETO(1,0)
  CLOSEPOLY()
  STROKE(.01)[]
  FILL()[ hue  Colfunc(xx,yy)   sat (rand(1,10)*0.1) b 1.0  ]
}

path tr4(xx,yy) {
  MOVETO(1,0)
  LINETO(0,1)
  LINETO(0,0)
  LINETO(1,0)
  CLOSEPOLY()
  STROKE(.01)[]
  FILL()[ hue   Colfunc(xx,yy)    sat (rand(1,10)*0.1) b 1.0  ]
}
Colfunc(xx,yy) =    rand(xx*10, yy*10)