### Truchet Tiles

Playing with Truchet Tiles
en.wikipedia.org/wiki/truchet_tiles

```// Forked from "10Print" by rupertxrussell
// https://turtletoy.net/turtle/188b93df20
// Released under the MIT licence
// you can use this for commercial gain if you like eg you can sell artworks with this image.

// You can find the Turtle API reference here: https://turtletoy.net/syntax
Canvas.setpenopacity(1);

// Global code will be evaluated once.
const turtle = new Turtle();
const gap = 12; //min=1 max=12 step=1
const gridCount = 15; //min=1 max=20 step=1
const size = 11; //min=5 max=12 step=1
const xOffset = -90; //min=-100 max=80 step=1
const yOffset = -90; //min=-100 max=80 step=1
const outline = 0; //min=0 max=1 step=1 (No, Yes)
// const type = 0; //min=0 max=1 step=1 (No, Yes)
const type = 1;

for(let x=0; x < gridCount; x++){
for(let y=0; y < gridCount; y++){
square((x * gap) + xOffset, (y * gap)+ yOffset);
}
}

function square(x,y) {

// Pick a random number
let r = randomInRange(0, 2);

turtle.penup();
turtle.goto(x,y);
turtle.pendown();

if(outline === 1){
for(let i=0; i< 4; i++){
turtle.forward(size);
turtle.right(90);
}
}
turtle.penup();

switch(type) {
case 0: // Original 10 Print Design just / or \

switch(r) {
case 0:
turtle.right(45);
turtle.forward(size * Math.sqrt(2));
turtle.backward(size * Math.sqrt(2));
turtle.left(45);
break;

case 1:
turtle.penup();
turtle.forward(size);
turtle.pendown();
turtle.right(90 + 45);
turtle.forward(size * Math.sqrt(2));
turtle.backward(size * Math.sqrt(2));
turtle.left(90 + 45);
turtle.penup();
turtle.backward(size);
break;
default:
// end of original 10 Print design code block
}

case(1): // Curved Truchet tile design
switch(r) {
case 0:
// top left arc
turtle.penup();
radius = size * 0.5;
turtle.forward(size * 0.5);
turtle.right(90);
turtle.pendown();
turtle.circle(radius, extent = 90);
turtle.penup();
turtle.circle(radius, extent = -90);
turtle.left(90);
turtle.backward(size * 0.5);

// bottom right arc
turtle.penup();
radius = size * 0.5;
turtle.forward(size);
turtle.right(90);
turtle.forward(size);
turtle.right(90);

turtle.forward(size * 0.5);
turtle.right(90);
turtle.pendown();
turtle.circle(radius, extent = 90);
turtle.penup();
turtle.circle(radius, extent = -90);
turtle.left(90);
turtle.backward(size * 0.5);

turtle.left(90);
turtle.backward(size);
turtle.left(90);
turtle.backward(size);
break;

case 1:

turtle.forward(size);
turtle.right(90);

// top left arc
turtle.penup();
radius = size * 0.5;
turtle.forward(size * 0.5);
turtle.right(90);
turtle.pendown();
turtle.circle(radius, extent = 90);
turtle.penup();
turtle.circle(radius, extent = -90);
turtle.left(90);
turtle.backward(size * 0.5);

// bottom right arc
turtle.penup();
radius = size * 0.5;
turtle.forward(size);
turtle.right(90);
turtle.forward(size);
turtle.right(90);

turtle.forward(size * 0.5);
turtle.right(90);
turtle.pendown();
turtle.circle(radius, extent = 90);
turtle.penup();
turtle.circle(radius, extent = -90);
turtle.left(90);
turtle.backward(size * 0.5);

turtle.left(90);
turtle.backward(size);
turtle.left(90);
turtle.backward(size);

turtle.backward(size);
turtle.left(90);

break;
default:
// End of Curved Truchet tile design
}
}
}

function randomInRange(from, to) {
var r = Math.random();
return Math.floor(r * (to - from) + from);
}```