2021-10-08 17:32:12 +02:00
export default function ( part ) {
let {
Point ,
points ,
Path ,
paths ,
measurements ,
options ,
macro ,
complete ,
snippets ,
Snippet ,
sa ,
paperless ,
} = part . shorthand ( )
// define some variables
let width
if ( options . width === 'ToElbow' ) {
width = measurements . shoulderToElbow
}
if ( options . width === 'ToMidArm' ) {
width = measurements . shoulderToElbow / 2
}
if ( options . width === 'ToShoulder' ) {
width = 0
} // careful! takes other measurements if those are bigger to ensure that the tunica actually fits your body, use forceWidth if you know what you're doing
let hem _pos
if ( options . length === 'ToKnee' ) {
hem _pos = measurements . waistToKnee
}
if ( options . length === 'ToMidLeg' ) {
hem _pos = measurements . waistToKnee / 1.3
} //UpperLeg}
if ( options . length === 'ToFloor' ) {
hem _pos = measurements . waistToFloor * 0.95
}
let hwidth = ( measurements . shoulderToShoulder / 2 + width ) * options . widthBonus
let length = ( measurements . hpsToWaistBack + hem _pos ) * options . lengthBonus
let hhead = ( measurements . head / 4 ) * options . headRatio
let armhole = ( measurements . biceps / 2 ) * 1.3 * options . armholeDrop
let clavusPos = hhead * options . clavusPosBonus
let clavusWidth = ( options . clavusWidth * hwidth ) / 13 / options . widthBonus
// some checks, can be circumvented with forceWidth
if ( options . forceWidth === false ) {
if ( hwidth < measurements . waist / 4 ) {
hwidth = ( measurements . waist / 4 ) * options . widthBonus
}
if ( hwidth < measurements . hips / 4 ) {
hwidth = ( measurements . hips / 4 ) * options . widthBonus
2021-09-13 22:03:08 +02:00
}
2021-10-08 17:32:12 +02:00
if ( hwidth < measurements . chest / 4 ) {
hwidth = ( measurements . chest / 4 ) * options . widthBonus
}
if ( hwidth < measurements . seat / 4 ) {
hwidth = ( measurements . seat / 4 ) * options . widthBonus
}
}
// make points
points . top = new Point ( 0 , 0 )
points . bottom = new Point ( 0 , length )
points . topLeft = points . top . shift ( 0 , - hwidth )
points . bottomLeft = points . bottom . shift ( 0 , points . bottom . dx ( points . topLeft ) )
points . headLeft = points . top . shift ( 180 , hhead )
points . armholeLeft = points . topLeft . shift ( - 90 , armhole )
// draw paths
paths . seam = new Path ( )
. move ( points . top )
. line ( points . topLeft )
. line ( points . bottomLeft )
. attr ( 'class' , 'fabric' )
paths . hem = new Path ( ) . move ( points . bottomLeft ) . line ( points . bottom ) . attr ( 'class' , 'fabric' )
paths . fold = new Path ( ) . move ( points . bottom ) . line ( points . top ) . attr ( 'class' , 'fabric' )
// clavi
if ( options . clavi ) {
2021-09-13 22:03:08 +02:00
// make points
2021-10-08 17:32:12 +02:00
points . clavusTopRight = points . top . shift ( 180 , clavusPos )
points . clavusBottomRight = points . bottom . shift ( 0 , points . top . dx ( points . clavusTopRight ) )
points . clavusTopLeft = points . clavusTopRight . shift ( 180 , clavusWidth )
points . clavusBottomLeft = points . bottom . shift ( 0 , points . top . dx ( points . clavusTopLeft ) )
2021-09-13 22:03:08 +02:00
// draw paths
2021-10-08 17:32:12 +02:00
paths . clavusRight = new Path ( )
. move ( points . clavusTopRight )
. line ( points . clavusBottomRight )
. attr ( 'class' , 'various dashed' )
paths . clavusLeft = new Path ( )
. move ( points . clavusTopLeft )
. line ( points . clavusBottomLeft )
. attr ( 'class' , 'various dashed' )
. attr ( 'data-text' , 'BiasTape' )
. attr ( 'data-text-class' , 'center fill-various' )
}
// Complete?
if ( complete ) {
// notches
snippets . hl = new Snippet ( 'notch' , points . headLeft )
snippets . al = new Snippet ( 'notch' , points . armholeLeft )
// cut on fold
macro ( 'cutonfold' , {
from : points . bottom ,
to : points . top ,
grainline : true ,
} )
// logo & title
points . logo = points . top . shift ( 45 , points . bottom . dy ( points . top ) / 3 )
snippets . logo = new Snippet ( 'logo' , points . logo )
points . title = points . logo . shift ( 90 , points . bottom . dy ( points . top ) / 4 )
macro ( 'title' , {
at : points . title ,
nr : 1 ,
title : 'tunica' ,
} )
points . _ _titleNr . attr ( 'data-text-class' , 'center' )
points . _ _titleName . attr ( 'data-text-class' , 'center' )
points . _ _titlePattern . attr ( 'data-text-class' , 'center' )
// scalebox
points . scalebox = points . title . shift ( 90 , points . bottom . dy ( points . top ) / 5 )
macro ( 'scalebox' , { at : points . scalebox } )
// seam allowance
if ( sa ) {
paths . sa = paths . seam
. offset ( sa )
. join ( paths . hem . offset ( sa * 2.5 ) )
. close ( )
. attr ( 'class' , 'fabric sa' )
2021-09-13 22:03:08 +02:00
}
2021-10-08 17:32:12 +02:00
// Paperless?
if ( paperless ) {
macro ( 'vd' , {
from : points . top ,
to : points . bottom ,
x : points . bottomLeft . x + 10 ,
} )
macro ( 'vd' , {
from : points . armholeLeft ,
to : points . bottomLeft ,
x : points . armholeLeft . x - 15 ,
} )
macro ( 'vd' , {
from : points . topLeft ,
to : points . armholeLeft ,
x : points . armholeLeft . x - 15 ,
} )
macro ( 'hd' , {
from : points . topLeft ,
to : points . top ,
y : points . top . y + 15 ,
} )
macro ( 'hd' , {
from : points . headLeft ,
to : points . top ,
y : points . top . y - 15 ,
} )
macro ( 'hd' , {
from : points . topLeft ,
to : points . headLeft ,
y : points . top . y - 15 ,
} )
// for clavi
if ( options . clavi ) {
macro ( 'hd' , {
from : points . clavusTopLeft ,
to : points . clavusTopRight ,
y : points . clavusTopLeft . y + 25 ,
} )
macro ( 'hd' , {
from : points . clavusTopRight ,
to : points . headLeft ,
y : points . clavusTopRight . y + 25 ,
} )
macro ( 'hd' , {
from : points . topLeft ,
to : points . clavusTopLeft ,
y : points . clavusTopLeft . y + 25 ,
} )
macro ( 'hd' , {
from : points . clavusTopRight ,
to : points . top ,
y : points . clavusTopLeft . y + 30 ,
} )
}
2021-09-13 22:03:08 +02:00
}
2021-10-08 17:32:12 +02:00
}
return part
2021-09-13 22:03:08 +02:00
}