Optische Täuschung
Parallele Linien
============================================

ScriptBegin
var Grafik = "Script Turtle"

var a=15;            // Quadrat    
    din=4;           //Papierformat    
 
    PenC1   ="crimson" //"yellow"
    PenC2   ="white" //"yellow"
    PenW   =0.7;
    Fill0  ="lightblue"
    Fill1  ="black"



//-------------------------------


function init()
{ t.setPage(din);
  hoehe=t.P0y()-t.P1y();  breite=t.P1x()-t.P0x();
  t.setAntiAliasing();
  DiaRestwert = t.showDia(2500,20, 1); 
  if (DiaRestwert & 2)
   { PenC=PenC1; Info="Parallele Linien ?"; }
  else
   { PenC=PenC2; Info="Parallele Linien"; } 

}

var hoehe,breite, Info;

function draw()
{ //t.drawKoordSystem();
  //t.drawRaster();

  defMuster();  // t.goTo(0,0); t.draw("Quadrat"); 
  drawMuster();
  drawBeschriftung(); 
}



function defMuster()
{ 
  t.setNoStyle();
  t.goTo(-a/2,-a/2);
  t.rectPolygon(a,a)
  t.setPen(PenC,PenW); t.setBrush(Fill0);  
  t.defDraw("Quadrat");

  t.goTo(a/2,-a/2);
  t.rectPolygon(a,a)
  t.setPen(PenC,PenW); t.setBrush(Fill1);  
  t.defDraw("Quadrat",1);
  
  t.goTo(a+a,0); t.defPoint("ShiftX");
  t.goTo(0,a);   t.defPoint("ShiftY");
}


function drawMuster()
{
  t.turnTo(25); t.setNoStyle(); 
 
  maxj=Math.floor(breite/2 / (a+a))+2;
  maxi=Math.floor(hoehe /2 / (a))+4;

  for(i=-maxi; i<maxi; i++)
  { t.goTo(0,0);
    
    switch (Math.abs(i)%4)
    { case 0: break;
      case 3:
      case 1: t.shift("ShiftX",0.1); break;         
      case 2: t.shift("ShiftX",0.2); break;         
    }

    t.shift("ShiftY",i);  
    t.shift("ShiftX",-maxj);
    
    for(j=-maxj; j<maxj; j++)
    { t.draw("Quadrat"); t.shift("ShiftX",1);
    }    
  }
}


function drawBeschriftung()
{ t.setFont("Arial", a/4, false, 60);
  t.setPen("black",0);
  t.turnTo(0);
  t.goTo(t.P0x(), t.P0y()-15);
  t.setBrush(Fill0); t.rectangle(65,a);
  t.goTo(t.P0x()+15, t.P0y()-15+a/10);
  t.text(Info);
} 


ScriptEnd#1
============================================