Hitomezashi 002

Hitomezashi 002
From page 145 of Make + Mend by Jessica Marquez
ISBN 978-0-399-57943-1
#Hitomezashi

Log in to post a comment.

// Hitomezashi Pattern
// by Rupert Russell v002
// Horizontal Rows (Yokogushi)
// Ten Cross Stitch (Jujizashi)
// Marquez, J. (2018). *Make + Mend: Sashiko‑Inspired embroidery projects to customize and repair textiles and decorate your home*. Watson‑Guptill. ([biblio.ie][1])
// https://biblio.ie/9780399579431?utm_source=chatgpt.com 
// https://turtletoy.net/turtle/005b61831a
// You can find the Turtle API reference here: https://turtletoy.net/syntax
Canvas.setpenopacity(1);
const turtle = new Turtle();
const xTotal=24; // min=9 max=50 step=3
// There is a bug with even lines of code not offseting correctly I am not sure why :-)
const yCount=47; // min=1 max=100 step=2 
const size=3.97; // min=2 max=6 step=0.01
const xMargin=5; /// min=5 max=50 step=1
const yMargin=5; /// min=5 max=250 step=1
let group = 0;
turtle.penup();
turtle.goto(-100 + xMargin,-100 + yMargin);
let numOfX = xTotal / 3 

 for(let x=0; x < 3; x++){
     for(y=0; y<= yCount; y++){
        column();
        group ++;
        if(group >= 5){
        group = 0;
        SplitRow(y)
        }
    }
}

function column() {
    turtle.penup();
    turtle.setheading(0) // East
    for(let x=0; x < numOfX; x++){
        turtle.pendown();
        turtle.forward(size);
        
        // Ten Cross
        if(group >= 2){
            turtle.penup();
            turtle.back(size /2);
            turtle.setheading(90); // S
            turtle.forward(size /2);
            turtle.setheading(270); // N
            turtle.pendown();
            turtle.forward(size);
            turtle.penup();
            turtle.back(size /2); // Back to Center of Star
            turtle.setheading(0); // E
            turtle.forward(size /2);
            turtle.setheading(270); // N
        
            // Star 
            if(group >= 3){
                turtle.setheading(180); // W
                turtle.forward(size /2); 
                turtle.setheading(45); // SE
                turtle.penup()
                turtle.forward(size / 2);
                turtle.setheading(225); // NW
                turtle.pendown();
                turtle.forward(size);
                turtle.setheading(45); // SE
                turtle.penup()
                turtle.forward(size / 2); // Back to Center of Star
                turtle.setheading(315); // SW
                turtle.penup()
                turtle.forward(size / 2);
                turtle.setheading(135); // NW
                turtle.pendown();
                turtle.forward(size);
                turtle.penup()
                turtle.setheading(315); // N
                turtle.forward(size /2);
                turtle.setheading(0); // E
                turtle.forward(size /2);
            }
            turtle.setheading(0); // E
        }
        turtle.penup();
        turtle.forward(size);
    }
    group++;
    }

function SplitRow(x){
    turtle.penup()
    turtle.goto(-100 + xMargin,turtle.ycor());
    turtle.setheading(90); // S
    turtle.forward(size); // move down a row
    turtle.setheading(0); // E
    if (x % 2 == 0){
        turtle.forward(size); // even rows offset one space
    } 
}