Hard Coded Coordinates in this one.
Using Console Log from Grid 011
Grid 011
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
const opacity = -1; // min=-1, max=1, step=0.1
if(opacity == 0){
Canvas.setpenopacity(-0.1);
}
else{
Canvas.setpenopacity(opacity); // -1=Black background 1=White Background
}
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 = 20; //min=2 max=20 step=1
// const hNum = 1; //min=1 max=10 step=1
// const vNum = 1; //min=1 max=10 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: -90, y1: -90, x2: -31, y2: -41, x3: -56, y3: -72, x4: -46, y4: -64, hNum: 2, vNum: 2},
{x1: -31, y1: -90, x2: -5, y2: -75, x3: -21, y3: -83, x4: -16, y4: -80, hNum: 1, vNum: 1},
{x1: -5, y1: -95, x2: 32, y2: -75, x3: 5, y3: -85, x4: 19, y4: -80, hNum: 1, vNum: 1},
{x1: 32, y1: -90, x2: 95, y2: -41, x3: 56, y3: -74, x4: 73, y4: -59, hNum: 2.5, vNum: 2.5},
{x1: -31, y1: -75, x2: 17, y2: -41, x3: -21, y3: -64, x4: 6, y4: -52, hNum: 3, vNum: 3},
{x1: 17, y1: -75, x2: 32, y2: -41, x3: 19, y3: -64, x4: 24, y4: -52, hNum: 1, vNum: 0.8},
{x1: -95, y1: -41, x2: -64, y2: 10, x3: -80, y3: -13, x4: -74, y4: -5, hNum: 1, vNum: 2},
{x1: -64, y1: -41, x2: -31, y2: 10, x3: -54, y3: -27, x4: -42, y4: -15, hNum: 1, vNum: 2},
{x1: -31, y1: -41, x2: -5, y2: 10, x3: -21, y3: -25, x4: -16, y4: -1, hNum: 1, vNum: 3},
{x1: -5, y1: -41, x2: 32, y2: 10, x3: 13, y3: -27, x4: 20, y4: -1, hNum: 1, vNum: 2},
{x1: 32, y1: -41, x2: 58, y2: 10, x3: 43, y3: -28, x4: 48, y4: -3, hNum: 1, vNum: 3},
{x1: 58, y1: -41, x2: 90, y2: -13, x3: 70, y3: -31, x4: 77, y4: -23, hNum: 1, vNum: 1.5},
{x1: 58, y1: -13, x2: 95, y2: 10, x3: 74, y3: -5, x4: 79, y4: 0, hNum: 1, vNum: 0.8},
{x1: -95, y1: 10, x2: -31, y2: 67, x3: -61, y3: 25, x4: -44, y4: 53, hNum: 2, vNum: 3},
{x1: -31, y1: 10, x2: 17, y2: 44, x3: -16, y3: 20, x4: 6, y4: 34, hNum: 2, vNum: 2},
{x1: 17, y1: 10, x2: 32, y2: 67, x3: 20, y3: 31, x4: 25, y4: 56, hNum: 1, vNum: 1},
{x1: 32, y1: 10, x2: 58, y2: 44, x3: 43, y3: 24, x4: 48, y4: 33, hNum: 1, vNum: 1},
{x1: 58, y1: 10, x2: 90, y2: 67, x3: 71, y3: 31, x4: 80, y4: 51, hNum: 1, vNum: 3},
{x1: -31, y1: 44, x2: -5, y2: 67, x3: -21, y3: 53, x4: -16, y4: 58, hNum: 1, vNum: 1},
{x1: -5, y1: 44, x2: 17, y2: 90, x3: 4, y3: 62, x4: 9, y4: 77, hNum: 1, vNum: 1},
{x1: 32, y1: 44, x2: 58, y2: 67, x3: 43, y3: 54, x4: 48, y4: 59, hNum: 1, vNum: 1},
{x1: -90, y1: 67, x2: -64, y2: 90, x3: -80, y3: 76, x4: -74, y4: 81, hNum: 1, vNum: 1},
{x1: -64, y1: 67, x2: -31, y2: 90, x3: -48, y3: 75, x4: -42, y4: 80, hNum: 1, vNum: 1},
{x1: -31, y1: 67, x2: -5, y2: 85, x3: -21, y3: 73, x4: -15, y4: 79, hNum: 1, vNum: 1},
{x1: 17, y1: 67, x2: 58, y2: 90, x3: 36, y3: 76, x4: 45, y4: 81, hNum: 1, vNum: 1},
{x1: 58, y1: 67, x2: 95, y2: 95, x3: 72, y3: 76, x4: 80, y4: 81, hNum: 1, vNum: 1}
];
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, corner.hNum, corner.vNum);
}
else if(drawmode == 0){
blackLines(corner.x1, corner.y1, corner.x2, corner.y2, corner.x3, corner.y3, corner.x4, corner.y4, corner.hNum, corner.vNum);
}
else{
whiteLines(corner.x1, corner.y1, corner.x2, corner.y2, corner.x3, corner.y3, corner.x4, corner.y4, corner.hNum, corner.vNum);
blackLines(corner.x1, corner.y1, corner.x2, corner.y2, corner.x3, corner.y3, corner.x4, corner.y4, corner.hNum, corner.vNum);
}
}
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,hNum,vNum){
// 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 * hNum); j++){
turtle.penup();
turtle.goto(xA+j*topGap / hNum, yA);
turtle.pendown();
turtle.goto(xC+j*bottomGap / hNum,yC);
} // end top White lines
// Loop though numLines to draw Side White lines
for(j=0; j<=(numLines * vNum); j++){
turtle.penup();
turtle.goto(xD,yC+j*topSideGap / vNum);
turtle.pendown();
turtle.goto(xB,yA+j*bottomSideGap / vNum);
} // end top White lines
}
function blackLines(xA,yA,xB,yB,xC,yC,xD,yD,hNum,vNum){
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 * vNum); j++){
turtle.penup();
turtle.goto(xC,yC+j*topSideGap / vNum);
turtle.pendown();
turtle.goto(xA,yA+j*bottomSideGap / vNum);
} // end top White lines
// Loop though numLines to draw Bottom Black lines
for(j=0; j<=(numLines * hNum); j++){
turtle.penup();
turtle.goto(xA+j*topGap / hNum, yB);
turtle.pendown();
turtle.goto(xC+j*bottomGap / hNum,yD);
} // end top black lines
}