Impossible Triangle

To Do:
1. Remove unnecessary lines from the square buffers that makes 'L' shapes.
2. Find way to paint/plot color black.
3. Find way to paint/plot color grey.

Log in to post a comment.

const size = 60;
const t = new Turtle();

function walk(i)
{
    pos = [0, 0];
    impossibleTriangle(size);
}


function drawSquare(a, b, c, d)
/*
    a----c  0----2
    \    \  \    \
    \    \  \    \
    b----d  1----3
*/
{
    t.penup();
    t.jump(a[0], a[1]);
    t.pendown();
    
    t.goto(b[0], b[1]);
    t.goto(d[0], d[1]);
    t.goto(c[0], c[1]);
    t.goto(a[0], a[1]);
    t.penup();
}

function impossibleTriangle(size)
{
    // Paint Black:
    drawSquare([size * -1.0, size * -0.72], [size * -0.84, size * -1],
               [size * -0.16, size * 0.81], [size * 0.0, size * 0.53]);
               
    drawSquare([size * 0, size * 0.53], [size * -0.15, size * 0.27],
               [size * 0.54, size * -0.44], [size * 0.24, size * -0.44]);
               
    // Paint Grey:
    drawSquare([size * 0.15, size * 0.81], [size * -0.16, size * 0.81],
               [size * 1, size * -0.72], [size * 0.7, size * -0.72]);
               
    drawSquare([size * -0.235, size * -0.44], [size * -0.39, size * -0.72],
               [size * 0.84, size * -0.44], [size * 0.7, size * -0.72]);
               
    // Paint White:
    drawSquare([size * -0.686, size * -0.72], [size * -0.84, size * -1],
               [size * 1, size * -0.72], [size * 0.84, size * -1]);           
               
    drawSquare([size * -0.84, size * -1], [size * -0.54, size * -1],
               [size * -0.15, size * 0.27], [size * 0.0, size * -0.0]);  
               
}