Architecture 002

Inspired by: machine.arm sketch 149
instagram.com/p/dawupp4ybsn/

Log in to post a comment.

// Architecture 002 by Rupert Russell
// 8 November 2025
// Inspired by: machine.arm sketch 149
// https://www.instagram.com/p/DAWUpp4ybsN/


// You can find the Turtle API reference here: https://turtletoy.net/syntax
Canvas.setpenopacity(1);
// const drawmode = 2;  // min=1, max=2, step=1

const test=0;
const test2=0;

const drawmode = 2; // min=0, max=2, step=1, (Black Lines, White Lines, Both)
const outline = 0; // min=0, max=1, step=1, (Yes, No)

const turtle = new Turtle();

const numLines = 44; //min=5 max=50 step=1

// const xx1 = -48; //min=-100 max=100 step=1
// const yy1 = -43; //min=-100 max=100 step=1
// const xx2 = 55;  //min=-100 max=100 step=1
// const yy2 = 46;  //min=-100 max=100 step=1

// const xx3 = -22; //min=-100 max=100 step=1
// const yy3 = -2; //min=-100 max=100 step=1
// const xx4 = 27;  //min=-100 max=100 step=1
// const yy4 = 24;  //min=-100 max=100 step=1

const corners = [
    {x1:-48, y1:-43, x2:55, y2:46, x3:-22, y3:-2, x4:27, y4:24},
    {x1:-48, y1:-79, x2:43, y2:-43, x3:-26, y3:-65, x4:26, y4:-54},
    {x1:43, y1:-79, x2:88, y2:-43, x3:54, y3:-65, x4:69, y4:-54},
    {x1:55, y1:-43, x2:97, y2:46, x3:65, y3:-2, x4:81, y4:24},
    {x1:-48, y1:46, x2:97, y2:94, x3:-18, y3:65, x4:81, y4:85},
    {x1:-81, y1:-79, x2:-48, y2:94, x3:-70, y3:-52, x4:-60, y4:85},
    //{x1:xx1, y1:yy1, x2:xx2, y2:yy2, x3:xx3, y3:yy3, x4:xx4, y4:yy4},
];

for (let corner of corners) { // Loop through each rectangle
    if(outline == 0){
        rectangle(corner.x1, corner.y1, corner.x2, corner.y2);
        rectangle(corner.x3, corner.y3, corner.x4, corner.y4);
    }

    if(drawmode == 1){
        whiteLines(corner.x1, corner.y1, corner.x2, corner.y2, corner.x3, corner.y3, corner.x4, corner.y4);
    }
    else if(drawmode == 0){
        blackLines(corner.x1, corner.y1, corner.x2, corner.y2, corner.x3, corner.y3, corner.x4, corner.y4);
    }
    else{
        whiteLines(corner.x1, corner.y1, corner.x2, corner.y2, corner.x3, corner.y3, corner.x4, corner.y4);
        blackLines(corner.x1, corner.y1, corner.x2, corner.y2, corner.x3, corner.y3, corner.x4, corner.y4);
    }
}   

function rectangle(xA,yA,xB,yB){
    // top line
    turtle.penup();
    turtle.goto(xA,yA); 
    turtle.pendown();  
    turtle.goto(xB,yA); 
    
    // bottom line
    turtle.penup();
    turtle.goto(xA,yB); 
    turtle.pendown();  
    turtle.goto(xB,yB); 
    
    // left line
    turtle.penup();
    turtle.goto(xA,yA); 
    turtle.pendown();  
    turtle.goto(xA,yB); 
    
    //right line
    turtle.penup();
    turtle.goto(xB,yA); 
    turtle.pendown();  
    turtle.goto(xB,yB);
} // end rectangle

function whiteLines(xA,yA,xB,yB,xC,yC,xD,yD){
    //  Top and Right sides of rectangles

    var baseHeight = yA-yB;
    
    var topWidth = xC-xD;
    var topHeight = yC-yD;
    
    // Outer edges
    // top left corners
    turtle.penup();
    turtle.goto(xA,yA); 
    turtle.pendown();
    turtle.goto(xC,yC)
    
    //top right corners
    turtle.penup();
    turtle.goto(xB,yA); 
    turtle.pendown();
    turtle.goto(xD,yC)
    
    // divide the top line into x equal segments
    var baseWidth = Math.abs(xA-xB);
    var topGap = baseWidth / numLines;

    var topWidth = Math.abs(xC-xD);
    var bottomGap = topWidth / numLines;
    var baseHeight = Math.abs(yA-yB);
    
    var rightHeight = Math.abs(yA-yB);
    var leftHeight = Math.abs(yC-yD);
    
    var topSideGap = leftHeight / numLines;
    var bottomSideGap = rightHeight / numLines;
    
    // Loop though numLines to draw Top White lines
    for(j=0; j<=numLines; j++){
        turtle.penup();
        turtle.goto(xA+j*topGap, yA);
        turtle.pendown();
        turtle.goto(xC+j*bottomGap,yC);
    } // end top White lines
    
    // Loop though numLines to draw Side White lines
    for(j=0; j<=numLines; j++){
        turtle.penup();
        turtle.goto(xD,yC+j*topSideGap);
        turtle.pendown();
        turtle.goto(xB,yA+j*bottomSideGap);
    } // end top White lines
}



function blackLines(xA,yA,xB,yB,xC,yC,xD,yD){
    var baseHeight = yA-yB;
    
    var topWidth = xC-xD;
    var topHeight = yC-yD;

    // divide the top line into x equal segments
    var baseWidth = Math.abs(xA-xB);
    var topGap = baseWidth / numLines;

    var topWidth = Math.abs(xC-xD);
    var bottomGap = topWidth / numLines;
    var baseHeight = Math.abs(yA-yB);
    
    var rightHeight = Math.abs(yA-yB);
    var leftHeight = Math.abs(yC-yD);
    
    var topSideGap = leftHeight / numLines;
    var bottomSideGap = rightHeight / numLines;
    
    
    // Loop though numLines to draw left side Black lines
    for(j=0; j<=numLines; j++){
        turtle.penup();
        turtle.goto(xC,yC+j*topSideGap);
        turtle.pendown();
        turtle.goto(xA,yA+j*bottomSideGap);
    } // end top White lines
    
    // Loop though numLines to draw Bottom Black lines
    for(j=0; j<=numLines; j++){
        turtle.penup();
        turtle.goto(xA+j*topGap, yB);
        turtle.pendown();
        turtle.goto(xC+j*bottomGap,yD);
    } // end top black lines
}