Draw a Koch curve. See details: Koch curve

var width=512, height=512, img=PPM(width,height,0xFfffFF);   // white canvas
var angle=(60.0).toRad();
const green=0x00FF00;
 
fcn koch(x1,y1, x2,y2, it){
   x3,y3 := (x1*2 + x2)  /3, (y1*2 + y2)  /3;
   x4,y4 := (x1   + x2*2)/3, (y1   + y2*2)/3;
   x:=x3 + (x4-x3)*angle.cos() + (y4-y3)*angle.sin();
   y:=y3 - (x4-x3)*angle.sin() + (y4-y3)*angle.cos();
 
   if(it>0){
      it-=1;
      koch(x1,y1, x3,y3, it);
      koch(x3,y3, x, y,  it);
      koch(x, y,  x4,y4, it);
      koch(x4,y4, x2,y2, it);
   }else{
      x,y, x1,y1, x2,y2, x3,y3, x4,y4 = 
         T(x,y, x1,y1, x2,y2, x3,y3, x4,y4).apply("toInt");
      img.line(x1,y1, x3,y3, green);
      img.line(x3,y3, x, y,  green);
      img.line(x, y,  x4,y4, green);
      img.line(x4,y4, x2,y2, green);
   }
}
 
koch(100.0,100.0, 400.0,400.0, 4);
img.writeJPGFile("koch.zkl.jpg");