Fancy-turning 003

Working on duplicating a design from 1869
publicdomainreview.org/collection/fancy-turning/
pdr-assets.b-cdn.net…g?fit=max&w=2400
Specimens of Fancy Turning
Edward J. Woolsey, 1869

Log in to post a comment.

// --------------------------------------
// Fancy-turning  002.1
// You can find the Turtle API reference here: https://turtletoy.net/syntax
// Released under the MIT licence 
// https://mit-license.org/
// you can use this for commercial gain if you like eg you can sell artworks with this image.

// Working on duplicating a design from 1869
// https://publicdomainreview.org/collection/fancy-turning/
// https://pdr-assets.b-cdn.net/collections/fancy-turning/lathe-patterns-00002.jpg?fit=max&w=2400
// Specimens of Fancy Turning
// Edward J. Woolsey, 1869

Canvas.setpenopacity(1);

// Global code will be evaluated once.
const turtle = new Turtle();
const h = 0; 
const k3 = 32; // //min=1 max=110 step=1
const group3Radius = 37; // //min=1 max=110 step=1
const numberOfPoints = 8; 
const circleRadius = 29; // //min=8 max=60 step=1

const circleRadius3 = 10; // //min=8 max=12 step=1
const xOffset = 0; // //min=-10 max=20 step=1
const yOffset = -32; // // min=-160 max=20 step=1
const step = 1; // //min=0.3 max=1.20 step=0.1

const angle0 = -90; // //min=-360 max=360 step=.1
const angle1 = -135.15; // //min=-360 max=360 step=.1
const angle2 = -180; // //min=-360 max=360 step=.1
const angle3 = 135.15; // //min=-360 max=360 step=.1
const angle4 = 90; // //min=-360 max=360 step=.1
const angle5 = 45; // //min=-360 max=360 step=.1
const angle6 = 0; // //min=-360 max=360 step=.1
const angle7 = -45; // //min=-360 max=360 step=.1
const rotate2 = 322; // //min=-360 max=360 step=.1
const rotate3 = -85.4; // //min=-360 max=360 step=.1

var x;
var y;
var degree = 0;

const inner = 5; // // min=1 max=15 step=1
const innerStep = 1.7; // // min=0.5 max=5 step=0.1

// Draw 14 central circles 
for(n=0; n<13; n++){
    centerCircle(inner + n * innerStep)
}

// Draw n points around a circle group1
for (i = 0; i < numberOfPoints; i++) {
     k1 = 32
     x = h + circleRadius * Math.cos(degrees_to_radians(degree));
     y = k1 - circleRadius * Math.sin(degrees_to_radians(degree));
     
    // turtle.circle(Pointradius)
    group001(i,x,y);
    degree = degree + 360 / numberOfPoints;
}

// Draw n points around a circle group2
for (i = 0; i < numberOfPoints; i++) {

     x = h + 32 * Math.cos(degrees_to_radians(degree + rotate2));
     y = 32 - (32 * Math.sin(degrees_to_radians(degree + rotate2)));
     
    // turtle.circle(Pointradius)
    group002(i,x,y);
    degree = degree + 360 / numberOfPoints;
}

// Draw n points around a circle group3
for (i = 0; i < numberOfPoints; i++) {

     x = h + group3Radius * Math.cos(degrees_to_radians(degree + rotate3));
     y = k3 - (group3Radius * Math.sin(degrees_to_radians(degree + rotate3)));
     
    // turtle.circle(Pointradius)
    group003(i,x,y);
    degree = degree + 360 / numberOfPoints;
}

function degrees_to_radians(degrees) {
  return degrees * (Math.PI / 180);
}

function group001(i,x,y){
     var radius = 10;
    
    if (i == 0){
        turtle.seth(-90);
    }
    else if (i == 1){
        turtle.seth(-135.15);
    }
        else if (i == 2){
        turtle.seth(-180);
    }
        else if (i == 3){
        turtle.seth(135.15);
    }
        else if (i == 4){
        turtle.seth(90);
    }
        else if (i == 5){
        turtle.seth(45);
    }
        else if (i == 6){
        turtle.seth(0);
    }
        else if (i == 7){
        turtle.seth(-45);
    }
    
    turtle.penup();
    turtle.goto(x + xOffset, y + yOffset);
    turtle.pendown();

    // turtle.circle(Pointradius)
    for (x=1 ; x < 14; x=x+1){
        turtle.circle(radius);
        radius = radius + step;
    }
}  // end function group003(i,x,y)

function group002(i,x,y){
     var radius = 22;
    
    if (i == 0){
        turtle.seth(angle0);
    }
    else if (i == 1){
        turtle.seth(angle1);
    }
        else if (i == 2){
        turtle.seth(angle2);
    }
        else if (i == 3){
        turtle.seth(angle3);
    }
        else if (i == 4){
        turtle.seth(angle4);
    }
        else if (i == 5){
        turtle.seth(angle5);
    }
        else if (i == 6){
        turtle.seth(angle6);
    }
        else if (i == 7){
        turtle.seth(angle7);
    }
    
    turtle.penup();
    turtle.goto(x + xOffset, y + yOffset);
    turtle.pendown();

    // turtle.circle(Pointradius)
   turtle.circle(radius);
    
}  // end function group002(i,x,y)

function group003(i,x,y){
     var radius = circleRadius3;
    
    if (i == 0){
        turtle.seth(angle0);
    }
    else if (i == 1){
        turtle.seth(angle1);
    }
        else if (i == 2){
        turtle.seth(angle2);
    }
        else if (i == 3){
        turtle.seth(angle3);
    }
        else if (i == 4){
        turtle.seth(angle4);
    }
        else if (i == 5){
        turtle.seth(angle5);
    }
        else if (i == 6){
        turtle.seth(angle6);
    }
        else if (i == 7){
        turtle.seth(angle7);
    }
    
    turtle.penup();
    turtle.goto(x + xOffset, y + yOffset);
    turtle.pendown();

    // turtle.circle(Pointradius)
   turtle.circle(radius);
}  // end function group003(i,x,y)

function centerCircle(radius){
    // Offset Y North Radius distance
    turtle.penup()
    turtle.seth(270)
    turtle.forward(radius)

    turtle.pendown()
    turtle.seth(0)
    turtle.circle(radius)
    turtle.penup()
    
    // return to starting point
    turtle.seth(90)
    turtle.forward(radius)
}