diff --git a/packages/aaron/example/src/App.js b/packages/aaron/example/src/App.js index e7936330e5d..115cdf683af 100644 --- a/packages/aaron/example/src/App.js +++ b/packages/aaron/example/src/App.js @@ -1,22 +1,15 @@ -import React from "react"; -import freesewing from "@freesewing/core"; -import Workbench from "@freesewing/components/Workbench"; -import "typeface-roboto-condensed"; -import "@freesewing/css-theme"; +import React from 'react' +import freesewing from '@freesewing/core' +import Workbench from '@freesewing/components/Workbench' +import 'typeface-roboto-condensed' +import '@freesewing/css-theme' -import Pattern from "pattern"; +import Pattern from 'pattern' const App = props => { - let instance = new Pattern(); - let config = instance.config; - return ( - - ); -}; + let instance = new Pattern() + let config = instance.config + return +} -export default App; +export default App diff --git a/packages/aaron/example/src/index.js b/packages/aaron/example/src/index.js index 7900787a4d2..9dd7ba788d4 100644 --- a/packages/aaron/example/src/index.js +++ b/packages/aaron/example/src/index.js @@ -1,11 +1,11 @@ -import React from "react"; -import ReactDOM from "react-dom"; -import App from "./App"; -import * as serviceWorker from "./serviceWorker"; +import React from 'react' +import ReactDOM from 'react-dom' +import App from './App' +import * as serviceWorker from './serviceWorker' -ReactDOM.render(, document.getElementById("root")); +ReactDOM.render(, document.getElementById('root')) // If you want your app to work offline and load faster, you can change // unregister() to register() below. Note this comes with some pitfalls. // Learn more about service workers: http://bit.ly/CRA-PWA -serviceWorker.unregister(); +serviceWorker.unregister() diff --git a/packages/aaron/example/src/serviceWorker.js b/packages/aaron/example/src/serviceWorker.js index 68fda5a0eb6..44e1b1b2f8c 100644 --- a/packages/aaron/example/src/serviceWorker.js +++ b/packages/aaron/example/src/serviceWorker.js @@ -9,46 +9,44 @@ // This link also includes instructions on opting out of this behavior. const isLocalhost = Boolean( - window.location.hostname === "localhost" || + window.location.hostname === 'localhost' || // [::1] is the IPv6 localhost address. - window.location.hostname === "[::1]" || + window.location.hostname === '[::1]' || // 127.0.0.1/8 is considered localhost for IPv4. - window.location.hostname.match( - /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ - ) -); + window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/) +) export function register(config) { - if (process.env.NODE_ENV === "production" && "serviceWorker" in navigator) { + if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) { // The URL constructor is available in all browsers that support SW. - const publicUrl = new URL(process.env.PUBLIC_URL, window.location); + const publicUrl = new URL(process.env.PUBLIC_URL, window.location) if (publicUrl.origin !== window.location.origin) { // Our service worker won't work if PUBLIC_URL is on a different origin // from what our page is served on. This might happen if a CDN is used to // serve assets; see https://github.com/facebook/create-react-app/issues/2374 - return; + return } - window.addEventListener("load", () => { - const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; + window.addEventListener('load', () => { + const swUrl = `${process.env.PUBLIC_URL}/service-worker.js` if (isLocalhost) { // This is running on localhost. Let's check if a service worker still exists or not. - checkValidServiceWorker(swUrl, config); + checkValidServiceWorker(swUrl, config) // Add some additional logging to localhost, pointing developers to the // service worker/PWA documentation. navigator.serviceWorker.ready.then(() => { console.log( - "This web app is being served cache-first by a service " + - "worker. To learn more, visit https://goo.gl/SC7cgQ" - ); - }); + 'This web app is being served cache-first by a service ' + + 'worker. To learn more, visit https://goo.gl/SC7cgQ' + ) + }) } else { // Is not local host. Just register service worker - registerValidSW(swUrl, config); + registerValidSW(swUrl, config) } - }); + }) } } @@ -57,38 +55,38 @@ function registerValidSW(swUrl, config) { .register(swUrl) .then(registration => { registration.onupdatefound = () => { - const installingWorker = registration.installing; + const installingWorker = registration.installing installingWorker.onstatechange = () => { - if (installingWorker.state === "installed") { + if (installingWorker.state === 'installed') { if (navigator.serviceWorker.controller) { // At this point, the old content will have been purged and // the fresh content will have been added to the cache. // It's the perfect time to display a "New content is // available; please refresh." message in your web app. - console.log("New content is available; please refresh."); + console.log('New content is available; please refresh.') // Execute callback if (config.onUpdate) { - config.onUpdate(registration); + config.onUpdate(registration) } } else { // At this point, everything has been precached. // It's the perfect time to display a // "Content is cached for offline use." message. - console.log("Content is cached for offline use."); + console.log('Content is cached for offline use.') // Execute callback if (config.onSuccess) { - config.onSuccess(registration); + config.onSuccess(registration) } } } - }; - }; + } + } }) .catch(error => { - console.error("Error during service worker registration:", error); - }); + console.error('Error during service worker registration:', error) + }) } function checkValidServiceWorker(swUrl, config) { @@ -98,30 +96,28 @@ function checkValidServiceWorker(swUrl, config) { // Ensure service worker exists, and that we really are getting a JS file. if ( response.status === 404 || - response.headers.get("content-type").indexOf("javascript") === -1 + response.headers.get('content-type').indexOf('javascript') === -1 ) { // No service worker found. Probably a different app. Reload the page. navigator.serviceWorker.ready.then(registration => { registration.unregister().then(() => { - window.location.reload(); - }); - }); + window.location.reload() + }) + }) } else { // Service worker found. Proceed as normal. - registerValidSW(swUrl, config); + registerValidSW(swUrl, config) } }) .catch(() => { - console.log( - "No internet connection found. App is running in offline mode." - ); - }); + console.log('No internet connection found. App is running in offline mode.') + }) } export function unregister() { - if ("serviceWorker" in navigator) { + if ('serviceWorker' in navigator) { navigator.serviceWorker.ready.then(registration => { - registration.unregister(); - }); + registration.unregister() + }) } } diff --git a/packages/aaron/src/back.js b/packages/aaron/src/back.js index ac79bd459c9..283094797a2 100644 --- a/packages/aaron/src/back.js +++ b/packages/aaron/src/back.js @@ -1,4 +1,4 @@ -import { dimensions } from "./shared"; +import { dimensions } from './shared' export default function(part) { let { @@ -14,23 +14,23 @@ export default function(part) { macro, utils, units - } = part.shorthand(); + } = part.shorthand() points.strapLeftCp2 = utils.beamsIntersect( points.strapLeft, points.strapCenter.rotate(90, points.strapLeft), points.cbNeck, points.cbNeck.shift(0, 10) - ); + ) points.armholeCp2 = points.aaronArmhole.shiftFractionTowards( points.armholeCorner, options.backlineBend - ); + ) points.strapRightCp1 = points.strapRight.shiftFractionTowards( points.armholeCorner, options.backlineBend - ); + ) // Seamline paths.seam = new Path() @@ -43,7 +43,7 @@ export default function(part) { .line(points.strapLeft) .curve(points.strapLeftCp2, points.cbNeck, points.cbNeck) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') // Complete pattern? if (complete) { @@ -51,57 +51,54 @@ export default function(part) { new Path() .move(points.strapLeft) .curve(points.strapLeftCp2, points.cbNeck, points.cbNeck) - .length() + store.get("frontNeckOpeningLength"); + .length() + store.get('frontNeckOpeningLength') let armholeLength = new Path() .move(points.aaronArmhole) .curve(points.armholeCp2, points.strapRightCp1, points.strapRight) - .length() + store.get("frontArmholeLength"); - points.bindinAnchor = new Point( - points.aaronArmhole.x / 4, - points.aaronArmhole.y - ) - .attr("data-text", "cutTwoStripsToFinishTheArmholes") - .attr("data-text", ":\n") - .attr("data-text", "width") - .attr("data-text", ":") - .attr("data-text", units(sa * 6)) - .attr("data-text", "\n") - .attr("data-text", "length") - .attr("data-text", ":") - .attr("data-text", units(armholeLength * 0.95 + 2 * sa)) - .attr("data-text", "\n \n") - .attr("data-text", "cutOneStripToFinishTheNeckOpening") - .attr("data-text", ":\n") - .attr("data-text", "width") - .attr("data-text", ":") - .attr("data-text", units(sa * 6)) - .attr("data-text", "\n") - .attr("data-text", "length") - .attr("data-text", ":") - .attr("data-text", units(neckOpeningLength * 0.95 + 2 * sa)) - .attr("data-text-lineheight", 6); + .length() + store.get('frontArmholeLength') + points.bindinAnchor = new Point(points.aaronArmhole.x / 4, points.aaronArmhole.y) + .attr('data-text', 'cutTwoStripsToFinishTheArmholes') + .attr('data-text', ':\n') + .attr('data-text', 'width') + .attr('data-text', ':') + .attr('data-text', units(sa * 6)) + .attr('data-text', '\n') + .attr('data-text', 'length') + .attr('data-text', ':') + .attr('data-text', units(armholeLength * 0.95 + 2 * sa)) + .attr('data-text', '\n \n') + .attr('data-text', 'cutOneStripToFinishTheNeckOpening') + .attr('data-text', ':\n') + .attr('data-text', 'width') + .attr('data-text', ':') + .attr('data-text', units(sa * 6)) + .attr('data-text', '\n') + .attr('data-text', 'length') + .attr('data-text', ':') + .attr('data-text', units(neckOpeningLength * 0.95 + 2 * sa)) + .attr('data-text-lineheight', 6) - macro("cutonfold", { + macro('cutonfold', { from: points.cfNeck, to: points.cfHem, grainline: true - }); + }) - macro("title", { at: points.title, nr: 2, title: "back" }); - points.scaleboxAnchor = points.scalebox = points.title.shift(90, 100); - macro("scalebox", { at: points.scalebox }); + macro('title', { at: points.title, nr: 2, title: 'back' }) + points.scaleboxAnchor = points.scalebox = points.title.shift(90, 100) + macro('scalebox', { at: points.scalebox }) } // Paperless? if (paperless) { - dimensions(macro, points, sa); - macro("vd", { + dimensions(macro, points, sa) + macro('vd', { from: points.cbHem, to: points.cbNeck, x: points.cbHem.x - sa - 15 - }); + }) } - return part; + return part } diff --git a/packages/aaron/src/front.js b/packages/aaron/src/front.js index e4260852ffe..3f7fed4dbb9 100644 --- a/packages/aaron/src/front.js +++ b/packages/aaron/src/front.js @@ -1,4 +1,4 @@ -import { dimensions } from "./shared"; +import { dimensions } from './shared' export default function(part) { let { @@ -16,75 +16,67 @@ export default function(part) { complete, paperless, macro - } = part.shorthand(); + } = part.shorthand() // Hide Brian paths - for (let key of Object.keys(paths)) paths[key].render = false; + for (let key of Object.keys(paths)) paths[key].render = false // Handle stretch - for (let i in points) points[i].x = points[i].x * (1 - options.stretchFactor); + for (let i in points) points[i].x = points[i].x * (1 - options.stretchFactor) // Rename cb (center back) to cf (center front) - for (let key of ["Neck", "Shoulder", "Armhole", "Waist", "Hips", "Hem"]) { - points[`cf${key}`] = new Point(points[`cb${key}`].x, points[`cb${key}`].y); + for (let key of ['Neck', 'Shoulder', 'Armhole', 'Waist', 'Hips', 'Hem']) { + points[`cf${key}`] = new Point(points[`cb${key}`].x, points[`cb${key}`].y) //delete points[`cb${key}`]; } // Neckline points.cfNeck = points.cfNeck.shift( -90, - options.necklineDrop * - (measurements.centerBackNeckToWaist + measurements.naturalWaistToHip) - ); + options.necklineDrop * (measurements.centerBackNeckToWaist + measurements.naturalWaistToHip) + ) // Strap points.strapCenter = points.neck.shiftFractionTowards( points.shoulder, options.shoulderStrapPlacement - ); + ) points.strapLeft = points.strapCenter.shiftTowards( points.neck, points.neck.dist(points.shoulder) * options.shoulderStrapWidth - ); - points.strapRight = points.strapLeft.rotate(180, points.strapCenter); + ) + points.strapRight = points.strapLeft.rotate(180, points.strapCenter) points.necklineCorner = utils.beamsIntersect( points.strapLeft, points.strapRight.rotate(-90, points.strapLeft), points.cfNeck.shift(0, points.armholePitch.x / 4), points.cfNeck - ); + ) points.strapLeftCp2 = points.strapLeft.shiftFractionTowards( points.necklineCorner, options.necklineBend - ); - points.cfNeckCp1 = points.cfNeck.shiftFractionTowards( - points.necklineCorner, - options.necklineBend - ); + ) + points.cfNeckCp1 = points.cfNeck.shiftFractionTowards(points.necklineCorner, options.necklineBend) // Hips points.hips.x = - ((measurements.hipsCircumference + - options.hipsEase * measurements.hipsCircumference) / - 4) * - (1 - options.stretchFactor); - points.waist.x = points.hips.x; // Because stretch - points.waistCp2 = points.waist.shift(90, points.armhole.dy(points.waist) / 2); + ((measurements.hipsCircumference + options.hipsEase * measurements.hipsCircumference) / 4) * + (1 - options.stretchFactor) + points.waist.x = points.hips.x // Because stretch + points.waistCp2 = points.waist.shift(90, points.armhole.dy(points.waist) / 2) // Hem - points.hem.x = points.hips.x; + points.hem.x = points.hips.x // Armhole drop let side = new Path() .move(points.hem) .line(points.waist) - .curve(points.waistCp2, points.armhole, points.armhole); - let split = side - .intersectsY(points.armhole.y * (1 + options.armholeDrop)) - .pop(); - paths.side = side.split(split)[0]; - paths.side.render = false; - points.aaronArmhole = split; + .curve(points.waistCp2, points.armhole, points.armhole) + let split = side.intersectsY(points.armhole.y * (1 + options.armholeDrop)).pop() + paths.side = side.split(split)[0] + paths.side.render = false + points.aaronArmhole = split // Armhole points.armholeCorner = utils.beamsIntersect( @@ -92,15 +84,9 @@ export default function(part) { points.aaronArmhole.shift(180, 10), points.strapRight, points.strapLeft.rotate(90, points.strapRight) - ); - points.armholeCp2 = points.aaronArmhole.shiftFractionTowards( - points.armholeCorner, - 0.8 - ); - points.strapRightCp1 = points.strapRight.shiftFractionTowards( - points.armholeCorner, - 0.6 - ); + ) + points.armholeCp2 = points.aaronArmhole.shiftFractionTowards(points.armholeCorner, 0.8) + points.strapRightCp1 = points.strapRight.shiftFractionTowards(points.armholeCorner, 0.6) // Seamline paths.seam = new Path() @@ -113,35 +99,35 @@ export default function(part) { .line(points.strapLeft) .curve(points.strapLeftCp2, points.cfNeckCp1, points.cfNeck) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') // Store length of armhole and neck opening store.set( - "frontArmholeLength", + 'frontArmholeLength', new Path() .move(points.aaronArmhole) .curve(points.armholeCp2, points.strapRightCp1, points.strapRight) .length() - ); + ) store.set( - "frontNeckOpeningLength", + 'frontNeckOpeningLength', new Path() .move(points.strapLeft) .curve(points.cfNeckCp1, points.cfNeckCp1, points.cfNeck) .length() - ); + ) // Complete pattern? if (complete) { - macro("cutonfold", { + macro('cutonfold', { from: points.cfNeck, to: points.cfHem, grainline: true - }); - points.title = new Point(points.waist.x / 2, points.waist.y); - macro("title", { at: points.title, nr: 1, title: "front" }); - points.logo = points.title.shift(-90, 75); - snippets.logo = new Snippet("logo", points.logo); + }) + points.title = new Point(points.waist.x / 2, points.waist.y) + macro('title', { at: points.title, nr: 1, title: 'front' }) + points.logo = points.title.shift(-90, 75) + snippets.logo = new Snippet('logo', points.logo) if (sa) { paths.saShoulder = new Path() @@ -149,31 +135,31 @@ export default function(part) { .line(points.strapLeft) .offset(sa) .line(points.strapLeft) - .attr("class", "fabric sa"); - paths.saShoulder.move(points.strapRight).line(paths.saShoulder.start()); + .attr('class', 'fabric sa') + paths.saShoulder.move(points.strapRight).line(paths.saShoulder.start()) paths.saSide = paths.side .offset(sa) .line(points.aaronArmhole) - .attr("class", "fabric sa"); + .attr('class', 'fabric sa') paths.saHem = new Path() .move(points.cfHem) .line(points.hem) .offset(sa * 2.5) - .attr("class", "fabric sa") - .line(paths.saSide.start()); - paths.saHem.move(points.cfHem).line(paths.saHem.start()); + .attr('class', 'fabric sa') + .line(paths.saSide.start()) + paths.saHem.move(points.cfHem).line(paths.saHem.start()) } } // Paperless? if (paperless) { - dimensions(macro, points, sa); - macro("vd", { + dimensions(macro, points, sa) + macro('vd', { from: points.cfHem, to: points.cfNeck, x: points.cfHem.x - sa - 15 - }); + }) } - return part; + return part } diff --git a/packages/aaron/src/index.js b/packages/aaron/src/index.js index 9d385931bc7..62f543970f2 100644 --- a/packages/aaron/src/index.js +++ b/packages/aaron/src/index.js @@ -1,20 +1,20 @@ -import freesewing from "@freesewing/core"; -import Brian from "@freesewing/brian"; -import plugins from "@freesewing/plugin-bundle"; -import config from "../config"; +import freesewing from '@freesewing/core' +import Brian from '@freesewing/brian' +import plugins from '@freesewing/plugin-bundle' +import config from '../config' // Parts -import draftBack from "./back"; -import draftFront from "./front"; +import draftBack from './back' +import draftFront from './front' // Create design -const Pattern = new freesewing.Design(config, plugins); +const Pattern = new freesewing.Design(config, plugins) // Attach draft methods to prototype Pattern.prototype.draftBase = function(part) { // Getting the base part from Brian - return new Brian(this.settings).draftBase(part); -}; -Pattern.prototype.draftFront = part => draftFront(part); -Pattern.prototype.draftBack = part => draftBack(part); + return new Brian(this.settings).draftBase(part) +} +Pattern.prototype.draftFront = part => draftFront(part) +Pattern.prototype.draftBack = part => draftBack(part) -export default Pattern; +export default Pattern diff --git a/packages/aaron/src/shared.js b/packages/aaron/src/shared.js index 32b0c5df11a..99144fb44ea 100644 --- a/packages/aaron/src/shared.js +++ b/packages/aaron/src/shared.js @@ -1,37 +1,37 @@ export function dimensions(macro, points, sa) { - macro("hd", { + macro('hd', { from: points.cfHem, to: points.hem, y: points.hem.y + sa * 2.5 + 15 - }); - macro("hd", { + }) + macro('hd', { from: points.cfNeck, to: points.strapLeft, y: points.neck.y - sa - 15 - }); - macro("hd", { + }) + macro('hd', { from: points.cfNeck, to: points.strapRight, y: points.neck.y - sa - 30 - }); - macro("vd", { + }) + macro('vd', { from: points.hem, to: points.aaronArmhole, x: points.aaronArmhole.x + sa + 15 - }); - macro("vd", { + }) + macro('vd', { from: points.hem, to: points.strapRight, x: points.aaronArmhole.x + sa + 30 - }); - macro("vd", { + }) + macro('vd', { from: points.hem, to: points.strapLeft, x: points.aaronArmhole.x + sa + 45 - }); - macro("hd", { + }) + macro('hd', { from: points.cfNeck, to: points.aaronArmhole, y: points.neck.y - sa - 45 - }); + }) } diff --git a/packages/benjamin/example/src/App.js b/packages/benjamin/example/src/App.js index e7936330e5d..115cdf683af 100644 --- a/packages/benjamin/example/src/App.js +++ b/packages/benjamin/example/src/App.js @@ -1,22 +1,15 @@ -import React from "react"; -import freesewing from "@freesewing/core"; -import Workbench from "@freesewing/components/Workbench"; -import "typeface-roboto-condensed"; -import "@freesewing/css-theme"; +import React from 'react' +import freesewing from '@freesewing/core' +import Workbench from '@freesewing/components/Workbench' +import 'typeface-roboto-condensed' +import '@freesewing/css-theme' -import Pattern from "pattern"; +import Pattern from 'pattern' const App = props => { - let instance = new Pattern(); - let config = instance.config; - return ( - - ); -}; + let instance = new Pattern() + let config = instance.config + return +} -export default App; +export default App diff --git a/packages/benjamin/example/src/index.js b/packages/benjamin/example/src/index.js index 7900787a4d2..9dd7ba788d4 100644 --- a/packages/benjamin/example/src/index.js +++ b/packages/benjamin/example/src/index.js @@ -1,11 +1,11 @@ -import React from "react"; -import ReactDOM from "react-dom"; -import App from "./App"; -import * as serviceWorker from "./serviceWorker"; +import React from 'react' +import ReactDOM from 'react-dom' +import App from './App' +import * as serviceWorker from './serviceWorker' -ReactDOM.render(, document.getElementById("root")); +ReactDOM.render(, document.getElementById('root')) // If you want your app to work offline and load faster, you can change // unregister() to register() below. Note this comes with some pitfalls. // Learn more about service workers: http://bit.ly/CRA-PWA -serviceWorker.unregister(); +serviceWorker.unregister() diff --git a/packages/benjamin/example/src/serviceWorker.js b/packages/benjamin/example/src/serviceWorker.js index 68fda5a0eb6..44e1b1b2f8c 100644 --- a/packages/benjamin/example/src/serviceWorker.js +++ b/packages/benjamin/example/src/serviceWorker.js @@ -9,46 +9,44 @@ // This link also includes instructions on opting out of this behavior. const isLocalhost = Boolean( - window.location.hostname === "localhost" || + window.location.hostname === 'localhost' || // [::1] is the IPv6 localhost address. - window.location.hostname === "[::1]" || + window.location.hostname === '[::1]' || // 127.0.0.1/8 is considered localhost for IPv4. - window.location.hostname.match( - /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ - ) -); + window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/) +) export function register(config) { - if (process.env.NODE_ENV === "production" && "serviceWorker" in navigator) { + if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) { // The URL constructor is available in all browsers that support SW. - const publicUrl = new URL(process.env.PUBLIC_URL, window.location); + const publicUrl = new URL(process.env.PUBLIC_URL, window.location) if (publicUrl.origin !== window.location.origin) { // Our service worker won't work if PUBLIC_URL is on a different origin // from what our page is served on. This might happen if a CDN is used to // serve assets; see https://github.com/facebook/create-react-app/issues/2374 - return; + return } - window.addEventListener("load", () => { - const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; + window.addEventListener('load', () => { + const swUrl = `${process.env.PUBLIC_URL}/service-worker.js` if (isLocalhost) { // This is running on localhost. Let's check if a service worker still exists or not. - checkValidServiceWorker(swUrl, config); + checkValidServiceWorker(swUrl, config) // Add some additional logging to localhost, pointing developers to the // service worker/PWA documentation. navigator.serviceWorker.ready.then(() => { console.log( - "This web app is being served cache-first by a service " + - "worker. To learn more, visit https://goo.gl/SC7cgQ" - ); - }); + 'This web app is being served cache-first by a service ' + + 'worker. To learn more, visit https://goo.gl/SC7cgQ' + ) + }) } else { // Is not local host. Just register service worker - registerValidSW(swUrl, config); + registerValidSW(swUrl, config) } - }); + }) } } @@ -57,38 +55,38 @@ function registerValidSW(swUrl, config) { .register(swUrl) .then(registration => { registration.onupdatefound = () => { - const installingWorker = registration.installing; + const installingWorker = registration.installing installingWorker.onstatechange = () => { - if (installingWorker.state === "installed") { + if (installingWorker.state === 'installed') { if (navigator.serviceWorker.controller) { // At this point, the old content will have been purged and // the fresh content will have been added to the cache. // It's the perfect time to display a "New content is // available; please refresh." message in your web app. - console.log("New content is available; please refresh."); + console.log('New content is available; please refresh.') // Execute callback if (config.onUpdate) { - config.onUpdate(registration); + config.onUpdate(registration) } } else { // At this point, everything has been precached. // It's the perfect time to display a // "Content is cached for offline use." message. - console.log("Content is cached for offline use."); + console.log('Content is cached for offline use.') // Execute callback if (config.onSuccess) { - config.onSuccess(registration); + config.onSuccess(registration) } } } - }; - }; + } + } }) .catch(error => { - console.error("Error during service worker registration:", error); - }); + console.error('Error during service worker registration:', error) + }) } function checkValidServiceWorker(swUrl, config) { @@ -98,30 +96,28 @@ function checkValidServiceWorker(swUrl, config) { // Ensure service worker exists, and that we really are getting a JS file. if ( response.status === 404 || - response.headers.get("content-type").indexOf("javascript") === -1 + response.headers.get('content-type').indexOf('javascript') === -1 ) { // No service worker found. Probably a different app. Reload the page. navigator.serviceWorker.ready.then(registration => { registration.unregister().then(() => { - window.location.reload(); - }); - }); + window.location.reload() + }) + }) } else { // Service worker found. Proceed as normal. - registerValidSW(swUrl, config); + registerValidSW(swUrl, config) } }) .catch(() => { - console.log( - "No internet connection found. App is running in offline mode." - ); - }); + console.log('No internet connection found. App is running in offline mode.') + }) } export function unregister() { - if ("serviceWorker" in navigator) { + if ('serviceWorker' in navigator) { navigator.serviceWorker.ready.then(registration => { - registration.unregister(); - }); + registration.unregister() + }) } } diff --git a/packages/benjamin/src/base.js b/packages/benjamin/src/base.js index f553f930045..ebcd4f9b270 100644 --- a/packages/benjamin/src/base.js +++ b/packages/benjamin/src/base.js @@ -13,122 +13,114 @@ export default function(part) { complete, paperless, macro - } = part.shorthand(); + } = part.shorthand() - if (options.bowStyle === "square") options.tipWidth = options.knotWidth; + if (options.bowStyle === 'square') options.tipWidth = options.knotWidth for (let option of [ - "ribbonWidth", - "bandLength", - "tipWidth", - "knotWidth", - "bowLength", - "collarEase" + 'ribbonWidth', + 'bandLength', + 'tipWidth', + 'knotWidth', + 'bowLength', + 'collarEase' ]) - store.set(option, measurements.neckCircumference * options[option]); + store.set(option, measurements.neckCircumference * options[option]) // For easy access - const knot = store.get("knotWidth"); - const ribbon = store.get("ribbonWidth"); - const tip = store.get("tipWidth"); - const band = store.get("bandLength"); - const transition = band * options.transitionLength; - const bow = store.get("bowLength"); + const knot = store.get('knotWidth') + const ribbon = store.get('ribbonWidth') + const tip = store.get('tipWidth') + const band = store.get('bandLength') + const transition = band * options.transitionLength + const bow = store.get('bowLength') // Points - points.bandBottomLeft = new Point(0, ribbon / 2); - points.bandTopLeft = points.bandBottomLeft.flipY(); - points.bandBottomRight = points.bandBottomLeft.shift(0, band); - points.bandTopRight = points.bandBottomRight.flipY(); + points.bandBottomLeft = new Point(0, ribbon / 2) + points.bandTopLeft = points.bandBottomLeft.flipY() + points.bandBottomRight = points.bandBottomLeft.shift(0, band) + points.bandTopRight = points.bandBottomRight.flipY() - points.transitionBottomRight = new Point(band + transition, knot / 2); - points.transitionTopRight = points.transitionBottomRight.flipY(); + points.transitionBottomRight = new Point(band + transition, knot / 2) + points.transitionTopRight = points.transitionBottomRight.flipY() - points.tip1Bottom = new Point(band + transition + 0.5 * bow, tip / 2); - points.tip1Top = points.tip1Bottom.flipY(); - points.tip2Bottom = new Point(band + transition + 1.5 * bow, tip / 2); - points.tip2Top = points.tip2Bottom.flipY(); - points.knotBottom = new Point(band + transition + bow, knot / 2); - points.knotTop = points.knotBottom.flipY(); + points.tip1Bottom = new Point(band + transition + 0.5 * bow, tip / 2) + points.tip1Top = points.tip1Bottom.flipY() + points.tip2Bottom = new Point(band + transition + 1.5 * bow, tip / 2) + points.tip2Top = points.tip2Bottom.flipY() + points.knotBottom = new Point(band + transition + bow, knot / 2) + points.knotTop = points.knotBottom.flipY() - if (options.endStyle === "pointed" || options.endStyle === "rounded") { - points.tip = new Point(points.tip2Bottom.x + points.tip2Bottom.y, 0); - } else points.tip = new Point(points.tip2Bottom.x, 0); + if (options.endStyle === 'pointed' || options.endStyle === 'rounded') { + points.tip = new Point(points.tip2Bottom.x + points.tip2Bottom.y, 0) + } else points.tip = new Point(points.tip2Bottom.x, 0) - points.grainlineStart = new Point(0, 0); - points.titleAnchor = new Point(points.tip1Top.x, 0); + points.grainlineStart = new Point(0, 0) + points.titleAnchor = new Point(points.tip1Top.x, 0) // Paths - paths.cap = new Path().move(points.tip2Bottom); - if (options.endStyle === "straight") { - paths.cap = new Path().move(points.tip2Bottom).line(points.tip2Top); - } else if (options.endStyle === "pointed") { + paths.cap = new Path().move(points.tip2Bottom) + if (options.endStyle === 'straight') { + paths.cap = new Path().move(points.tip2Bottom).line(points.tip2Top) + } else if (options.endStyle === 'pointed') { paths.cap = new Path() .move(points.tip2Bottom) .line(points.tip) - .line(points.tip2Top); + .line(points.tip2Top) } else { - points.roundBottom = new Point(points.tip.x, points.tip2Bottom.y); - points.roundTop = points.roundBottom.flipY(); - macro("round", { + points.roundBottom = new Point(points.tip.x, points.tip2Bottom.y) + points.roundTop = points.roundBottom.flipY() + macro('round', { from: points.tip2Bottom, to: points.tip, via: points.roundBottom, - prefix: "bottom" - }); - macro("round", { + prefix: 'bottom' + }) + macro('round', { from: points.tip, to: points.tip2Top, via: points.roundTop, - prefix: "top" - }); - paths.cap = paths.bottomRounded.join(paths.topRounded); + prefix: 'top' + }) + paths.cap = paths.bottomRounded.join(paths.topRounded) } - paths.cap.render = false; + paths.cap.render = false - if (options.bowStyle === "diamond" || options.bowStyle === "butterfly") { - const cpl = options.bowStyle === "diamond" ? bow / 10 : bow / 4; + if (options.bowStyle === 'diamond' || options.bowStyle === 'butterfly') { + const cpl = options.bowStyle === 'diamond' ? bow / 10 : bow / 4 points.transitionBottomRightCp2 = points.bandBottomRight.shiftOutwards( points.transitionBottomRight, cpl - ); - points.transitionTopRightCp1 = points.transitionBottomRightCp2.flipY(); - points.tip1TopCp2 = points.tip1Top.shift(180, cpl); - points.tip1TopCp1 = points.tip1Top.shift(0, cpl); - points.tip1BottomCp1 = points.tip1Bottom.shift(180, cpl); - points.tip1BottomCp2 = points.tip1Bottom.shift(0, cpl); - points.knotTopCp2 = points.knotTop.shift(180, cpl); - points.knotTopCp1 = points.knotTop.shift(0, cpl); - points.knotBottomCp2 = points.knotBottom.shift(0, cpl); - points.knotBottomCp1 = points.knotBottom.shift(180, cpl); - points.tip2TopCp2 = points.tip2Top.shift(180, cpl); - points.tip2BottomCp1 = points.tip2Bottom.shift(180, cpl); + ) + points.transitionTopRightCp1 = points.transitionBottomRightCp2.flipY() + points.tip1TopCp2 = points.tip1Top.shift(180, cpl) + points.tip1TopCp1 = points.tip1Top.shift(0, cpl) + points.tip1BottomCp1 = points.tip1Bottom.shift(180, cpl) + points.tip1BottomCp2 = points.tip1Bottom.shift(0, cpl) + points.knotTopCp2 = points.knotTop.shift(180, cpl) + points.knotTopCp1 = points.knotTop.shift(0, cpl) + points.knotBottomCp2 = points.knotBottom.shift(0, cpl) + points.knotBottomCp1 = points.knotBottom.shift(180, cpl) + points.tip2TopCp2 = points.tip2Top.shift(180, cpl) + points.tip2BottomCp1 = points.tip2Bottom.shift(180, cpl) paths.seam = new Path() .move(points.bandTopLeft) .line(points.bandBottomLeft) .line(points.bandBottomRight) .line(points.transitionBottomRight) - .curve( - points.transitionBottomRightCp2, - points.tip1BottomCp1, - points.tip1Bottom - ) + .curve(points.transitionBottomRightCp2, points.tip1BottomCp1, points.tip1Bottom) .curve(points.tip1BottomCp2, points.knotBottomCp1, points.knotBottom) .curve(points.knotBottomCp2, points.tip2BottomCp1, points.tip2Bottom) .join(paths.cap) .line(points.tip2Top) .curve(points.tip2TopCp2, points.knotTopCp1, points.knotTop) .curve(points.knotTopCp2, points.tip1TopCp1, points.tip1Top) - .curve( - points.tip1TopCp2, - points.transitionTopRightCp1, - points.transitionTopRight - ) + .curve(points.tip1TopCp2, points.transitionTopRightCp1, points.transitionTopRight) .line(points.bandTopRight) .line(points.bandTopLeft) - .close(); + .close() } else { paths.seam = new Path() .move(points.bandTopLeft) @@ -141,85 +133,82 @@ export default function(part) { .line(points.transitionTopRight) .line(points.bandTopRight) .line(points.bandTopLeft) - .close(); + .close() } - paths.seam.attr("class", "fabric"); + paths.seam.attr('class', 'fabric') // Complete? if (complete) { - if (sa) paths.sa = paths.seam.offset(sa).attr("class", "fabric sa"); + if (sa) paths.sa = paths.seam.offset(sa).attr('class', 'fabric sa') - macro("grainline", { + macro('grainline', { from: points.grainlineStart, to: points.tip - }); - points.logoAnchor = points.tip.shift(180, 20); - snippets.logo = new Snippet("logo", points.logoAnchor).attr( - "data-scale", - 0.5 - ); + }) + points.logoAnchor = points.tip.shift(180, 20) + snippets.logo = new Snippet('logo', points.logoAnchor).attr('data-scale', 0.5) // Paperless? if (paperless) { - let baseY = points.tip2Bottom.y + 15 + sa; - if (options.bowStyle === "butterfly" || options.bowStyle === "diamond") { - macro("hd", { + let baseY = points.tip2Bottom.y + 15 + sa + if (options.bowStyle === 'butterfly' || options.bowStyle === 'diamond') { + macro('hd', { from: points.knotBottom, to: points.tip2Bottom, y: baseY - }); - baseY += 15; - macro("hd", { + }) + baseY += 15 + macro('hd', { from: points.tip1Bottom, to: points.tip2Bottom, y: baseY - }); - baseY += 15; - macro("vd", { + }) + baseY += 15 + macro('vd', { from: points.tip1Bottom, to: points.tip1Top - }); + }) } - macro("hd", { + macro('hd', { from: points.transitionBottomRight, to: points.tip2Bottom, y: baseY - }); - baseY += 15; - macro("hd", { + }) + baseY += 15 + macro('hd', { from: points.bandBottomRight, to: points.tip2Bottom, y: baseY - }); - baseY += 15; - macro("hd", { + }) + baseY += 15 + macro('hd', { from: points.bandBottomLeft, to: points.tip2Bottom, y: baseY - }); - macro("vd", { + }) + macro('vd', { from: points.bandBottomRight, to: points.bandTopRight - }); - macro("vd", { + }) + macro('vd', { from: points.transitionBottomRight, to: points.transitionTopRight - }); - macro("vd", { + }) + macro('vd', { from: points.tip2Bottom, to: points.tip2Top, x: points.tip.x + 15 + sa - }); - if (options.endStyle !== "straight") { - macro("hd", { + }) + if (options.endStyle !== 'straight') { + macro('hd', { from: points.tip2Bottom, to: points.tip, y: points.tip2Bottom.y + 15 + sa - }); + }) } } } - return part; + return part } diff --git a/packages/benjamin/src/bow1.js b/packages/benjamin/src/bow1.js index be2004a65f2..6aef8e6b0da 100644 --- a/packages/benjamin/src/bow1.js +++ b/packages/benjamin/src/bow1.js @@ -1,19 +1,19 @@ export default function(part) { - let { complete, macro, points, paths, sa } = part.shorthand(); + let { complete, macro, points, paths, sa } = part.shorthand() - paths.seam.render = true; + paths.seam.render = true if (complete) { - if (sa) paths.sa.render = true; - macro("title", { + if (sa) paths.sa.render = true + macro('title', { at: points.titleAnchor, nr: 1, - title: "bowTie", + title: 'bowTie', scale: 0.8 - }); - points.scaleboxAnchor = points.bandTopLeft.shift(30, 80); - macro("scalebox", { at: points.scaleboxAnchor }); + }) + points.scaleboxAnchor = points.bandTopLeft.shift(30, 80) + macro('scalebox', { at: points.scaleboxAnchor }) } - return part; + return part } diff --git a/packages/benjamin/src/bow2.js b/packages/benjamin/src/bow2.js index 86e3a96b26c..b518dd22587 100644 --- a/packages/benjamin/src/bow2.js +++ b/packages/benjamin/src/bow2.js @@ -1,22 +1,22 @@ export default function(part) { - let { options, points, paths, complete, macro, sa } = part.shorthand(); + let { options, points, paths, complete, macro, sa } = part.shorthand() if (options.adjustmentRibbon) { - part.render = false; - return part; + part.render = false + return part } - paths.seam.render = true; + paths.seam.render = true if (complete) { - if (sa) paths.sa.render = true; - macro("title", { + if (sa) paths.sa.render = true + macro('title', { at: points.titleAnchor, nr: 2, - title: "bowTie", + title: 'bowTie', scale: 0.8 - }); + }) } - return part; + return part } diff --git a/packages/benjamin/src/bow3.js b/packages/benjamin/src/bow3.js index 62529471ea3..4a9e7a612ea 100644 --- a/packages/benjamin/src/bow3.js +++ b/packages/benjamin/src/bow3.js @@ -1,20 +1,20 @@ export default function(part) { - let { options, points, paths, complete, macro, sa } = part.shorthand(); + let { options, points, paths, complete, macro, sa } = part.shorthand() if (options.adjustmentRibbon) { - part.render = false; - return part; + part.render = false + return part } if (complete) { - if (sa) paths.sa.render = true; - macro("title", { + if (sa) paths.sa.render = true + macro('title', { at: points.titleAnchor, nr: 3, - title: "bowTie", + title: 'bowTie', scale: 0.8 - }); + }) } - return part; + return part } diff --git a/packages/benjamin/src/index.js b/packages/benjamin/src/index.js index c3661de3c80..91cffd95727 100644 --- a/packages/benjamin/src/index.js +++ b/packages/benjamin/src/index.js @@ -1,21 +1,21 @@ -import freesewing from "@freesewing/core"; -import plugins from "@freesewing/plugin-bundle"; -import config from "../config"; +import freesewing from '@freesewing/core' +import plugins from '@freesewing/plugin-bundle' +import config from '../config' // Parts -import draftBase from "./base"; -import draftBow1 from "./bow1"; -import draftBow2 from "./bow2"; -import draftBow3 from "./bow3"; -import draftRibbon from "./ribbon"; +import draftBase from './base' +import draftBow1 from './bow1' +import draftBow2 from './bow2' +import draftBow3 from './bow3' +import draftRibbon from './ribbon' // Create new design -const benjamin = new freesewing.Design(config, plugins); +const benjamin = new freesewing.Design(config, plugins) // Attach draft methods to prototype -benjamin.prototype.draftBase = draftBase; -benjamin.prototype.draftBow1 = draftBow1; -benjamin.prototype.draftBow2 = draftBow2; -benjamin.prototype.draftBow3 = draftBow3; -benjamin.prototype.draftRibbon = draftRibbon; +benjamin.prototype.draftBase = draftBase +benjamin.prototype.draftBow1 = draftBow1 +benjamin.prototype.draftBow2 = draftBow2 +benjamin.prototype.draftBow3 = draftBow3 +benjamin.prototype.draftRibbon = draftRibbon -export default benjamin; +export default benjamin diff --git a/packages/benjamin/src/ribbon.js b/packages/benjamin/src/ribbon.js index 5af08339fc2..e805b159603 100644 --- a/packages/benjamin/src/ribbon.js +++ b/packages/benjamin/src/ribbon.js @@ -11,26 +11,20 @@ export default function(part) { paths, sa, paperless - } = part.shorthand(); + } = part.shorthand() if (!options.adjustmentRibbon) { - part.render = false; - return part; + part.render = false + return part } // Points - points.bottomLeft = new Point(0, 0.5 * store.get("ribbonWidth")); - points.topLeft = points.bottomLeft.flipY(); + points.bottomLeft = new Point(0, 0.5 * store.get('ribbonWidth')) + points.topLeft = points.bottomLeft.flipY() // FIXME: How long should this adjustment ribbon be? - points.bottomRight = points.bottomLeft.shift( - 0, - measurements.neckCircumference - ); - points.topRight = points.bottomRight.flipY(); - points.titleAnchor = points.topLeft.shiftFractionTowards( - points.bottomRight, - 0.5 - ); + points.bottomRight = points.bottomLeft.shift(0, measurements.neckCircumference) + points.topRight = points.bottomRight.flipY() + points.titleAnchor = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5) // Paths paths.seam = new Path() @@ -40,30 +34,30 @@ export default function(part) { .line(points.topRight) .line(points.topLeft) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') if (complete) { - if (sa) paths.sa = paths.seam.offset(sa).attr("class", "fabric sa"); - macro("title", { + if (sa) paths.sa = paths.seam.offset(sa).attr('class', 'fabric sa') + macro('title', { at: points.titleAnchor, nr: 4, - title: "ribbon", + title: 'ribbon', scale: 0.5 - }); + }) if (paperless) { - macro("hd", { + macro('hd', { from: points.bottomLeft, to: points.bottomRight, y: points.bottomLeft.y + 15 + sa - }); - macro("vd", { + }) + macro('vd', { from: points.bottomRight, to: points.topRight, x: points.topRight.x + 15 + sa - }); + }) } } - return part; + return part } diff --git a/packages/bent/example/src/App.js b/packages/bent/example/src/App.js index e7936330e5d..115cdf683af 100644 --- a/packages/bent/example/src/App.js +++ b/packages/bent/example/src/App.js @@ -1,22 +1,15 @@ -import React from "react"; -import freesewing from "@freesewing/core"; -import Workbench from "@freesewing/components/Workbench"; -import "typeface-roboto-condensed"; -import "@freesewing/css-theme"; +import React from 'react' +import freesewing from '@freesewing/core' +import Workbench from '@freesewing/components/Workbench' +import 'typeface-roboto-condensed' +import '@freesewing/css-theme' -import Pattern from "pattern"; +import Pattern from 'pattern' const App = props => { - let instance = new Pattern(); - let config = instance.config; - return ( - - ); -}; + let instance = new Pattern() + let config = instance.config + return +} -export default App; +export default App diff --git a/packages/bent/example/src/index.js b/packages/bent/example/src/index.js index 7900787a4d2..9dd7ba788d4 100644 --- a/packages/bent/example/src/index.js +++ b/packages/bent/example/src/index.js @@ -1,11 +1,11 @@ -import React from "react"; -import ReactDOM from "react-dom"; -import App from "./App"; -import * as serviceWorker from "./serviceWorker"; +import React from 'react' +import ReactDOM from 'react-dom' +import App from './App' +import * as serviceWorker from './serviceWorker' -ReactDOM.render(, document.getElementById("root")); +ReactDOM.render(, document.getElementById('root')) // If you want your app to work offline and load faster, you can change // unregister() to register() below. Note this comes with some pitfalls. // Learn more about service workers: http://bit.ly/CRA-PWA -serviceWorker.unregister(); +serviceWorker.unregister() diff --git a/packages/bent/example/src/serviceWorker.js b/packages/bent/example/src/serviceWorker.js index 68fda5a0eb6..44e1b1b2f8c 100644 --- a/packages/bent/example/src/serviceWorker.js +++ b/packages/bent/example/src/serviceWorker.js @@ -9,46 +9,44 @@ // This link also includes instructions on opting out of this behavior. const isLocalhost = Boolean( - window.location.hostname === "localhost" || + window.location.hostname === 'localhost' || // [::1] is the IPv6 localhost address. - window.location.hostname === "[::1]" || + window.location.hostname === '[::1]' || // 127.0.0.1/8 is considered localhost for IPv4. - window.location.hostname.match( - /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ - ) -); + window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/) +) export function register(config) { - if (process.env.NODE_ENV === "production" && "serviceWorker" in navigator) { + if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) { // The URL constructor is available in all browsers that support SW. - const publicUrl = new URL(process.env.PUBLIC_URL, window.location); + const publicUrl = new URL(process.env.PUBLIC_URL, window.location) if (publicUrl.origin !== window.location.origin) { // Our service worker won't work if PUBLIC_URL is on a different origin // from what our page is served on. This might happen if a CDN is used to // serve assets; see https://github.com/facebook/create-react-app/issues/2374 - return; + return } - window.addEventListener("load", () => { - const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; + window.addEventListener('load', () => { + const swUrl = `${process.env.PUBLIC_URL}/service-worker.js` if (isLocalhost) { // This is running on localhost. Let's check if a service worker still exists or not. - checkValidServiceWorker(swUrl, config); + checkValidServiceWorker(swUrl, config) // Add some additional logging to localhost, pointing developers to the // service worker/PWA documentation. navigator.serviceWorker.ready.then(() => { console.log( - "This web app is being served cache-first by a service " + - "worker. To learn more, visit https://goo.gl/SC7cgQ" - ); - }); + 'This web app is being served cache-first by a service ' + + 'worker. To learn more, visit https://goo.gl/SC7cgQ' + ) + }) } else { // Is not local host. Just register service worker - registerValidSW(swUrl, config); + registerValidSW(swUrl, config) } - }); + }) } } @@ -57,38 +55,38 @@ function registerValidSW(swUrl, config) { .register(swUrl) .then(registration => { registration.onupdatefound = () => { - const installingWorker = registration.installing; + const installingWorker = registration.installing installingWorker.onstatechange = () => { - if (installingWorker.state === "installed") { + if (installingWorker.state === 'installed') { if (navigator.serviceWorker.controller) { // At this point, the old content will have been purged and // the fresh content will have been added to the cache. // It's the perfect time to display a "New content is // available; please refresh." message in your web app. - console.log("New content is available; please refresh."); + console.log('New content is available; please refresh.') // Execute callback if (config.onUpdate) { - config.onUpdate(registration); + config.onUpdate(registration) } } else { // At this point, everything has been precached. // It's the perfect time to display a // "Content is cached for offline use." message. - console.log("Content is cached for offline use."); + console.log('Content is cached for offline use.') // Execute callback if (config.onSuccess) { - config.onSuccess(registration); + config.onSuccess(registration) } } } - }; - }; + } + } }) .catch(error => { - console.error("Error during service worker registration:", error); - }); + console.error('Error during service worker registration:', error) + }) } function checkValidServiceWorker(swUrl, config) { @@ -98,30 +96,28 @@ function checkValidServiceWorker(swUrl, config) { // Ensure service worker exists, and that we really are getting a JS file. if ( response.status === 404 || - response.headers.get("content-type").indexOf("javascript") === -1 + response.headers.get('content-type').indexOf('javascript') === -1 ) { // No service worker found. Probably a different app. Reload the page. navigator.serviceWorker.ready.then(registration => { registration.unregister().then(() => { - window.location.reload(); - }); - }); + window.location.reload() + }) + }) } else { // Service worker found. Proceed as normal. - registerValidSW(swUrl, config); + registerValidSW(swUrl, config) } }) .catch(() => { - console.log( - "No internet connection found. App is running in offline mode." - ); - }); + console.log('No internet connection found. App is running in offline mode.') + }) } export function unregister() { - if ("serviceWorker" in navigator) { + if ('serviceWorker' in navigator) { navigator.serviceWorker.ready.then(registration => { - registration.unregister(); - }); + registration.unregister() + }) } } diff --git a/packages/bent/src/index.js b/packages/bent/src/index.js index ec481ef0091..84c9f986cb5 100644 --- a/packages/bent/src/index.js +++ b/packages/bent/src/index.js @@ -1,29 +1,29 @@ -import freesewing from "@freesewing/core"; -import plugins from "@freesewing/plugin-bundle"; -import Brian from "@freesewing/brian"; -import config from "../config"; +import freesewing from '@freesewing/core' +import plugins from '@freesewing/plugin-bundle' +import Brian from '@freesewing/brian' +import config from '../config' // Parts -import draftSleeve from "./sleeve"; -import draftTopSleeve from "./topsleeve"; -import draftUnderSleeve from "./undersleeve"; +import draftSleeve from './sleeve' +import draftTopSleeve from './topsleeve' +import draftUnderSleeve from './undersleeve' // Create new design -const Pattern = new freesewing.Design(config, plugins); +const Pattern = new freesewing.Design(config, plugins) // Attach draft methods from Brian to prototype Pattern.prototype.draftBase = function(part) { - return new Brian(this.settings).draftBase(part); -}; + return new Brian(this.settings).draftBase(part) +} Pattern.prototype.draftFront = function(part) { - return new Brian(this.settings).draftFront(part); -}; + return new Brian(this.settings).draftFront(part) +} Pattern.prototype.draftBack = function(part) { - return new Brian(this.settings).draftBack(part); -}; + return new Brian(this.settings).draftBack(part) +} // Attach own draft methods to prototype -Pattern.prototype.draftSleeve = draftSleeve; -Pattern.prototype.draftTopSleeve = draftTopSleeve; -Pattern.prototype.draftUnderSleeve = draftUnderSleeve; +Pattern.prototype.draftSleeve = draftSleeve +Pattern.prototype.draftTopSleeve = draftTopSleeve +Pattern.prototype.draftUnderSleeve = draftUnderSleeve -export default Pattern; +export default Pattern diff --git a/packages/bent/src/shared.js b/packages/bent/src/shared.js index 6666798b4fb..eaba9eb0a9d 100644 --- a/packages/bent/src/shared.js +++ b/packages/bent/src/shared.js @@ -1,52 +1,52 @@ export default function(part, s) { - let { macro, points, sa } = part.shorthand(); + let { macro, points, sa } = part.shorthand() - macro("ld", { - from: points[s + "WristLeft"], - to: points[s + "WristRight"], + macro('ld', { + from: points[s + 'WristLeft'], + to: points[s + 'WristRight'], d: 15 - }); - macro("ld", { - from: points[s + "ElbowLeft"], + }) + macro('ld', { + from: points[s + 'ElbowLeft'], to: points.elbowRight - }); - macro("ld", { - from: points[s + "LeftEdge"], - to: points[s + "RightEdge"] - }); - macro("hd", { - from: points[s + "LeftEdge"], - to: points[s + "ElbowLeft"], - y: points[s + "WristRight"].y + 3 * sa + 15 - }); - macro("hd", { - from: points[s + "LeftEdge"], - to: points[s + "WristLeft"], - y: points[s + "WristRight"].y + 3 * sa + 30 - }); - macro("hd", { - from: points[s + "LeftEdge"], - to: points[s + "WristRight"], - y: points[s + "WristRight"].y + 3 * sa + 45 - }); - macro("hd", { - from: points[s + "LeftEdge"], + }) + macro('ld', { + from: points[s + 'LeftEdge'], + to: points[s + 'RightEdge'] + }) + macro('hd', { + from: points[s + 'LeftEdge'], + to: points[s + 'ElbowLeft'], + y: points[s + 'WristRight'].y + 3 * sa + 15 + }) + macro('hd', { + from: points[s + 'LeftEdge'], + to: points[s + 'WristLeft'], + y: points[s + 'WristRight'].y + 3 * sa + 30 + }) + macro('hd', { + from: points[s + 'LeftEdge'], + to: points[s + 'WristRight'], + y: points[s + 'WristRight'].y + 3 * sa + 45 + }) + macro('hd', { + from: points[s + 'LeftEdge'], to: points.elbowRight, - y: points[s + "WristRight"].y + 3 * sa + 60 - }); - macro("vd", { - from: points[s + "ElbowLeft"], - to: points[s + "LeftEdge"], - x: points[s + "LeftEdge"].x - sa - 15 - }); - macro("vd", { - from: points[s + "WristLeft"], - to: points[s + "LeftEdge"], - x: points[s + "LeftEdge"].x - sa - 30 - }); - macro("vd", { - from: points[s + "WristRight"], - to: points[s + "LeftEdge"], - x: points[s + "LeftEdge"].x - sa - 45 - }); + y: points[s + 'WristRight'].y + 3 * sa + 60 + }) + macro('vd', { + from: points[s + 'ElbowLeft'], + to: points[s + 'LeftEdge'], + x: points[s + 'LeftEdge'].x - sa - 15 + }) + macro('vd', { + from: points[s + 'WristLeft'], + to: points[s + 'LeftEdge'], + x: points[s + 'LeftEdge'].x - sa - 30 + }) + macro('vd', { + from: points[s + 'WristRight'], + to: points[s + 'LeftEdge'], + x: points[s + 'LeftEdge'].x - sa - 45 + }) } diff --git a/packages/bent/src/sleeve.js b/packages/bent/src/sleeve.js index be7ab8fe96c..d434a29433f 100644 --- a/packages/bent/src/sleeve.js +++ b/packages/bent/src/sleeve.js @@ -1,59 +1,41 @@ export default function(part) { - let { Path, paths, points, store, options } = part.shorthand(); + let { Path, paths, points, store, options } = part.shorthand() function draftSleeve(part, tweak) { - let { - Point, - Path, - points, - paths, - store, - options, - measurements, - utils - } = part.shorthand(); + let { Point, Path, points, paths, store, options, measurements, utils } = part.shorthand() // Sleeve frame - points.top = new Point(0, 0); - points.boxTopRight = points.top.shift( - 0, - (store.get("sleevecapTarget") / 5.8) * tweak - ); - points.boxTopLeft = points.boxTopRight.flipX(); + points.top = new Point(0, 0) + points.boxTopRight = points.top.shift(0, (store.get('sleevecapTarget') / 5.8) * tweak) + points.boxTopLeft = points.boxTopRight.flipX() points.boxBottom = points.top.shift( -90, measurements.shoulderToWrist * (1 + options.sleeveLengthBonus) - ); - points.boxBottomRight = points.boxBottom.shift(0, points.boxTopRight.x); - points.boxBottomLeft = points.boxBottomRight.flipX(); + ) + points.boxBottomRight = points.boxBottom.shift(0, points.boxTopRight.x) + points.boxBottomLeft = points.boxBottomRight.flipX() points.armCenter = points.top.shift( -90, - measurements.bicepsCircumference * - (1 + options.bicepsEase) * - options.sleevecapHeight * - tweak - ); - points.armRight = points.armCenter.shift(0, points.boxTopRight.x); - points.armLeft = points.armRight.flipX(); - points.elbowCenter = points.top.shift(-90, measurements.shoulderToElbow); - points.elbowRight = points.elbowCenter.shift(0, points.boxTopRight.x); - points.elbowLeft = points.elbowRight.flipX(); + measurements.bicepsCircumference * (1 + options.bicepsEase) * options.sleevecapHeight * tweak + ) + points.armRight = points.armCenter.shift(0, points.boxTopRight.x) + points.armLeft = points.armRight.flipX() + points.elbowCenter = points.top.shift(-90, measurements.shoulderToElbow) + points.elbowRight = points.elbowCenter.shift(0, points.boxTopRight.x) + points.elbowLeft = points.elbowRight.flipX() // Using sleeve width to adapt other values - let factor = points.boxTopRight.x; + let factor = points.boxTopRight.x // Note: us = undersleeve, ts = topsleeve - points.backPitchPoint = new Point(factor, points.armCenter.y / 3); - points.usTip = points.backPitchPoint.shift(180, factor / 4); - points.tsLeftEdge = points.armLeft.shift(180, factor / 4); - points.usLeftEdge = points.armLeft.shift(0, factor / 4); - points.tsRightEdge = points.armRight.shift(0, factor / 9); - points.usRightEdge = points.armRight.shift(180, factor / 9); - points.frontPitchPoint = new Point( - points.boxTopLeft.x, - points.armCenter.y * 0.6 - ); - points.tsElbowLeft = points.elbowLeft.shift(180, factor / 9); - points.usElbowLeft = points.elbowLeft.shift(0, factor / 2.4); + points.backPitchPoint = new Point(factor, points.armCenter.y / 3) + points.usTip = points.backPitchPoint.shift(180, factor / 4) + points.tsLeftEdge = points.armLeft.shift(180, factor / 4) + points.usLeftEdge = points.armLeft.shift(0, factor / 4) + points.tsRightEdge = points.armRight.shift(0, factor / 9) + points.usRightEdge = points.armRight.shift(180, factor / 9) + points.frontPitchPoint = new Point(points.boxTopLeft.x, points.armCenter.y * 0.6) + points.tsElbowLeft = points.elbowLeft.shift(180, factor / 9) + points.usElbowLeft = points.elbowLeft.shift(0, factor / 2.4) // Different approach to sleeve bend, wrist right first points.tsWristRight = utils.beamsIntersect( @@ -61,206 +43,130 @@ export default function(part) { points.boxBottomRight.rotate(options.sleeveBend * -1, points.elbowRight), points.boxBottomLeft, points.boxBottomRight - ); - points.usWristRight = points.tsWristRight.clone(); + ) + points.usWristRight = points.tsWristRight.clone() // Shift wrist left to the exact wrist width - let wristWidth = measurements.wristCircumference * (1 + options.cuffEase); - let topWrist = wristWidth / 2 + factor / 5; - let underWrist = wristWidth / 2 - factor / 5; - points.tsWristLeftHelperBottom = points.tsWristRight.shift( - 180, - topWrist / 2 - ); - points.usWristLeftHelperBottom = points.usWristRight.shift( - 180, - underWrist / 2 - ); - points.tsWristLeftHelperTop = points.tsElbowLeft.shiftFractionTowards( - points.elbowRight, - 0.5 - ); - points.usWristLeftHelperTop = points.usElbowLeft.shiftFractionTowards( - points.elbowRight, - 0.5 - ); - let tsWristAngle = points.tsWristLeftHelperBottom.angle( - points.tsWristLeftHelperTop - ); - let usWristAngle = points.usWristLeftHelperBottom.angle( - points.usWristLeftHelperTop - ); - points.tsWristLeft = points.tsWristRight.shift( - tsWristAngle - 90, - topWrist * -1 - ); - points.usWristLeft = points.usWristRight.shift( - usWristAngle - 90, - underWrist * -1 - ); + let wristWidth = measurements.wristCircumference * (1 + options.cuffEase) + let topWrist = wristWidth / 2 + factor / 5 + let underWrist = wristWidth / 2 - factor / 5 + points.tsWristLeftHelperBottom = points.tsWristRight.shift(180, topWrist / 2) + points.usWristLeftHelperBottom = points.usWristRight.shift(180, underWrist / 2) + points.tsWristLeftHelperTop = points.tsElbowLeft.shiftFractionTowards(points.elbowRight, 0.5) + points.usWristLeftHelperTop = points.usElbowLeft.shiftFractionTowards(points.elbowRight, 0.5) + let tsWristAngle = points.tsWristLeftHelperBottom.angle(points.tsWristLeftHelperTop) + let usWristAngle = points.usWristLeftHelperBottom.angle(points.usWristLeftHelperTop) + points.tsWristLeft = points.tsWristRight.shift(tsWristAngle - 90, topWrist * -1) + points.usWristLeft = points.usWristRight.shift(usWristAngle - 90, underWrist * -1) // Control points ts points.tsRightEdgeCpTop = points.tsRightEdge.shift( 90, points.backPitchPoint.dy(points.tsRightEdge) / 2 - ); - points.tsRightEdgeCpBottom = points.tsRightEdgeCpTop.flipY( - points.tsRightEdge - ); - points.elbowRightCpTop = points.tsWristRight.shiftFractionTowards( - points.elbowRight, - 1.15 - ); - points.topCpRight = points.top.shift(0, factor / 1.6); - points.topCpLeft = points.topCpRight.flipX(); + ) + points.tsRightEdgeCpBottom = points.tsRightEdgeCpTop.flipY(points.tsRightEdge) + points.elbowRightCpTop = points.tsWristRight.shiftFractionTowards(points.elbowRight, 1.15) + points.topCpRight = points.top.shift(0, factor / 1.6) + points.topCpLeft = points.topCpRight.flipX() points.tsLeftEdgeCpRight = points.tsLeftEdge.shift( 0, points.tsLeftEdge.dist(points.armLeft) / 2 - ); + ) points.frontPitchPointCpBottom = points.frontPitchPoint.shiftFractionTowards( points.tsLeftEdgeCpRight, 0.666 - ); - points.frontPitchPointCpTop = points.frontPitchPointCpBottom.rotate( - 180, - points.frontPitchPoint - ); - points.tsElbowLeftCpTop = points.tsWristLeft.shiftFractionTowards( - points.tsElbowLeft, - 1.2 - ); + ) + points.frontPitchPointCpTop = points.frontPitchPointCpBottom.rotate(180, points.frontPitchPoint) + points.tsElbowLeftCpTop = points.tsWristLeft.shiftFractionTowards(points.tsElbowLeft, 1.2) // Control points us points.usRightEdgeCpBottom = points.usRightEdge.shift( points.usTip.angle(points.elbowRight), points.usTip.dy(points.usRightEdge) / 2 - ); - points.usRightEdgeCpTop = points.usRightEdgeCpBottom.rotate( - 180, - points.usRightEdge - ); + ) + points.usRightEdgeCpTop = points.usRightEdgeCpBottom.rotate(180, points.usRightEdge) points._helper1 = new Path() .move(points.backPitchPoint) ._curve(points.topCpRight, points.top) - .shiftAlong(5); + .shiftAlong(5) points._helper2 = new Path() .move(points.backPitchPoint) ._curve(points.tsRightEdgeCpTop, points.tsRightEdge) - .shiftAlong(5); + .shiftAlong(5) points.usLeftEdgeRight = points.usLeftEdge.shift( 0, points.usLeftEdge.dist(points.armCenter) / 3 - ); + ) points.usLeftEdgeCpRight = points.usLeftEdge.shift( 0, points.usLeftEdge.dist(points.armCenter) / 1.2 - ); + ) // Angle of the usTip let angle = - points._helper1.angle(points.backPitchPoint) - - points.backPitchPoint.angle(points._helper2); - points.usTipCpBottom = points.usRightEdgeCpTop.rotate( - angle * -1, - points.usTip - ); - points.usElbowLeftCpTop = points.usWristLeft.shiftFractionTowards( - points.usElbowLeft, - 1.2 - ); + points._helper1.angle(points.backPitchPoint) - points.backPitchPoint.angle(points._helper2) + points.usTipCpBottom = points.usRightEdgeCpTop.rotate(angle * -1, points.usTip) + points.usElbowLeftCpTop = points.usWristLeft.shiftFractionTowards(points.usElbowLeft, 1.2) // Calculate length of the sleevecap seam let lenTop = new Path() .move(points.backPitchPoint) .curve(points.backPitchPoint, points.topCpRight, points.top) - .curve( - points.topCpLeft, - points.frontPitchPointCpTop, - points.frontPitchPoint - ) - .curve( - points.frontPitchPointCpBottom, - points.tsLeftEdgeCpRight, - points.tsLeftEdge - ) - .length(); + .curve(points.topCpLeft, points.frontPitchPointCpTop, points.frontPitchPoint) + .curve(points.frontPitchPointCpBottom, points.tsLeftEdgeCpRight, points.tsLeftEdge) + .length() let lenUnder = new Path() .move(points.usTip) - .curve( - points.usTipCpBottom, - points.usLeftEdgeCpRight, - points.usLeftEdgeRight - ) + .curve(points.usTipCpBottom, points.usLeftEdgeCpRight, points.usLeftEdgeRight) .line(points.usLeftEdge) - .length(); - store.set("sleevecapLength", lenTop + lenUnder); + .length() + store.set('sleevecapLength', lenTop + lenUnder) } - let armholeLength = - store.get("frontArmholeLength") + store.get("backArmholeLength"); - let sleevecapEase = armholeLength * options.sleevecapEase; - store.set("sleevecapEase", sleevecapEase); - store.set("sleevecapTarget", armholeLength + sleevecapEase); + let armholeLength = store.get('frontArmholeLength') + store.get('backArmholeLength') + let sleevecapEase = armholeLength * options.sleevecapEase + store.set('sleevecapEase', sleevecapEase) + store.set('sleevecapTarget', armholeLength + sleevecapEase) - let delta = 0; - let runs = 0; - let tweak = 1; - let target = store.get("sleevecapTarget"); + let delta = 0 + let runs = 0 + let tweak = 1 + let target = store.get('sleevecapTarget') do { - draftSleeve(part, tweak); - runs++; - delta = store.get("sleevecapLength") - target; - if (delta > 0) tweak = tweak * 0.99; - else tweak = tweak * 1.02; - } while (Math.abs(delta) > 2 && runs < 25); + draftSleeve(part, tweak) + runs++ + delta = store.get('sleevecapLength') - target + if (delta > 0) tweak = tweak * 0.99 + else tweak = tweak * 1.02 + } while (Math.abs(delta) > 2 && runs < 25) // Paths paths.ts = new Path() .move(points.tsWristRight) .line(points.elbowRight) - .curve( - points.elbowRightCpTop, - points.tsRightEdgeCpBottom, - points.tsRightEdge - ) + .curve(points.elbowRightCpTop, points.tsRightEdgeCpBottom, points.tsRightEdge) .curve_(points.tsRightEdgeCpTop, points.backPitchPoint) .curve(points.backPitchPoint, points.topCpRight, points.top) - .curve( - points.topCpLeft, - points.frontPitchPointCpTop, - points.frontPitchPoint - ) - .curve( - points.frontPitchPointCpBottom, - points.tsLeftEdgeCpRight, - points.tsLeftEdge - ) + .curve(points.topCpLeft, points.frontPitchPointCpTop, points.frontPitchPoint) + .curve(points.frontPitchPointCpBottom, points.tsLeftEdgeCpRight, points.tsLeftEdge) .curve(points.tsLeftEdge, points.tsElbowLeftCpTop, points.tsElbowLeft) .line(points.tsWristLeft) .line(points.tsWristRight) .close() - .attr("class", "lining"); + .attr('class', 'lining') paths.us = new Path() .move(points.usWristRight) .line(points.elbowRight) - .curve( - points.elbowRightCpTop, - points.usRightEdgeCpBottom, - points.usRightEdge - ) + .curve(points.elbowRightCpTop, points.usRightEdgeCpBottom, points.usRightEdge) .curve_(points.usRightEdgeCpTop, points.usTip) - .curve( - points.usTipCpBottom, - points.usLeftEdgeCpRight, - points.usLeftEdgeRight - ) + .curve(points.usTipCpBottom, points.usLeftEdgeCpRight, points.usLeftEdgeRight) .line(points.usLeftEdge) .curve(points.usLeftEdge, points.usElbowLeftCpTop, points.usElbowLeft) .line(points.usWristLeft) .line(points.usWristRight) .close() - .attr("class", "stroke-xl interfacing"); + .attr('class', 'stroke-xl interfacing') - return part; + return part } diff --git a/packages/bent/src/topsleeve.js b/packages/bent/src/topsleeve.js index 8f41406dc15..55c15d9e527 100644 --- a/packages/bent/src/topsleeve.js +++ b/packages/bent/src/topsleeve.js @@ -1,36 +1,26 @@ -import dimensions from "./shared"; +import dimensions from './shared' export default function(part) { - let { - macro, - Path, - points, - paths, - complete, - paperless, - snippets, - Snippet, - sa - } = part.shorthand(); + let { macro, Path, points, paths, complete, paperless, snippets, Snippet, sa } = part.shorthand() // Extract seamline from sleeve - delete paths.us; - paths.seam = paths.ts.clone().attr("class", "fabric", true); - delete paths.ts; + delete paths.us + paths.seam = paths.ts.clone().attr('class', 'fabric', true) + delete paths.ts // Complete? if (complete) { - snippets.logo = new Snippet("logo", points.elbowCenter); - macro("title", { + snippets.logo = new Snippet('logo', points.elbowCenter) + macro('title', { at: points.armCenter, nr: 3, - title: "topsleeve" - }); + title: 'topsleeve' + }) if (sa) { - paths.sa = paths.seam.clone(); + paths.sa = paths.seam.clone() // Remove hem - paths.sa.ops.splice(-2); + paths.sa.ops.splice(-2) paths.sa = paths.sa .offset(sa) .join( @@ -40,39 +30,39 @@ export default function(part) { .offset(sa * 3) ) .close() - .attr("class", "fabric sa"); + .attr('class', 'fabric sa') } } // Paperless? if (paperless) { - dimensions(part, "ts"); - macro("vd", { + dimensions(part, 'ts') + macro('vd', { from: points.tsLeftEdge, to: points.top, x: points.tsLeftEdge.x - sa - 15 - }); - macro("hd", { + }) + macro('hd', { from: points.tsLeftEdge, to: points.top, y: points.top.x - sa - 15 - }); - macro("hd", { + }) + macro('hd', { from: points.tsLeftEdge, to: points.backPitchPoint, y: points.top.x - sa - 30 - }); - macro("hd", { + }) + macro('hd', { from: points.tsLeftEdge, to: points.tsRightEdge, y: points.top.x - sa - 45 - }); - macro("vd", { + }) + macro('vd', { from: points.tsRightEdge, to: points.backPitchPoint, x: points.tsRightEdge.x + sa + 15 - }); + }) } - return part; + return part } diff --git a/packages/bent/src/undersleeve.js b/packages/bent/src/undersleeve.js index 434023c2da7..da34303c3a3 100644 --- a/packages/bent/src/undersleeve.js +++ b/packages/bent/src/undersleeve.js @@ -1,36 +1,26 @@ -import dimensions from "./shared"; +import dimensions from './shared' export default function(part) { - let { - macro, - Path, - points, - paths, - complete, - paperless, - snippets, - Snippet, - sa - } = part.shorthand(); + let { macro, Path, points, paths, complete, paperless, snippets, Snippet, sa } = part.shorthand() // Extract seamline from sleeve - delete paths.ts; - paths.seam = paths.us.clone().attr("class", "fabric", true); - delete paths.us; + delete paths.ts + paths.seam = paths.us.clone().attr('class', 'fabric', true) + delete paths.us // Complete? if (complete) { - snippets.logo = new Snippet("logo", points.elbowCenter); - macro("title", { + snippets.logo = new Snippet('logo', points.elbowCenter) + macro('title', { at: points.armCenter, nr: 4, - title: "undersleeve" - }); + title: 'undersleeve' + }) if (sa) { - paths.sa = paths.seam.clone(); + paths.sa = paths.seam.clone() // Remove hem - paths.sa.ops.splice(-2); + paths.sa.ops.splice(-2) paths.sa = paths.sa .offset(sa) .join( @@ -40,24 +30,24 @@ export default function(part) { .offset(sa * 3) ) .close() - .attr("class", "fabric sa"); + .attr('class', 'fabric sa') } } // Paperless? if (paperless) { - dimensions(part, "us"); - macro("hd", { + dimensions(part, 'us') + macro('hd', { from: points.usLeftEdge, to: points.usTip, y: points.usTip.y - sa - 15 - }); - macro("vd", { + }) + macro('vd', { from: points.tsRightEdge, to: points.usTip, x: points.tsRightEdge.x + sa + 15 - }); + }) } - return part; + return part } diff --git a/packages/brian/example/src/App.js b/packages/brian/example/src/App.js index e7936330e5d..115cdf683af 100644 --- a/packages/brian/example/src/App.js +++ b/packages/brian/example/src/App.js @@ -1,22 +1,15 @@ -import React from "react"; -import freesewing from "@freesewing/core"; -import Workbench from "@freesewing/components/Workbench"; -import "typeface-roboto-condensed"; -import "@freesewing/css-theme"; +import React from 'react' +import freesewing from '@freesewing/core' +import Workbench from '@freesewing/components/Workbench' +import 'typeface-roboto-condensed' +import '@freesewing/css-theme' -import Pattern from "pattern"; +import Pattern from 'pattern' const App = props => { - let instance = new Pattern(); - let config = instance.config; - return ( - - ); -}; + let instance = new Pattern() + let config = instance.config + return +} -export default App; +export default App diff --git a/packages/brian/example/src/index.js b/packages/brian/example/src/index.js index 7900787a4d2..9dd7ba788d4 100644 --- a/packages/brian/example/src/index.js +++ b/packages/brian/example/src/index.js @@ -1,11 +1,11 @@ -import React from "react"; -import ReactDOM from "react-dom"; -import App from "./App"; -import * as serviceWorker from "./serviceWorker"; +import React from 'react' +import ReactDOM from 'react-dom' +import App from './App' +import * as serviceWorker from './serviceWorker' -ReactDOM.render(, document.getElementById("root")); +ReactDOM.render(, document.getElementById('root')) // If you want your app to work offline and load faster, you can change // unregister() to register() below. Note this comes with some pitfalls. // Learn more about service workers: http://bit.ly/CRA-PWA -serviceWorker.unregister(); +serviceWorker.unregister() diff --git a/packages/brian/example/src/serviceWorker.js b/packages/brian/example/src/serviceWorker.js index 68fda5a0eb6..44e1b1b2f8c 100644 --- a/packages/brian/example/src/serviceWorker.js +++ b/packages/brian/example/src/serviceWorker.js @@ -9,46 +9,44 @@ // This link also includes instructions on opting out of this behavior. const isLocalhost = Boolean( - window.location.hostname === "localhost" || + window.location.hostname === 'localhost' || // [::1] is the IPv6 localhost address. - window.location.hostname === "[::1]" || + window.location.hostname === '[::1]' || // 127.0.0.1/8 is considered localhost for IPv4. - window.location.hostname.match( - /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ - ) -); + window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/) +) export function register(config) { - if (process.env.NODE_ENV === "production" && "serviceWorker" in navigator) { + if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) { // The URL constructor is available in all browsers that support SW. - const publicUrl = new URL(process.env.PUBLIC_URL, window.location); + const publicUrl = new URL(process.env.PUBLIC_URL, window.location) if (publicUrl.origin !== window.location.origin) { // Our service worker won't work if PUBLIC_URL is on a different origin // from what our page is served on. This might happen if a CDN is used to // serve assets; see https://github.com/facebook/create-react-app/issues/2374 - return; + return } - window.addEventListener("load", () => { - const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; + window.addEventListener('load', () => { + const swUrl = `${process.env.PUBLIC_URL}/service-worker.js` if (isLocalhost) { // This is running on localhost. Let's check if a service worker still exists or not. - checkValidServiceWorker(swUrl, config); + checkValidServiceWorker(swUrl, config) // Add some additional logging to localhost, pointing developers to the // service worker/PWA documentation. navigator.serviceWorker.ready.then(() => { console.log( - "This web app is being served cache-first by a service " + - "worker. To learn more, visit https://goo.gl/SC7cgQ" - ); - }); + 'This web app is being served cache-first by a service ' + + 'worker. To learn more, visit https://goo.gl/SC7cgQ' + ) + }) } else { // Is not local host. Just register service worker - registerValidSW(swUrl, config); + registerValidSW(swUrl, config) } - }); + }) } } @@ -57,38 +55,38 @@ function registerValidSW(swUrl, config) { .register(swUrl) .then(registration => { registration.onupdatefound = () => { - const installingWorker = registration.installing; + const installingWorker = registration.installing installingWorker.onstatechange = () => { - if (installingWorker.state === "installed") { + if (installingWorker.state === 'installed') { if (navigator.serviceWorker.controller) { // At this point, the old content will have been purged and // the fresh content will have been added to the cache. // It's the perfect time to display a "New content is // available; please refresh." message in your web app. - console.log("New content is available; please refresh."); + console.log('New content is available; please refresh.') // Execute callback if (config.onUpdate) { - config.onUpdate(registration); + config.onUpdate(registration) } } else { // At this point, everything has been precached. // It's the perfect time to display a // "Content is cached for offline use." message. - console.log("Content is cached for offline use."); + console.log('Content is cached for offline use.') // Execute callback if (config.onSuccess) { - config.onSuccess(registration); + config.onSuccess(registration) } } } - }; - }; + } + } }) .catch(error => { - console.error("Error during service worker registration:", error); - }); + console.error('Error during service worker registration:', error) + }) } function checkValidServiceWorker(swUrl, config) { @@ -98,30 +96,28 @@ function checkValidServiceWorker(swUrl, config) { // Ensure service worker exists, and that we really are getting a JS file. if ( response.status === 404 || - response.headers.get("content-type").indexOf("javascript") === -1 + response.headers.get('content-type').indexOf('javascript') === -1 ) { // No service worker found. Probably a different app. Reload the page. navigator.serviceWorker.ready.then(registration => { registration.unregister().then(() => { - window.location.reload(); - }); - }); + window.location.reload() + }) + }) } else { // Service worker found. Proceed as normal. - registerValidSW(swUrl, config); + registerValidSW(swUrl, config) } }) .catch(() => { - console.log( - "No internet connection found. App is running in offline mode." - ); - }); + console.log('No internet connection found. App is running in offline mode.') + }) } export function unregister() { - if ("serviceWorker" in navigator) { + if ('serviceWorker' in navigator) { navigator.serviceWorker.ready.then(registration => { - registration.unregister(); - }); + registration.unregister() + }) } } diff --git a/packages/brian/src/back.js b/packages/brian/src/back.js index 174ced2aa44..13ddfcbfaa8 100644 --- a/packages/brian/src/back.js +++ b/packages/brian/src/back.js @@ -1,4 +1,4 @@ -import * as shared from "./shared"; +import * as shared from './shared' export default part => { let { @@ -12,67 +12,64 @@ export default part => { complete, paperless, macro - } = part.shorthand(); + } = part.shorthand() // Seamline - paths.saBase = shared.saBase("back", points, Path); + paths.saBase = shared.saBase('back', points, Path) paths.seam = new Path() .move(points.cbNeck) .line(points.cbHips) .join(paths.saBase) - .attr("class", "fabric"); + .attr('class', 'fabric') // Store lengths to fit sleeve - store.set("backArmholeLength", shared.armholeLength(points, Path)); - store.set( - "backShoulderToArmholePitch", - shared.shoulderToArmholePitch(points, Path) - ); + store.set('backArmholeLength', shared.armholeLength(points, Path)) + store.set('backShoulderToArmholePitch', shared.shoulderToArmholePitch(points, Path)) // Complete pattern? if (complete) { - macro("cutonfold", { + macro('cutonfold', { from: points.cbNeck, to: points.cbHips, grainline: true - }); + }) - macro("title", { at: points.title, nr: 2, title: "back" }); - snippets.armholePitchNotch = new Snippet("bnotch", points.armholePitch); + macro('title', { at: points.title, nr: 2, title: 'back' }) + snippets.armholePitchNotch = new Snippet('bnotch', points.armholePitch) if (sa) { paths.sa = paths.saBase .offset(sa) - .attr("class", "fabric sa") + .attr('class', 'fabric sa') .line(points.cbNeck) - .move(points.cbHips); - paths.sa.line(paths.sa.start()); + .move(points.cbHips) + paths.sa.line(paths.sa.start()) } } // Paperless? if (paperless) { - shared.dimensions(macro, points, Path, sa); - macro("hd", { + shared.dimensions(macro, points, Path, sa) + macro('hd', { from: points.cbHips, to: points.hips, y: points.hips.y + sa + 15 - }); - macro("vd", { + }) + macro('vd', { from: points.cbHips, to: points.cbNeck, x: points.cbHips.x - sa - 15 - }); - macro("hd", { + }) + macro('hd', { from: points.cbNeck, to: points.neck, y: points.neck.y - sa - 15 - }); - macro("hd", { + }) + macro('hd', { from: points.cbNeck, to: points.shoulder, y: points.neck.y - sa - 30 - }); + }) } - return part; -}; + return part +} diff --git a/packages/brian/src/base.js b/packages/brian/src/base.js index 525fa30a383..e65b2d53f54 100644 --- a/packages/brian/src/base.js +++ b/packages/brian/src/base.js @@ -1,4 +1,4 @@ -import * as shared from "./shared"; +import * as shared from './shared' export default part => { let { @@ -15,179 +15,146 @@ export default part => { paths, utils, complete - } = part.shorthand(); + } = part.shorthand() - store.set( - "shoulderEase", - (measurements.shoulderToShoulder * options.shoulderEase) / 2 - ); + store.set('shoulderEase', (measurements.shoulderToShoulder * options.shoulderEase) / 2) // Center back (cb) vertical axis - points.cbNeck = new Point( - 0, - options.backNeckCutout * measurements.neckCircumference - ); + points.cbNeck = new Point(0, options.backNeckCutout * measurements.neckCircumference) points.cbShoulder = new Point( 0, (measurements.shoulderSlope - measurements.shoulderToShoulder * options.shoulderSlopeReduction) / 2 - ); + ) points.cbArmhole = new Point( 0, points.cbShoulder.y + (measurements.shoulderToShoulder * options.shoulderSlopeReduction) / 2 + - measurements.bicepsCircumference * - (1 + options.bicepsEase) * - options.armholeDepthFactor - ); - points.cbWaist = new Point( - 0, - points.cbNeck.y + measurements.centerBackNeckToWaist - ); - points.cbHips = new Point( - 0, - points.cbWaist.y + measurements.naturalWaistToHip - ); + measurements.bicepsCircumference * (1 + options.bicepsEase) * options.armholeDepthFactor + ) + points.cbWaist = new Point(0, points.cbNeck.y + measurements.centerBackNeckToWaist) + points.cbHips = new Point(0, points.cbWaist.y + measurements.naturalWaistToHip) points.cbHem = new Point( 0, points.cbWaist.y + measurements.naturalWaistToHip + - (measurements.centerBackNeckToWaist + measurements.naturalWaistToHip) * - options.lengthBonus - ); + (measurements.centerBackNeckToWaist + measurements.naturalWaistToHip) * options.lengthBonus + ) // Side back (cb) vertical axis points.armhole = new Point( (measurements.chestCircumference * (1 + options.chestEase)) / 4, points.cbArmhole.y - ); - points.waist = new Point(points.armhole.x, points.cbWaist.y); - points.hips = new Point(points.armhole.x, points.cbHips.y); - points.hem = new Point(points.armhole.x, points.cbHem.y); + ) + points.waist = new Point(points.armhole.x, points.cbWaist.y) + points.hips = new Point(points.armhole.x, points.cbHips.y) + points.hem = new Point(points.armhole.x, points.cbHem.y) // Shoulder line points.neck = new Point( - (measurements.neckCircumference * (1 + options.collarEase)) / - options.collarFactor, + (measurements.neckCircumference * (1 + options.collarEase)) / options.collarFactor, 0 - ); + ) points.shoulder = new Point( - measurements.shoulderToShoulder / 2 + store.get("shoulderEase"), + measurements.shoulderToShoulder / 2 + store.get('shoulderEase'), points.cbShoulder.y - ); + ) // Armhhole points.armholePitch = new Point( (measurements.shoulderToShoulder * options.acrossBackFactor) / 2 + - store.get("shoulderEase") / 2, + store.get('shoulderEase') / 2, points.shoulder.y + points.shoulder.dy(points.armhole) / 2 - ); - points._tmp1 = new Point(points.armholePitch.x, points.armhole.y); - points._tmp2 = points._tmp1.shift(45, 10); + ) + points._tmp1 = new Point(points.armholePitch.x, points.armhole.y) + points._tmp2 = points._tmp1.shift(45, 10) points._tmp3 = utils.beamsIntersect( points._tmp1, points._tmp2, points.armhole, points.armholePitch - ); - points.armholeHollow = points._tmp1.shiftFractionTowards(points._tmp3, 0.5); - points.armholeCp2 = points.armhole.shift( - 180, - points._tmp1.dx(points.armhole) / 4 - ); + ) + points.armholeHollow = points._tmp1.shiftFractionTowards(points._tmp3, 0.5) + points.armholeCp2 = points.armhole.shift(180, points._tmp1.dx(points.armhole) / 4) points.armholeHollowCp1 = points.armholeHollow.shift( -45, points.armholeHollow.dy(points.armhole) / 2 - ); + ) points.armholeHollowCp2 = points.armholeHollow.shift( 135, points.armholePitch.dx(points.armholeHollow) - ); + ) points.armholePitchCp1 = points.armholePitch.shift( -90, points.armholePitch.dy(points.armholeHollow) / 2 - ); + ) points.armholePitchCp2 = points.armholePitch.shift( 90, points.shoulder.dy(points.armholePitch) / 2 - ); + ) points.shoulderCp1 = points.shoulder .shiftTowards(points.neck, points.shoulder.dy(points.armholePitch) / 5) - .rotate(90, points.shoulder); + .rotate(90, points.shoulder) // Neck opening (back) - points._tmp4 = points.neck - .shiftTowards(points.shoulder, 10) - .rotate(-90, points.neck); - points.neckCp2 = utils.beamIntersectsY( - points.neck, - points._tmp4, - points.cbNeck.y - ); + points._tmp4 = points.neck.shiftTowards(points.shoulder, 10).rotate(-90, points.neck) + points.neckCp2 = utils.beamIntersectsY(points.neck, points._tmp4, points.cbNeck.y) // Fit collar - points.cfNeck = points.neck.rotate(-90, new Point(0, 0)); - let target = measurements.neckCircumference * (1 + options.collarEase); - let delta = 0; - let run = 0; + points.cfNeck = points.neck.rotate(-90, new Point(0, 0)) + let target = measurements.neckCircumference * (1 + options.collarEase) + let delta = 0 + let run = 0 do { - run++; - points.cfNeck = points.cfNeck.shift(90, delta / 3); + run++ + points.cfNeck = points.cfNeck.shift(90, delta / 3) points.frontNeckCpEdge = utils.beamsIntersect( points.neck, points.neckCp2, points.cfNeck, new Point(20, points.cfNeck.y) - ); - points.cfNeckCp1 = points.cfNeck.shiftFractionTowards( - points.frontNeckCpEdge, - 0.55 - ); - points.neckCp2Front = points.neck.shiftFractionTowards( - points.frontNeckCpEdge, - 0.65 - ); + ) + points.cfNeckCp1 = points.cfNeck.shiftFractionTowards(points.frontNeckCpEdge, 0.55) + points.neckCp2Front = points.neck.shiftFractionTowards(points.frontNeckCpEdge, 0.65) paths.neckOpening = new Path() .move(points.cfNeck) .curve(points.cfNeckCp1, points.neckCp2Front, points.neck) .curve(points.neckCp2, points.cbNeck, points.cbNeck) - .attr("class", "dashed stroke-xl various"); - delta = paths.neckOpening.length() * 2 - target; - } while (Math.abs(delta) > 1 && options.brianFitCollar && run < 10); - delete paths.neckOpening; + .attr('class', 'dashed stroke-xl various') + delta = paths.neckOpening.length() * 2 - target + } while (Math.abs(delta) > 1 && options.brianFitCollar && run < 10) + delete paths.neckOpening if (options.brianFitCollar) { debug({ - style: "success", - label: "🏁 Collar fitted", - msg: `Target was ${units(target)}, delta of ${units( - delta - )} reached in ${run} attempts.` - }); + style: 'success', + label: '🏁 Collar fitted', + msg: `Target was ${units(target)}, delta of ${units(delta)} reached in ${run} attempts.` + }) } else debug({ - style: "warning", - label: "🚫 Not fittingcollar", - msg: "(in Brian)" - }); + style: 'warning', + label: '🚫 Not fittingcollar', + msg: '(in Brian)' + }) // Anchor point for sampling - points.gridAnchor = points.cbHem; + points.gridAnchor = points.cbHem // Seamline - paths.saBase = shared.saBase("back", points, Path); + paths.saBase = shared.saBase('back', points, Path) paths.seam = new Path() .move(points.cbNeck) .line(points.cbHem) .join(paths.saBase) - .attr("class", "fabric"); + .attr('class', 'fabric') // Complete pattern? if (complete) { - points.title = new Point(points.armholePitch.x / 2, points.armholePitch.y); - points.logo = points.title.shift(-90, 100); - snippets.logo = new Snippet("logo", points.logo); + points.title = new Point(points.armholePitch.x / 2, points.armholePitch.y) + points.logo = points.title.shift(-90, 100) + snippets.logo = new Snippet('logo', points.logo) } - return part; -}; + return part +} diff --git a/packages/brian/src/front.js b/packages/brian/src/front.js index f07bdc4737f..d3174b5ecaa 100644 --- a/packages/brian/src/front.js +++ b/packages/brian/src/front.js @@ -1,4 +1,4 @@ -import * as shared from "./shared"; +import * as shared from './shared' export default part => { let { @@ -15,80 +15,77 @@ export default part => { complete, paperless, macro - } = part.shorthand(); + } = part.shorthand() // Cut arm a bit deeper at the front - let deeper = measurements.chestCircumference * options.frontArmholeDeeper; - points.armholePitchCp1.x -= deeper; - points.armholePitch.x -= deeper; - points.armholePitchCp2.x -= deeper; + let deeper = measurements.chestCircumference * options.frontArmholeDeeper + points.armholePitchCp1.x -= deeper + points.armholePitch.x -= deeper + points.armholePitchCp2.x -= deeper // Rename cb (center back) to cf (center front) - for (let key of ["Shoulder", "Armhole", "Waist", "Hips", "Hem"]) { - points[`cf${key}`] = new Point(points[`cb${key}`].x, points[`cb${key}`].y); - delete points[`cb${key}`]; + for (let key of ['Shoulder', 'Armhole', 'Waist', 'Hips', 'Hem']) { + points[`cf${key}`] = new Point(points[`cb${key}`].x, points[`cb${key}`].y) + delete points[`cb${key}`] } // Front neckline points - points.neckCp2 = new Point(points.neckCp2Front.x, points.neckCp2Front.y); + points.neckCp2 = new Point(points.neckCp2Front.x, points.neckCp2Front.y) // Seamline - paths.saBase = shared.saBase("front", points, Path); + paths.saBase = shared.saBase('front', points, Path) paths.seam = new Path() .move(points.cfNeck) .line(points.cfHem) .join(paths.saBase) - .attr("class", "fabric"); + .attr('class', 'fabric') // Store lengths to fit sleeve - store.set("frontArmholeLength", shared.armholeLength(points, Path)); - store.set( - "frontShoulderToArmholePitch", - shared.shoulderToArmholePitch(points, Path) - ); + store.set('frontArmholeLength', shared.armholeLength(points, Path)) + store.set('frontShoulderToArmholePitch', shared.shoulderToArmholePitch(points, Path)) // Complete pattern? if (complete) { - macro("cutonfold", { + macro('cutonfold', { from: points.cfNeck, to: points.cfHips, grainline: true - }); - macro("title", { at: points.title, nr: 1, title: "front" }); - snippets.armholePitchNotch = new Snippet("notch", points.armholePitch); + }) + macro('title', { at: points.title, nr: 1, title: 'front' }) + snippets.armholePitchNotch = new Snippet('notch', points.armholePitch) if (sa) { paths.sa = paths.saBase .offset(sa) - .attr("class", "fabric sa") + .attr('class', 'fabric sa') .line(points.cfNeck) - .move(points.cfHips); - paths.sa.line(paths.sa.start()); + .move(points.cfHips) + paths.sa.line(paths.sa.start()) } } // Paperless? if (paperless) { - shared.dimensions(macro, points, Path, sa); - macro("hd", { + shared.dimensions(macro, points, Path, sa) + macro('hd', { from: points.cfHips, to: points.hips, y: points.hips.y + sa + 15 - }); - macro("vd", { + }) + macro('vd', { from: points.cfHips, to: points.cfNeck, x: points.cfHips.x - sa - 15 - }); - macro("hd", { + }) + macro('hd', { from: points.cfNeck, to: points.neck, y: points.neck.y - sa - 15 - }); - macro("hd", { + }) + macro('hd', { from: points.cfNeck, to: points.shoulder, y: points.neck.y - sa - 30 - }); + }) } - return part; -}; + return part +} diff --git a/packages/brian/src/index.js b/packages/brian/src/index.js index ff508cc1d90..c24f0e9d183 100644 --- a/packages/brian/src/index.js +++ b/packages/brian/src/index.js @@ -1,21 +1,21 @@ -import freesewing from "@freesewing/core"; -import plugins from "@freesewing/plugin-bundle"; -import config from "../config"; +import freesewing from '@freesewing/core' +import plugins from '@freesewing/plugin-bundle' +import config from '../config' // Parts -import draftBase from "./base"; -import draftBack from "./back"; -import draftFront from "./front"; -import draftSleevecap from "./sleevecap"; -import draftSleeve from "./sleeve"; +import draftBase from './base' +import draftBack from './back' +import draftFront from './front' +import draftSleevecap from './sleevecap' +import draftSleeve from './sleeve' // Create design -const Pattern = new freesewing.Design(config, plugins); +const Pattern = new freesewing.Design(config, plugins) // Attach draft methods to prototype -Pattern.prototype.draftBase = draftBase; -Pattern.prototype.draftBack = draftBack; -Pattern.prototype.draftFront = draftFront; -Pattern.prototype.draftSleevecap = draftSleevecap; -Pattern.prototype.draftSleeve = draftSleeve; +Pattern.prototype.draftBase = draftBase +Pattern.prototype.draftBack = draftBack +Pattern.prototype.draftFront = draftFront +Pattern.prototype.draftSleevecap = draftSleevecap +Pattern.prototype.draftSleeve = draftSleeve -export default Pattern; +export default Pattern diff --git a/packages/brian/src/shared.js b/packages/brian/src/shared.js index d71bc2e3523..18e7119a5d8 100644 --- a/packages/brian/src/shared.js +++ b/packages/brian/src/shared.js @@ -1,21 +1,21 @@ export function saBase(side, points, Path) { - let path = new Path(); - if (side === "back") path.move(points.cbHem); - else path.move(points.cfHem); + let path = new Path() + if (side === 'back') path.move(points.cbHem) + else path.move(points.cfHem) path .line(points.hem) .line(points.armhole) .curve(points.armholeCp2, points.armholeHollowCp1, points.armholeHollow) .curve(points.armholeHollowCp2, points.armholePitchCp1, points.armholePitch) .curve(points.armholePitchCp2, points.shoulderCp1, points.shoulder) - .line(points.neck); - if (side === "back") { - path.curve(points.neckCp2, points.cbNeck, points.cbNeck); + .line(points.neck) + if (side === 'back') { + path.curve(points.neckCp2, points.cbNeck, points.cbNeck) } else { - path.curve(points.neckCp2, points.cfNeckCp1, points.cfNeck); + path.curve(points.neckCp2, points.cfNeckCp1, points.cfNeck) } - return path; + return path } export function armholeLength(points, Path) { @@ -24,54 +24,50 @@ export function armholeLength(points, Path) { .curve(points.armholeCp2, points.armholeHollowCp1, points.armholeHollow) .curve(points.armholeHollowCp2, points.armholePitchCp1, points.armholePitch) .curve(points.armholePitchCp2, points.shoulderCp1, points.shoulder) - .length(); + .length() } export function shoulderToArmholePitch(points, Path) { return new Path() .move(points.armholePitch) .curve(points.armholePitchCp2, points.shoulderCp1, points.shoulder) - .length(); + .length() } export function dimensions(macro, points, Path, sa) { - macro("pd", { + macro('pd', { path: new Path() .move(points.armhole) .curve(points.armholeCp2, points.armholeHollowCp1, points.armholeHollow) - .curve( - points.armholeHollowCp2, - points.armholePitchCp1, - points.armholePitch - ) + .curve(points.armholeHollowCp2, points.armholePitchCp1, points.armholePitch) .curve(points.armholePitchCp2, points.shoulderCp1, points.shoulder), d: sa + 15 - }); - macro("pd", { + }) + macro('pd', { path: new Path() .move(points.armholePitch) .curve(points.armholePitchCp2, points.shoulderCp1, points.shoulder), d: -15 - }); - macro("vd", { + }) + macro('vd', { from: points.hips, to: points.armhole, x: points.hips.x + sa + 15 - }); - macro("vd", { + }) + macro('vd', { from: points.hips, to: points.armholePitch, x: points.hips.x + sa + 30 - }); - macro("vd", { + }) + macro('vd', { from: points.hips, to: points.shoulder, x: points.hips.x + sa + 45 - }); - macro("vd", { + }) + macro('vd', { from: points.hips, to: points.neck, x: points.hips.x + sa + 60 - }); - macro("ld", { from: points.neck, to: points.shoulder, d: sa + 15 }); + }) + macro('ld', { from: points.neck, to: points.shoulder, d: sa + 15 }) } diff --git a/packages/brian/src/sleeve.js b/packages/brian/src/sleeve.js index 5d65319afa7..40c6ef7d6bf 100644 --- a/packages/brian/src/sleeve.js +++ b/packages/brian/src/sleeve.js @@ -15,33 +15,33 @@ export default part => { complete, paperless, macro - } = part.shorthand(); + } = part.shorthand() // Wrist - let top = paths.sleevecap.bbox().topLeft.y; + let top = paths.sleevecap.bbox().topLeft.y debug({ - style: "info", - label: "🗸 Sleevecap height", + style: 'info', + label: '🗸 Sleevecap height', msg: units(Math.abs(top)) - }); + }) debug({ - style: "info", - label: "🗸 Sleevecap width", + style: 'info', + label: '🗸 Sleevecap width', msg: units(points.bicepsRight.x * 2) - }); + }) points.centerWrist = new Point( 0, top + measurements.shoulderToWrist * (1 + options.sleeveLengthBonus) - ); + ) points.wristRight = points.centerWrist.shift( 0, (measurements.wristCircumference * (1 + options.cuffEase)) / 2 - ); - points.wristLeft = points.wristRight.rotate(180, points.centerWrist); - points.sleeveTip = paths.sleevecap.shiftFractionAlong(0.5); + ) + points.wristLeft = points.wristRight.rotate(180, points.centerWrist) + points.sleeveTip = paths.sleevecap.shiftFractionAlong(0.5) // Paths - paths.sleevecap.render = false; + paths.sleevecap.render = false paths.seam = new Path() .move(points.bicepsLeft) .move(points.wristLeft) @@ -49,67 +49,64 @@ export default part => { .line(points.bicepsRight) .join(paths.sleevecap) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') // Anchor point for sampling - points.gridAnchor = new Point(0, 0); + points.gridAnchor = new Point(0, 0) // Complete pattern? if (complete) { - points.logo = points.centerBiceps.shiftFractionTowards( - points.centerWrist, - 0.3 - ); - snippets.logo = new Snippet("logo", points.logo); - macro("title", { at: points.centerBiceps, nr: 3, title: "sleeve" }); - macro("grainline", { from: points.centerWrist, to: points.centerBiceps }); + points.logo = points.centerBiceps.shiftFractionTowards(points.centerWrist, 0.3) + snippets.logo = new Snippet('logo', points.logo) + macro('title', { at: points.centerBiceps, nr: 3, title: 'sleeve' }) + macro('grainline', { from: points.centerWrist, to: points.centerBiceps }) points.scaleboxAnchor = points.scalebox = points.centerBiceps.shiftFractionTowards( points.centerWrist, 0.5 - ); - macro("scalebox", { at: points.scalebox }); + ) + macro('scalebox', { at: points.scalebox }) points.frontNotch = paths.sleevecap.shiftAlong( paths.sleevecap.length() / 2 - - store.get("frontShoulderToArmholePitch") - - store.get("sleevecapEase") / 2 - ); + store.get('frontShoulderToArmholePitch') - + store.get('sleevecapEase') / 2 + ) points.backNotch = paths.sleevecap.shiftAlong( paths.sleevecap.length() / 2 + - store.get("backShoulderToArmholePitch") + - store.get("sleevecapEase") / 2 - ); - snippets.frontNotch = new Snippet("notch", points.frontNotch); - snippets.backNotch = new Snippet("bnotch", points.backNotch); - if (sa) paths.sa = paths.seam.offset(sa).attr("class", "fabric sa"); + store.get('backShoulderToArmholePitch') + + store.get('sleevecapEase') / 2 + ) + snippets.frontNotch = new Snippet('notch', points.frontNotch) + snippets.backNotch = new Snippet('bnotch', points.backNotch) + if (sa) paths.sa = paths.seam.offset(sa).attr('class', 'fabric sa') } // Paperless? if (paperless) { - macro("vd", { + macro('vd', { from: points.wristLeft, to: points.bicepsLeft, x: points.bicepsLeft.x - sa - 15 - }); - macro("vd", { + }) + macro('vd', { from: points.wristLeft, to: points.sleeveTip, x: points.bicepsLeft.x - sa - 30 - }); - macro("hd", { + }) + macro('hd', { from: points.bicepsLeft, to: points.bicepsRight, y: points.sleeveTip.y - sa - 30 - }); - macro("hd", { + }) + macro('hd', { from: points.wristLeft, to: points.wristRight, y: points.wristLeft.y + sa + 30 - }); - macro("pd", { + }) + macro('pd', { path: paths.sleevecap.reverse(), d: -1 * sa - 15 - }); + }) } - return part; -}; + return part +} diff --git a/packages/brian/src/sleevecap.js b/packages/brian/src/sleevecap.js index f28aa53bf92..b0ba418c039 100644 --- a/packages/brian/src/sleevecap.js +++ b/packages/brian/src/sleevecap.js @@ -2,139 +2,116 @@ * Positive values mean sleevecap is longer than armhole */ function sleevecapDelta(store) { - return store.get("sleevecapLength") - store.get("sleevecapTarget"); + return store.get('sleevecapLength') - store.get('sleevecapTarget') } function sleevecapAdjust(store) { - let delta = sleevecapDelta(store); - let factor = store.get("sleeveFactor"); - if (delta > 0) factor = factor * 0.98; - else factor = factor * 1.02; - store.set("sleeveFactor", factor); + let delta = sleevecapDelta(store) + let factor = store.get('sleeveFactor') + if (delta > 0) factor = factor * 0.98 + else factor = factor * 1.02 + store.set('sleeveFactor', factor) } function draftSleevecap(part, run) { - let { - debug, - units, - store, - measurements, - options, - Point, - points, - Path, - paths - } = part.shorthand(); + let { debug, units, store, measurements, options, Point, points, Path, paths } = part.shorthand() // Sleeve center axis - points.centerBiceps = new Point(0, 0); + points.centerBiceps = new Point(0, 0) points.centerCap = points.centerBiceps.shift( 90, options.sleevecapTopFactorY * (measurements.bicepsCircumference * (1 + options.bicepsEase) * options.armholeDepthFactor * - store.get("sleeveFactor")) - ); + store.get('sleeveFactor')) + ) // Left and right biceps points, limit impact of sleeveFactor to 25% - let halfWidth = - (measurements.bicepsCircumference * (1 + options.bicepsEase)) / 2; + let halfWidth = (measurements.bicepsCircumference * (1 + options.bicepsEase)) / 2 points.bicepsLeft = points.centerBiceps.shift( 180, halfWidth * options.sleeveWidthGuarantee + - halfWidth * (1 - options.sleeveWidthGuarantee) * store.get("sleeveFactor") - ); - points.bicepsRight = points.bicepsLeft.flipX(points.centerBiceps); + halfWidth * (1 - options.sleeveWidthGuarantee) * store.get('sleeveFactor') + ) + points.bicepsRight = points.bicepsLeft.flipX(points.centerBiceps) // Adapt sleeve center axis - points.capLeft = new Point(points.bicepsLeft.x, points.centerCap.y); - points.capRight = points.capLeft.flipX(); + points.capLeft = new Point(points.bicepsLeft.x, points.centerCap.y) + points.capRight = points.capLeft.flipX() points.centerCap = points.capLeft.shiftFractionTowards( points.capRight, options.sleevecapTopFactorX - ); + ) // Pitch points - let width = points.bicepsRight.x; - let height = points.centerCap.y; + let width = points.bicepsRight.x + let height = points.centerCap.y points.backPitch = new Point( -1 * width * options.sleevecapBackFactorX, height * options.sleevecapBackFactorY - ); + ) points.frontPitch = new Point( width * options.sleevecapFrontFactorX, height * options.sleevecapFrontFactorY - ); + ) // 4 sleevecap quadrants // Base points - points.capQ1Base = points.frontPitch.shiftFractionTowards( - points.bicepsRight, - 0.5 - ); - points.capQ2Base = points.frontPitch.shiftFractionTowards( - points.centerCap, - 0.5 - ); - points.capQ3Base = points.backPitch.shiftFractionTowards( - points.centerCap, - 0.5 - ); - points.capQ4Base = points.backPitch.shiftFractionTowards( - points.bicepsLeft, - 0.5 - ); + points.capQ1Base = points.frontPitch.shiftFractionTowards(points.bicepsRight, 0.5) + points.capQ2Base = points.frontPitch.shiftFractionTowards(points.centerCap, 0.5) + points.capQ3Base = points.backPitch.shiftFractionTowards(points.centerCap, 0.5) + points.capQ4Base = points.backPitch.shiftFractionTowards(points.bicepsLeft, 0.5) // Offset points - let baseOffset = measurements.bicepsCircumference * (1 + options.bicepsEase); + let baseOffset = measurements.bicepsCircumference * (1 + options.bicepsEase) points.capQ1 = points.capQ1Base.shift( points.bicepsRight.angle(points.frontPitch) + 90, baseOffset * options.sleevecapQ1Offset - ); + ) points.capQ2 = points.capQ2Base.shift( points.centerCap.angle(points.frontPitch) + 90, baseOffset * options.sleevecapQ2Offset - ); + ) points.capQ3 = points.capQ3Base.shift( points.centerCap.angle(points.backPitch) - 90, baseOffset * options.sleevecapQ3Offset - ); + ) points.capQ4 = points.capQ4Base.shift( points.bicepsLeft.angle(points.backPitch) - 90, baseOffset * options.sleevecapQ4Offset - ); + ) // Control points points.capQ1Cp1 = points.capQ1.shift( points.frontPitch.angle(points.bicepsRight), baseOffset * options.sleevecapQ1Spread1 - ); + ) points.capQ1Cp2 = points.capQ1.shift( points.frontPitch.angle(points.bicepsRight), baseOffset * options.sleevecapQ1Spread2 * -1 - ); + ) points.capQ2Cp1 = points.capQ2.shift( points.centerCap.angle(points.frontPitch), baseOffset * options.sleevecapQ2Spread1 - ); + ) points.capQ2Cp2 = points.capQ2.shift( points.centerCap.angle(points.frontPitch), baseOffset * options.sleevecapQ2Spread2 * -1 - ); + ) points.capQ3Cp1 = points.capQ3.shift( points.backPitch.angle(points.centerCap), baseOffset * options.sleevecapQ3Spread1 - ); + ) points.capQ3Cp2 = points.capQ3.shift( points.backPitch.angle(points.centerCap), baseOffset * options.sleevecapQ3Spread2 * -1 - ); + ) points.capQ4Cp1 = points.capQ4.shift( points.bicepsLeft.angle(points.backPitch), baseOffset * options.sleevecapQ4Spread1 - ); + ) points.capQ4Cp2 = points.capQ4.shift( points.bicepsLeft.angle(points.backPitch), baseOffset * options.sleevecapQ4Spread2 * -1 - ); + ) // Sleevecap seamline paths.sleevecap = new Path() @@ -143,21 +120,20 @@ function draftSleevecap(part, run) { .curve(points.capQ1Cp2, points.capQ2Cp1, points.capQ2) .curve(points.capQ2Cp2, points.capQ3Cp1, points.capQ3) .curve(points.capQ3Cp2, points.capQ4Cp1, points.capQ4) - .curve(points.capQ4Cp2, points.bicepsLeft, points.bicepsLeft); + .curve(points.capQ4Cp2, points.bicepsLeft, points.bicepsLeft) // Store sleevecap length - store.set("sleevecapLength", paths.sleevecap.length()); + store.set('sleevecapLength', paths.sleevecap.length()) if (run === 0) { - let armholeLength = - store.get("frontArmholeLength") + store.get("backArmholeLength"); - let sleevecapEase = armholeLength * options.sleevecapEase; - store.set("sleevecapEase", sleevecapEase); - store.set("sleevecapTarget", armholeLength + sleevecapEase); + let armholeLength = store.get('frontArmholeLength') + store.get('backArmholeLength') + let sleevecapEase = armholeLength * options.sleevecapEase + store.set('sleevecapEase', sleevecapEase) + store.set('sleevecapTarget', armholeLength + sleevecapEase) debug({ - style: "info", - label: "🗸 Sleevecap ease", + style: 'info', + label: '🗸 Sleevecap ease', msg: units(sleevecapEase) - }); + }) // Uncomment this line to see all sleevecap iterations //paths[run] = paths.sleevecap; @@ -165,41 +141,37 @@ function draftSleevecap(part, run) { } export default part => { - let { debug, store, units, options, Point, points, paths } = part.shorthand(); + let { debug, store, units, options, Point, points, paths } = part.shorthand() - store.set("sleeveFactor", 1); - let run = 0; - let delta = 0; + store.set('sleeveFactor', 1) + let run = 0 + let delta = 0 do { - draftSleevecap(part, run); - delta = sleevecapDelta(store); - sleevecapAdjust(store); - run++; - } while ( - options.brianFitSleeve === true && - run < 30 && - Math.abs(sleevecapDelta(store)) > 2 - ); + draftSleevecap(part, run) + delta = sleevecapDelta(store) + sleevecapAdjust(store) + run++ + } while (options.brianFitSleeve === true && run < 30 && Math.abs(sleevecapDelta(store)) > 2) if (options.brianFitSleeve) { debug({ - style: "success", - label: "🏁 Sleevecap fitted", - msg: `Target was ${units(store.get("sleevecapTarget"))}, delta of ${units( + style: 'success', + label: '🏁 Sleevecap fitted', + msg: `Target was ${units(store.get('sleevecapTarget'))}, delta of ${units( delta )} reached in ${run} attempts.` - }); + }) } else debug({ - style: "warning", - label: "🚫 Not fittingsleevecap", - msg: "(in Brian)" - }); + style: 'warning', + label: '🚫 Not fittingsleevecap', + msg: '(in Brian)' + }) // Paths - paths.sleevecap.attr("class", "fabric"); + paths.sleevecap.attr('class', 'fabric') // Anchor point for sampling - points.gridAnchor = new Point(0, 0); + points.gridAnchor = new Point(0, 0) - return part; -}; + return part +} diff --git a/packages/bruce/example/src/App.js b/packages/bruce/example/src/App.js index e7936330e5d..115cdf683af 100644 --- a/packages/bruce/example/src/App.js +++ b/packages/bruce/example/src/App.js @@ -1,22 +1,15 @@ -import React from "react"; -import freesewing from "@freesewing/core"; -import Workbench from "@freesewing/components/Workbench"; -import "typeface-roboto-condensed"; -import "@freesewing/css-theme"; +import React from 'react' +import freesewing from '@freesewing/core' +import Workbench from '@freesewing/components/Workbench' +import 'typeface-roboto-condensed' +import '@freesewing/css-theme' -import Pattern from "pattern"; +import Pattern from 'pattern' const App = props => { - let instance = new Pattern(); - let config = instance.config; - return ( - - ); -}; + let instance = new Pattern() + let config = instance.config + return +} -export default App; +export default App diff --git a/packages/bruce/example/src/index.js b/packages/bruce/example/src/index.js index 7900787a4d2..9dd7ba788d4 100644 --- a/packages/bruce/example/src/index.js +++ b/packages/bruce/example/src/index.js @@ -1,11 +1,11 @@ -import React from "react"; -import ReactDOM from "react-dom"; -import App from "./App"; -import * as serviceWorker from "./serviceWorker"; +import React from 'react' +import ReactDOM from 'react-dom' +import App from './App' +import * as serviceWorker from './serviceWorker' -ReactDOM.render(, document.getElementById("root")); +ReactDOM.render(, document.getElementById('root')) // If you want your app to work offline and load faster, you can change // unregister() to register() below. Note this comes with some pitfalls. // Learn more about service workers: http://bit.ly/CRA-PWA -serviceWorker.unregister(); +serviceWorker.unregister() diff --git a/packages/bruce/example/src/serviceWorker.js b/packages/bruce/example/src/serviceWorker.js index 68fda5a0eb6..44e1b1b2f8c 100644 --- a/packages/bruce/example/src/serviceWorker.js +++ b/packages/bruce/example/src/serviceWorker.js @@ -9,46 +9,44 @@ // This link also includes instructions on opting out of this behavior. const isLocalhost = Boolean( - window.location.hostname === "localhost" || + window.location.hostname === 'localhost' || // [::1] is the IPv6 localhost address. - window.location.hostname === "[::1]" || + window.location.hostname === '[::1]' || // 127.0.0.1/8 is considered localhost for IPv4. - window.location.hostname.match( - /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ - ) -); + window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/) +) export function register(config) { - if (process.env.NODE_ENV === "production" && "serviceWorker" in navigator) { + if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) { // The URL constructor is available in all browsers that support SW. - const publicUrl = new URL(process.env.PUBLIC_URL, window.location); + const publicUrl = new URL(process.env.PUBLIC_URL, window.location) if (publicUrl.origin !== window.location.origin) { // Our service worker won't work if PUBLIC_URL is on a different origin // from what our page is served on. This might happen if a CDN is used to // serve assets; see https://github.com/facebook/create-react-app/issues/2374 - return; + return } - window.addEventListener("load", () => { - const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; + window.addEventListener('load', () => { + const swUrl = `${process.env.PUBLIC_URL}/service-worker.js` if (isLocalhost) { // This is running on localhost. Let's check if a service worker still exists or not. - checkValidServiceWorker(swUrl, config); + checkValidServiceWorker(swUrl, config) // Add some additional logging to localhost, pointing developers to the // service worker/PWA documentation. navigator.serviceWorker.ready.then(() => { console.log( - "This web app is being served cache-first by a service " + - "worker. To learn more, visit https://goo.gl/SC7cgQ" - ); - }); + 'This web app is being served cache-first by a service ' + + 'worker. To learn more, visit https://goo.gl/SC7cgQ' + ) + }) } else { // Is not local host. Just register service worker - registerValidSW(swUrl, config); + registerValidSW(swUrl, config) } - }); + }) } } @@ -57,38 +55,38 @@ function registerValidSW(swUrl, config) { .register(swUrl) .then(registration => { registration.onupdatefound = () => { - const installingWorker = registration.installing; + const installingWorker = registration.installing installingWorker.onstatechange = () => { - if (installingWorker.state === "installed") { + if (installingWorker.state === 'installed') { if (navigator.serviceWorker.controller) { // At this point, the old content will have been purged and // the fresh content will have been added to the cache. // It's the perfect time to display a "New content is // available; please refresh." message in your web app. - console.log("New content is available; please refresh."); + console.log('New content is available; please refresh.') // Execute callback if (config.onUpdate) { - config.onUpdate(registration); + config.onUpdate(registration) } } else { // At this point, everything has been precached. // It's the perfect time to display a // "Content is cached for offline use." message. - console.log("Content is cached for offline use."); + console.log('Content is cached for offline use.') // Execute callback if (config.onSuccess) { - config.onSuccess(registration); + config.onSuccess(registration) } } } - }; - }; + } + } }) .catch(error => { - console.error("Error during service worker registration:", error); - }); + console.error('Error during service worker registration:', error) + }) } function checkValidServiceWorker(swUrl, config) { @@ -98,30 +96,28 @@ function checkValidServiceWorker(swUrl, config) { // Ensure service worker exists, and that we really are getting a JS file. if ( response.status === 404 || - response.headers.get("content-type").indexOf("javascript") === -1 + response.headers.get('content-type').indexOf('javascript') === -1 ) { // No service worker found. Probably a different app. Reload the page. navigator.serviceWorker.ready.then(registration => { registration.unregister().then(() => { - window.location.reload(); - }); - }); + window.location.reload() + }) + }) } else { // Service worker found. Proceed as normal. - registerValidSW(swUrl, config); + registerValidSW(swUrl, config) } }) .catch(() => { - console.log( - "No internet connection found. App is running in offline mode." - ); - }); + console.log('No internet connection found. App is running in offline mode.') + }) } export function unregister() { - if ("serviceWorker" in navigator) { + if ('serviceWorker' in navigator) { navigator.serviceWorker.ready.then(registration => { - registration.unregister(); - }); + registration.unregister() + }) } } diff --git a/packages/bruce/src/back.js b/packages/bruce/src/back.js index 643b31cb81b..18c73b7c15a 100644 --- a/packages/bruce/src/back.js +++ b/packages/bruce/src/back.js @@ -1,4 +1,4 @@ -import init from "./init"; +import init from './init' export default function(part) { let { @@ -14,55 +14,49 @@ export default function(part) { paperless, macro, utils - } = part.shorthand(); + } = part.shorthand() // Initialize - init(part); + init(part) // Center back - points.zero = new Point(0, 0); - points.center = points.zero.shift(90, store.get("rise")); + points.zero = new Point(0, 0) + points.center = points.zero.shift(90, store.get('rise')) // Side top - points.sideRight = new Point(store.get("hipsBack") / 2, points.center.y); + points.sideRight = new Point(store.get('hipsBack') / 2, points.center.y) // Gusset - points.gussetTop = points.center.shift(-90, store.get("riseLength")); - points.gussetBottom = points.gussetTop.shift( - -90, - store.get("gusset") + store.get("legBonus") - ); - points.gussetRight = points.gussetBottom.shift( - 0, - (store.get("gusset") * store.get("xScale")) / 2 - ); - points.gussetCpRight = new Point(points.gussetRight.x, points.gussetTop.y); + points.gussetTop = points.center.shift(-90, store.get('riseLength')) + points.gussetBottom = points.gussetTop.shift(-90, store.get('gusset') + store.get('legBonus')) + points.gussetRight = points.gussetBottom.shift(0, (store.get('gusset') * store.get('xScale')) / 2) + points.gussetCpRight = new Point(points.gussetRight.x, points.gussetTop.y) // Find leg edge let isect = utils.circlesIntersect( points.gussetRight, - store.get("legBack"), + store.get('legBack'), points.sideRight, - store.get("fullLength") - ); - points.legRight = isect[1]; - points.legLeft = points.legRight.flipX(points.center); + store.get('fullLength') + ) + points.legRight = isect[1] + points.legLeft = points.legRight.flipX(points.center) // Store back seam length and (half of the) crotch seam length - store.set("backSeamLength", points.sideRight.dist(points.legRight)); + store.set('backSeamLength', points.sideRight.dist(points.legRight)) store.set( - "crotchSeamLength", + 'crotchSeamLength', new Path() .move(points.gussetTop) .curve(points.gussetCpRight, points.gussetRight, points.gussetRight) .length() - ); + ) // Handle back rise - points.center = points.center.shift(90, store.get("backRise")); - points.sideRight = points.sideRight.shift(90, store.get("sideRise")); - points.centerCpRight = new Point(points.sideRight.x / 2, points.center.y); - points.centerCpLeft = points.centerCpRight.flipX(); + points.center = points.center.shift(90, store.get('backRise')) + points.sideRight = points.sideRight.shift(90, store.get('sideRise')) + points.centerCpRight = new Point(points.sideRight.x / 2, points.center.y) + points.centerCpLeft = points.centerCpRight.flipX() paths.seam = new Path() .move(points.gussetTop) @@ -72,7 +66,7 @@ export default function(part) { .curve(points.sideRight, points.centerCpRight, points.center) .line(points.gussetTop) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') // Complete pattern? if (complete) { @@ -81,15 +75,15 @@ export default function(part) { .move(points.legRight) .line(points.sideRight) .curve(points.sideRight, points.centerCpRight, points.center) - .offset(sa); + .offset(sa) let sa2 = new Path() .move(points.gussetTop) .curve(points.gussetCpRight, points.gussetRight, points.gussetRight) - .offset(sa); + .offset(sa) let hemSa = new Path() .move(points.gussetRight) .line(points.legRight) - .offset(sa * 2); + .offset(sa * 2) paths.sa = new Path() .move(points.gussetTop) .line(sa2.start()) @@ -97,68 +91,65 @@ export default function(part) { .join(hemSa) .join(sa1) .line(points.center) - .attr("class", "fabric sa"); + .attr('class', 'fabric sa') } - points.title = new Point( - points.sideRight.x * 0.6, - points.gussetTop.y * 0.6 - ); - macro("title", { + points.title = new Point(points.sideRight.x * 0.6, points.gussetTop.y * 0.6) + macro('title', { at: points.title, nr: 1, - title: "back" - }); - macro("cutonfold", { + title: 'back' + }) + macro('cutonfold', { from: points.center, to: points.gussetTop, grainline: true - }); - snippets.logo = new Snippet("logo", points.title.shift(90, 50)); + }) + snippets.logo = new Snippet('logo', points.title.shift(90, 50)) } // Paperless? if (paperless) { - macro("vd", { + macro('vd', { from: points.gussetTop, to: points.center, x: points.center.x - 15 - }); - macro("vd", { + }) + macro('vd', { from: points.gussetRight, to: points.center, x: points.center.x - 30 - }); - macro("vd", { + }) + macro('vd', { from: points.legRight, to: points.sideRight, x: points.legRight.x + 15 + sa - }); - macro("vd", { + }) + macro('vd', { from: points.legRight, to: points.center, x: points.legRight.x + 30 + sa - }); - macro("hd", { + }) + macro('hd', { from: points.center, to: points.sideRight, y: points.center.y - 15 - sa - }); - macro("hd", { + }) + macro('hd', { from: points.gussetTop, to: points.gussetRight, y: points.gussetRight.y + 15 + sa * 2 - }); - macro("hd", { + }) + macro('hd', { from: points.gussetTop, to: points.legRight, y: points.gussetRight.y + 30 + sa * 2 - }); - macro("ld", { + }) + macro('ld', { from: points.gussetRight, to: points.legRight, d: -15 - sa * 2 - }); + }) } - return part; + return part } diff --git a/packages/bruce/src/front.js b/packages/bruce/src/front.js index f0ffdb4e9a0..8fa42d0759f 100644 --- a/packages/bruce/src/front.js +++ b/packages/bruce/src/front.js @@ -1,32 +1,25 @@ -import init from "./init"; +import init from './init' function tuskDelta(part) { - let { Path, points, store } = part.shorthand(); + let { Path, points, store } = part.shorthand() let len = new Path() .move(points.midRight) - .curve( - points.curveRightCpTop, - points.curveRightCpBottom, - points.rightTuskRight - ) - .length(); + .curve(points.curveRightCpTop, points.curveRightCpBottom, points.rightTuskRight) + .length() - return len - store.get("curve"); + return len - store.get('curve') } function tweakTusk(delta, part) { - let { points } = part.shorthand(); + let { points } = part.shorthand() - let factor; - if (Math.abs(delta) > 2) factor = 3; - else factor = 5; + let factor + if (Math.abs(delta) > 2) factor = 3 + else factor = 5 - points.rightTuskRight = points.rightTuskRight.shift(90, delta / factor); - points.rightTuskLeft = points.rightTuskLeft.shift(90, delta / factor); - points.curveRightCpBottom = points.curveRightCpBottom.shift( - 90, - delta / factor - ); + points.rightTuskRight = points.rightTuskRight.shift(90, delta / factor) + points.rightTuskLeft = points.rightTuskLeft.shift(90, delta / factor) + points.curveRightCpBottom = points.curveRightCpBottom.shift(90, delta / factor) } export default function(part) { @@ -43,133 +36,108 @@ export default function(part) { macro, utils, debug - } = part.shorthand(); + } = part.shorthand() // Initialize - init(part); + init(part) - points.topRight = new Point(store.get("hipsFront") / 2, 0); - points.topLeft = points.topRight.flipX(); - points.midMid = new Point(0, store.get("heightFront")); - points.midRight = new Point( - points.topRight.x + store.get("heightFront") * 0.05, - points.midMid.y - ); - points.midLeft = points.midRight.flipX(); + points.topRight = new Point(store.get('hipsFront') / 2, 0) + points.topLeft = points.topRight.flipX() + points.midMid = new Point(0, store.get('heightFront')) + points.midRight = new Point(points.topRight.x + store.get('heightFront') * 0.05, points.midMid.y) + points.midLeft = points.midRight.flipX() // Store this length for a notch on the side part - store.set("frontNotch", points.topRight.dist(points.midRight)); + store.set('frontNotch', points.topRight.dist(points.midRight)) - points.bottomMid = new Point(0, store.get("riseLength")); + points.bottomMid = new Point(0, store.get('riseLength')) points.rightTuskRight = new Point( - store.get("gusset") * - store.get("xScale") * - (1 - store.get("gussetInsetRatio")), + store.get('gusset') * store.get('xScale') * (1 - store.get('gussetInsetRatio')), points.bottomMid.y - ); - points.rightTuskLeft = points.bottomMid.clone(); + ) + points.rightTuskLeft = points.bottomMid.clone() points.curveRightCpTop = new Point( - points.midRight.x - store.get("gusset") * 1.3, + points.midRight.x - store.get('gusset') * 1.3, points.midRight.y - ); + ) points.curveRightCpBottom = new Point( points.rightTuskRight.x, - points.rightTuskRight.y - store.get("gusset") * 1.3 - ); + points.rightTuskRight.y - store.get('gusset') * 1.3 + ) // Adjust tusk length to fit inset curve - let delta = tuskDelta(part); - let count = 0; + let delta = tuskDelta(part) + let count = 0 while (Math.abs(delta) > 1) { // Below 1mm is good enough - tweakTusk(delta, part); - delta = tuskDelta(part); - count++; + tweakTusk(delta, part) + delta = tuskDelta(part) + count++ if (count > 150) - throw "We got stuck trying to calculate an optimal tusk length. Please report this."; + throw 'We got stuck trying to calculate an optimal tusk length. Please report this.' } - debug( - `After ${count} iterations, tusk curve length is ${utils.round( - delta - )}mm off.` - ); + debug(`After ${count} iterations, tusk curve length is ${utils.round(delta)}mm off.`) // Adjust midMid to new length - points.bottomMid = new Point(0, points.rightTuskLeft.y); + points.bottomMid = new Point(0, points.rightTuskLeft.y) // Front dart only if bulge > 0 if (options.bulge > 0) { // Rotate tusk according to bulge option - for (let pid of [ - "curveRightCpTop", - "curveRightCpBottom", - "rightTuskRight", - "rightTuskLeft" - ]) { - points[pid] = points[pid].rotate(options.bulge, points.midRight); + for (let pid of ['curveRightCpTop', 'curveRightCpBottom', 'rightTuskRight', 'rightTuskLeft']) { + points[pid] = points[pid].rotate(options.bulge, points.midRight) } // Dart join point - points.dartJoin = new Point( - 0, - points.midMid.y + 0.65 * points.midMid.dist(points.bottomMid) - ); + points.dartJoin = new Point(0, points.midMid.y + 0.65 * points.midMid.dist(points.bottomMid)) // Dart control point points.dartCpRight = new Point( 0, - points.dartJoin.y + - points.dartJoin.dist(points.bottomMid) * (options.bulge / 30) - ); - points.dartCpRight = points.dartCpRight.rotate( - options.bulge, - points.dartJoin - ); + points.dartJoin.y + points.dartJoin.dist(points.bottomMid) * (options.bulge / 30) + ) + points.dartCpRight = points.dartCpRight.rotate(options.bulge, points.dartJoin) // Flip control point to left side - points.dartCpLeft = points.dartCpRight.flipX(); + points.dartCpLeft = points.dartCpRight.flipX() } else { - points.dartJoin = points.rightTuskLeft; + points.dartJoin = points.rightTuskLeft } // Flip points to left side - points.leftTuskRight = points.rightTuskLeft.flipX(); - points.leftTuskLeft = points.rightTuskRight.flipX(); - points.curveLeftCpBottom = points.curveRightCpBottom.flipX(); - points.curveLeftCpTop = points.curveRightCpTop.flipX(); + points.leftTuskRight = points.rightTuskLeft.flipX() + points.leftTuskLeft = points.rightTuskRight.flipX() + points.curveLeftCpBottom = points.curveRightCpBottom.flipX() + points.curveLeftCpTop = points.curveRightCpTop.flipX() // Handle back rise - points.topMid = new Point(0, points.topLeft.y); - points.topLeft = points.topLeft.shift(90, store.get("frontRise")); - points.topRight = points.topRight.shift(90, store.get("frontRise")); - points.topMidCpRight = new Point(points.topRight.x / 2, points.topMid.y); - points.topMidCpLeft = points.topMidCpRight.flipX(); + points.topMid = new Point(0, points.topLeft.y) + points.topLeft = points.topLeft.shift(90, store.get('frontRise')) + points.topRight = points.topRight.shift(90, store.get('frontRise')) + points.topMidCpRight = new Point(points.topRight.x / 2, points.topMid.y) + points.topMidCpLeft = points.topMidCpRight.flipX() if (options.bulge > 0) { paths.trimBase = new Path() .move(points.rightTuskLeft) .curve(points.rightTuskLeft, points.dartCpRight, points.dartJoin) - .curve(points.dartCpLeft, points.leftTuskRight, points.leftTuskRight); + .curve(points.dartCpLeft, points.leftTuskRight, points.leftTuskRight) paths.seamStart = new Path() .move(points.midLeft) .line(points.topLeft) .curve(points.topLeft, points.topMidCpLeft, points.topMid) .curve(points.topMidCpRight, points.topRight, points.topRight) .line(points.midRight) - .curve( - points.curveRightCpTop, - points.curveRightCpBottom, - points.rightTuskRight - ) - .line(points.rightTuskLeft); + .curve(points.curveRightCpTop, points.curveRightCpBottom, points.rightTuskRight) + .line(points.rightTuskLeft) paths.seamEnd = new Path() .move(points.leftTuskRight) .line(points.leftTuskLeft) - .curve(points.curveLeftCpBottom, points.curveLeftCpTop, points.midLeft); - paths.seamStart.render = false; - paths.trimBase.render = false; - paths.seamEnd.render = false; - paths.seam = paths.seamStart.join(paths.trimBase).join(paths.seamEnd); + .curve(points.curveLeftCpBottom, points.curveLeftCpTop, points.midLeft) + paths.seamStart.render = false + paths.trimBase.render = false + paths.seamEnd.render = false + paths.seam = paths.seamStart.join(paths.trimBase).join(paths.seamEnd) } else { paths.seam = new Path() .move(points.midLeft) @@ -177,140 +145,128 @@ export default function(part) { .curve(points.topLeft, points.topMidCpLeft, points.topMid) .curve(points.topMidCpRight, points.topRight, points.topRight) .line(points.midRight) - .curve( - points.curveRightCpTop, - points.curveRightCpBottom, - points.rightTuskRight - ) + .curve(points.curveRightCpTop, points.curveRightCpBottom, points.rightTuskRight) .line(points.leftTuskLeft) - .curve(points.curveLeftCpBottom, points.curveLeftCpTop, points.midLeft); + .curve(points.curveLeftCpBottom, points.curveLeftCpTop, points.midLeft) } - paths.seam.close().attr("class", "fabric"); + paths.seam.close().attr('class', 'fabric') // Complete pattern? if (complete) { if (sa) { if (options.bulge > 0) { - let saStart = paths.seamStart.offset(sa * -1); - let saTrim = paths.trimBase.offset(sa * -1).trim(); - let saEnd = paths.seamEnd.offset(sa * -1); + let saStart = paths.seamStart.offset(sa * -1) + let saTrim = paths.trimBase.offset(sa * -1).trim() + let saEnd = paths.seamEnd.offset(sa * -1) paths.sa = saStart .join(saTrim) .join(saEnd) .close() - .attr("class", "fabric sa"); + .attr('class', 'fabric sa') } else { paths.sa = paths.seam .offset(sa * -1) .trim() .close() - .attr("class", "fabric sa"); + .attr('class', 'fabric sa') } } - macro("title", { + macro('title', { at: points.midMid, nr: 2, - title: "front" - }); - macro("grainline", { + title: 'front' + }) + macro('grainline', { from: points.dartJoin, to: points.topMid - }); + }) } // Paperless? if (paperless) { - macro("hd", { + macro('hd', { from: points.topLeft, to: points.topRight, y: points.topLeft.y - 15 - sa - }); - macro("hd", { + }) + macro('hd', { from: points.midLeft, to: points.midRight, y: points.topLeft.y - 30 - sa - }); - macro("vd", { + }) + macro('vd', { from: points.midLeft, to: points.topMid, x: points.midLeft.x - 15 - sa - }); - macro("vd", { + }) + macro('vd', { from: points.midLeft, to: points.topLeft, x: points.midLeft.x - 30 - sa - }); + }) if (options.bulge === 0) { - macro("hd", { + macro('hd', { from: points.leftTuskLeft, to: points.rightTuskRight, y: points.leftTuskLeft.y + 15 + sa - }); - macro("vd", { + }) + macro('vd', { from: points.leftTuskLeft, to: points.topLeft, x: points.midLeft.x - 45 - sa - }); + }) } else { - macro("vd", { + macro('vd', { from: points.leftTuskLeft, to: points.topLeft, x: points.midLeft.x - 45 - sa - }); - macro("vd", { + }) + macro('vd', { from: points.leftTuskRight, to: points.topLeft, x: points.midLeft.x - 60 - sa - }); + }) points.narrowRight = new Path() .move(points.midRight) - .curve( - points.curveRightCpTop, - points.curveRightCpBottom, - points.rightTuskRight - ) - .edge("left"); + .curve(points.curveRightCpTop, points.curveRightCpBottom, points.rightTuskRight) + .edge('left') points.narrowLeft = new Path() .move(points.midLeft) - .curve( - points.curveLeftCpTop, - points.curveLeftCpBottom, - points.leftTuskLeft - ) - .attr("class", "various stroke-xl lashed") - .edge("right"); - macro("hd", { + .curve(points.curveLeftCpTop, points.curveLeftCpBottom, points.leftTuskLeft) + .attr('class', 'various stroke-xl lashed') + .edge('right') + macro('hd', { from: points.narrowLeft, to: points.narrowRight, y: points.narrowLeft.y - }); - macro("hd", { + }) + macro('hd', { from: points.leftTuskRight, to: points.rightTuskLeft, y: points.rightTuskLeft.y + 15 + sa - }); - macro("hd", { + }) + macro('hd', { from: points.leftTuskLeft, to: points.rightTuskRight, y: points.rightTuskLeft.y + 30 + sa - }); - macro("ld", { + }) + macro('ld', { from: points.rightTuskLeft, to: points.rightTuskRight, d: -15 - sa - }); - macro("vd", { + }) + macro('vd', { from: points.narrowRight, to: points.topRight, x: points.topRight.x + 15 + sa - }); - macro("vd", { + }) + macro('vd', { from: points.dartJoin, to: points.topRight, x: points.topRight.x + 30 + sa - }); + }) } } - return part; + return part } diff --git a/packages/bruce/src/index.js b/packages/bruce/src/index.js index ec775ecfe1d..37ef3615431 100644 --- a/packages/bruce/src/index.js +++ b/packages/bruce/src/index.js @@ -1,19 +1,19 @@ -import freesewing from "@freesewing/core"; -import plugins from "@freesewing/plugin-bundle"; -import config from "../config"; +import freesewing from '@freesewing/core' +import plugins from '@freesewing/plugin-bundle' +import config from '../config' // Parts -import draftBack from "./back"; -import draftSide from "./side"; -import draftFront from "./front"; -import draftInset from "./inset"; +import draftBack from './back' +import draftSide from './side' +import draftFront from './front' +import draftInset from './inset' // Create design -const Pattern = new freesewing.Design(config, plugins); +const Pattern = new freesewing.Design(config, plugins) // Attach draft methods to prototype -Pattern.prototype.draftBack = part => draftBack(part); -Pattern.prototype.draftSide = part => draftSide(part); -Pattern.prototype.draftInset = part => draftInset(part); -Pattern.prototype.draftFront = part => draftFront(part); +Pattern.prototype.draftBack = part => draftBack(part) +Pattern.prototype.draftSide = part => draftSide(part) +Pattern.prototype.draftInset = part => draftInset(part) +Pattern.prototype.draftFront = part => draftFront(part) -export default Pattern; +export default Pattern diff --git a/packages/bruce/src/init.js b/packages/bruce/src/init.js index df0d87613de..71b3b6ada1a 100644 --- a/packages/bruce/src/init.js +++ b/packages/bruce/src/init.js @@ -1,50 +1,54 @@ export default function init(part) { - let {store, options, measurements, utils} = part.shorthand(); + let { store, options, measurements, utils } = part.shorthand() - if(store.get('init') !== true) { + if (store.get('init') !== true) { /* Set vertical scale to 1 (no stretch) */ - store.set('yScale', 1); + store.set('yScale', 1) /* Store rise, backRise and legBonus as absolute values */ - store.set('rise', measurements.hipsToUpperLeg * options.rise * store.get('yScale')); - store.set('backRise', measurements.hipsToUpperLeg * options.backRise * store.get('yScale')); - store.set('sideRise', store.get('backRise') * 0.75); - store.set('frontRise', store.get('backRise') * 0.25); - store.set('legBonus', measurements.hipsToUpperLeg * options.legBonus * store.get('yScale')); + store.set('rise', measurements.hipsToUpperLeg * options.rise * store.get('yScale')) + store.set('backRise', measurements.hipsToUpperLeg * options.backRise * store.get('yScale')) + store.set('sideRise', store.get('backRise') * 0.75) + store.set('frontRise', store.get('backRise') * 0.25) + store.set('legBonus', measurements.hipsToUpperLeg * options.legBonus * store.get('yScale')) /* Set horizontal scale based on stretch */ - store.set('xScale', utils.stretchToScale(options.stretch)); - store.set('xScaleLegs', utils.stretchToScale(options.legStretch)); + store.set('xScale', utils.stretchToScale(options.stretch)) + store.set('xScaleLegs', utils.stretchToScale(options.legStretch)) /* Ratio of parts at the hips*/ - store.set('hips', measurements.hipsCircumference * store.get('xScale')); - store.set('hipsFront', store.get('hips') * options.hipRatioFront); - let hipRatioSide = (1 - (options.hipRatioFront + options.hipRatioBack)) / 2; - store.set('hipsSide', store.get('hips') * hipRatioSide); - store.set('hipsBack', store.get('hips') * options.hipRatioBack); + store.set('hips', measurements.hipsCircumference * store.get('xScale')) + store.set('hipsFront', store.get('hips') * options.hipRatioFront) + let hipRatioSide = (1 - (options.hipRatioFront + options.hipRatioBack)) / 2 + store.set('hipsSide', store.get('hips') * hipRatioSide) + store.set('hipsBack', store.get('hips') * options.hipRatioBack) /* Ratio of parts at the legs*/ - store.set('leg', measurements.upperLegCircumference * store.get('xScaleLegs')); - store.set('legInset', store.get('leg') * options.legRatioInset); - let legRatioSide = 1 - options.legRatioInset - options.legRatioBack; - store.set('legSide', store.get('leg') * legRatioSide); - store.set('legBack', store.get('leg') * options.legRatioBack); + store.set('leg', measurements.upperLegCircumference * store.get('xScaleLegs')) + store.set('legInset', store.get('leg') * options.legRatioInset) + let legRatioSide = 1 - options.legRatioInset - options.legRatioBack + store.set('legSide', store.get('leg') * legRatioSide) + store.set('legBack', store.get('leg') * options.legRatioBack) /* Gusset */ - store.set('gusset', measurements.hipsCircumference * options.gussetRatio); - store.set('gussetInsetRatio', options.gussetInsetRatio); + store.set('gusset', measurements.hipsCircumference * options.gussetRatio) + store.set('gussetInsetRatio', options.gussetInsetRatio) /* Length helper */ - store.set('length', measurements.hipsToUpperLeg * store.get('yScale')); - store.set('riseLength', measurements.hipsToUpperLeg + store.get('rise')); - store.set('fullLength', store.get('riseLength') + store.get('legBonus') * store.get('yScale')); + store.set('length', measurements.hipsToUpperLeg * store.get('yScale')) + store.set('riseLength', measurements.hipsToUpperLeg + store.get('rise')) + store.set('fullLength', store.get('riseLength') + store.get('legBonus') * store.get('yScale')) /* Height ratio front/inset */ - store.set('heightInset', store.get('riseLength') * options.heightRatioInset + store.get('legBonus') * store.get('yScale')); - store.set('heightFront', store.get('riseLength') * (1 - options.heightRatioInset)); + store.set( + 'heightInset', + store.get('riseLength') * options.heightRatioInset + + store.get('legBonus') * store.get('yScale') + ) + store.set('heightFront', store.get('riseLength') * (1 - options.heightRatioInset)) /* Absolute amount to raise the back */ - store.set('init', true); + store.set('init', true) } } diff --git a/packages/bruce/src/inset.js b/packages/bruce/src/inset.js index e19dd6f52c5..c4bbdd3618b 100644 --- a/packages/bruce/src/inset.js +++ b/packages/bruce/src/inset.js @@ -1,48 +1,34 @@ -import init from "./init"; +import init from './init' export default function(part) { - let { - store, - sa, - Point, - points, - Path, - paths, - complete, - paperless, - macro - } = part.shorthand(); + let { store, sa, Point, points, Path, paths, complete, paperless, macro } = part.shorthand() // Initialize - init(part); + init(part) // height is 73.5% - points.topLeft = new Point(0, 0); - points.bottomLeft = points.topLeft.shift(-90, store.get("heightInset")); - points.bottomRight = new Point(store.get("legInset"), points.bottomLeft.y); - points.tip = new Point( - points.bottomRight.x * 1.111, - points.bottomRight.y - store.get("gusset") - ); + points.topLeft = new Point(0, 0) + points.bottomLeft = points.topLeft.shift(-90, store.get('heightInset')) + points.bottomRight = new Point(store.get('legInset'), points.bottomLeft.y) + points.tip = new Point(points.bottomRight.x * 1.111, points.bottomRight.y - store.get('gusset')) points.tip = points.bottomRight.shiftTowards( points.tip, - store.get("crotchSeamLength") - - store.get("gusset") * (1 - store.get("gussetInsetRatio")) - ); - points.tipCpTop = new Point(store.get("gusset") * 1.2, 0); + store.get('crotchSeamLength') - store.get('gusset') * (1 - store.get('gussetInsetRatio')) + ) + points.tipCpTop = new Point(store.get('gusset') * 1.2, 0) points.tipCpBottom = points.tip.shift( points.bottomRight.angle(points.tip) + 90, - store.get("gusset") * 1.5 - ); + store.get('gusset') * 1.5 + ) // Store cuve length store.set( - "curve", + 'curve', new Path() .move(points.tip) .curve(points.tipCpBottom, points.tipCpTop, points.topLeft) .length() - ); + ) // Path paths.seam = new Path() @@ -52,46 +38,46 @@ export default function(part) { .line(points.tip) .curve(points.tipCpBottom, points.tipCpTop, points.topLeft) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') // Complete pattern? if (complete) { - if (sa) paths.sa = paths.seam.offset(sa).attr("class", "fabric sa"); - points.title = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5); - macro("title", { + if (sa) paths.sa = paths.seam.offset(sa).attr('class', 'fabric sa') + points.title = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5) + macro('title', { at: points.title.shift(-90, 15), nr: 4, - title: "inset" - }); - macro("grainline", { + title: 'inset' + }) + macro('grainline', { from: points.bottomLeft.shift(0, 15), to: points.topLeft.shift(0, 15) - }); + }) } // Paperless? if (paperless) { - macro("vd", { + macro('vd', { from: points.bottomLeft, to: points.topLeft, x: points.topLeft.x - 15 - sa - }); - macro("vd", { + }) + macro('vd', { from: points.bottomRight, to: points.tip, x: points.tip.x + 15 + sa - }); - macro("hd", { + }) + macro('hd', { from: points.bottomLeft, to: points.bottomRight, y: points.bottomRight.y + 15 + sa - }); - macro("hd", { + }) + macro('hd', { from: points.bottomLeft, to: points.tip, y: points.bottomRight.y + 30 + sa - }); + }) } - return part; + return part } diff --git a/packages/bruce/src/side.js b/packages/bruce/src/side.js index e0d98e76187..5784b8b80cb 100644 --- a/packages/bruce/src/side.js +++ b/packages/bruce/src/side.js @@ -1,4 +1,4 @@ -import init from "./init"; +import init from './init' export default function(part) { let { @@ -12,36 +12,36 @@ export default function(part) { paperless, macro, utils - } = part.shorthand(); + } = part.shorthand() // Initialize - init(part); + init(part) // Top left - points.zero = new Point(0, 0); - points.topLeft = points.zero.shift(90, store.get("rise")); + points.zero = new Point(0, 0) + points.topLeft = points.zero.shift(90, store.get('rise')) // Top right - points.topRight = new Point(store.get("hipsSide"), points.topLeft.y); + points.topRight = new Point(store.get('hipsSide'), points.topLeft.y) // Bottom right - points.bottomRight = points.topRight.shift(-90, store.get("fullLength")); + points.bottomRight = points.topRight.shift(-90, store.get('fullLength')) // Find bottom left let isect = utils.circlesIntersect( points.bottomRight, - store.get("legSide"), + store.get('legSide'), points.topLeft, - store.get("backSeamLength") - ); - points.bottomLeft = isect[0]; + store.get('backSeamLength') + ) + points.bottomLeft = isect[0] // Store side seam length - store.set("sideSeamLength", points.topRight.dist(points.bottomRight)); + store.set('sideSeamLength', points.topRight.dist(points.bottomRight)) // Handle back rise - points.topLeft = points.topLeft.shift(90, store.get("sideRise")); - points.topRight = points.topRight.shift(90, store.get("frontRise")); + points.topLeft = points.topLeft.shift(90, store.get('sideRise')) + points.topRight = points.topRight.shift(90, store.get('frontRise')) // Path paths.seam = new Path() @@ -51,51 +51,51 @@ export default function(part) { .line(points.bottomLeft) .line(points.topLeft) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') // Anchor point for sampling - points.anchor = points.topLeft; + points.anchor = points.topLeft // Complete pattern? if (complete) { - points.title = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5); - macro("title", { + points.title = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5) + macro('title', { at: points.title.shift(90, 30), nr: 3, - title: "side" - }); + title: 'side' + }) if (sa) { - paths.sa = paths.seam.offset(sa * -1).attr("class", "fabric sa"); + paths.sa = paths.seam.offset(sa * -1).attr('class', 'fabric sa') } - macro("grainline", { + macro('grainline', { from: new Point(points.bottomRight.x / 2, points.bottomRight.y), to: new Point(points.bottomRight.x / 2, points.topRight.y) - }); + }) } // Paperless? if (paperless) { - macro("vd", { + macro('vd', { from: points.bottomLeft, to: points.topLeft, x: points.topLeft.x - 15 - sa - }); - macro("vd", { + }) + macro('vd', { from: points.bottomRight, to: points.topRight, x: points.topRight.x + 15 + sa - }); - macro("hd", { + }) + macro('hd', { from: points.topLeft, to: points.topRight, y: points.topLeft.y - 15 - sa - }); - macro("hd", { + }) + macro('hd', { from: points.bottomLeft, to: points.bottomRight, y: points.bottomLeft.y + 15 + sa - }); + }) } - return part; + return part } diff --git a/packages/carlita/example/src/App.js b/packages/carlita/example/src/App.js index e7936330e5d..115cdf683af 100644 --- a/packages/carlita/example/src/App.js +++ b/packages/carlita/example/src/App.js @@ -1,22 +1,15 @@ -import React from "react"; -import freesewing from "@freesewing/core"; -import Workbench from "@freesewing/components/Workbench"; -import "typeface-roboto-condensed"; -import "@freesewing/css-theme"; +import React from 'react' +import freesewing from '@freesewing/core' +import Workbench from '@freesewing/components/Workbench' +import 'typeface-roboto-condensed' +import '@freesewing/css-theme' -import Pattern from "pattern"; +import Pattern from 'pattern' const App = props => { - let instance = new Pattern(); - let config = instance.config; - return ( - - ); -}; + let instance = new Pattern() + let config = instance.config + return +} -export default App; +export default App diff --git a/packages/carlita/example/src/index.js b/packages/carlita/example/src/index.js index 7900787a4d2..9dd7ba788d4 100644 --- a/packages/carlita/example/src/index.js +++ b/packages/carlita/example/src/index.js @@ -1,11 +1,11 @@ -import React from "react"; -import ReactDOM from "react-dom"; -import App from "./App"; -import * as serviceWorker from "./serviceWorker"; +import React from 'react' +import ReactDOM from 'react-dom' +import App from './App' +import * as serviceWorker from './serviceWorker' -ReactDOM.render(, document.getElementById("root")); +ReactDOM.render(, document.getElementById('root')) // If you want your app to work offline and load faster, you can change // unregister() to register() below. Note this comes with some pitfalls. // Learn more about service workers: http://bit.ly/CRA-PWA -serviceWorker.unregister(); +serviceWorker.unregister() diff --git a/packages/carlita/example/src/serviceWorker.js b/packages/carlita/example/src/serviceWorker.js index 68fda5a0eb6..44e1b1b2f8c 100644 --- a/packages/carlita/example/src/serviceWorker.js +++ b/packages/carlita/example/src/serviceWorker.js @@ -9,46 +9,44 @@ // This link also includes instructions on opting out of this behavior. const isLocalhost = Boolean( - window.location.hostname === "localhost" || + window.location.hostname === 'localhost' || // [::1] is the IPv6 localhost address. - window.location.hostname === "[::1]" || + window.location.hostname === '[::1]' || // 127.0.0.1/8 is considered localhost for IPv4. - window.location.hostname.match( - /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ - ) -); + window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/) +) export function register(config) { - if (process.env.NODE_ENV === "production" && "serviceWorker" in navigator) { + if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) { // The URL constructor is available in all browsers that support SW. - const publicUrl = new URL(process.env.PUBLIC_URL, window.location); + const publicUrl = new URL(process.env.PUBLIC_URL, window.location) if (publicUrl.origin !== window.location.origin) { // Our service worker won't work if PUBLIC_URL is on a different origin // from what our page is served on. This might happen if a CDN is used to // serve assets; see https://github.com/facebook/create-react-app/issues/2374 - return; + return } - window.addEventListener("load", () => { - const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; + window.addEventListener('load', () => { + const swUrl = `${process.env.PUBLIC_URL}/service-worker.js` if (isLocalhost) { // This is running on localhost. Let's check if a service worker still exists or not. - checkValidServiceWorker(swUrl, config); + checkValidServiceWorker(swUrl, config) // Add some additional logging to localhost, pointing developers to the // service worker/PWA documentation. navigator.serviceWorker.ready.then(() => { console.log( - "This web app is being served cache-first by a service " + - "worker. To learn more, visit https://goo.gl/SC7cgQ" - ); - }); + 'This web app is being served cache-first by a service ' + + 'worker. To learn more, visit https://goo.gl/SC7cgQ' + ) + }) } else { // Is not local host. Just register service worker - registerValidSW(swUrl, config); + registerValidSW(swUrl, config) } - }); + }) } } @@ -57,38 +55,38 @@ function registerValidSW(swUrl, config) { .register(swUrl) .then(registration => { registration.onupdatefound = () => { - const installingWorker = registration.installing; + const installingWorker = registration.installing installingWorker.onstatechange = () => { - if (installingWorker.state === "installed") { + if (installingWorker.state === 'installed') { if (navigator.serviceWorker.controller) { // At this point, the old content will have been purged and // the fresh content will have been added to the cache. // It's the perfect time to display a "New content is // available; please refresh." message in your web app. - console.log("New content is available; please refresh."); + console.log('New content is available; please refresh.') // Execute callback if (config.onUpdate) { - config.onUpdate(registration); + config.onUpdate(registration) } } else { // At this point, everything has been precached. // It's the perfect time to display a // "Content is cached for offline use." message. - console.log("Content is cached for offline use."); + console.log('Content is cached for offline use.') // Execute callback if (config.onSuccess) { - config.onSuccess(registration); + config.onSuccess(registration) } } } - }; - }; + } + } }) .catch(error => { - console.error("Error during service worker registration:", error); - }); + console.error('Error during service worker registration:', error) + }) } function checkValidServiceWorker(swUrl, config) { @@ -98,30 +96,28 @@ function checkValidServiceWorker(swUrl, config) { // Ensure service worker exists, and that we really are getting a JS file. if ( response.status === 404 || - response.headers.get("content-type").indexOf("javascript") === -1 + response.headers.get('content-type').indexOf('javascript') === -1 ) { // No service worker found. Probably a different app. Reload the page. navigator.serviceWorker.ready.then(registration => { registration.unregister().then(() => { - window.location.reload(); - }); - }); + window.location.reload() + }) + }) } else { // Service worker found. Proceed as normal. - registerValidSW(swUrl, config); + registerValidSW(swUrl, config) } }) .catch(() => { - console.log( - "No internet connection found. App is running in offline mode." - ); - }); + console.log('No internet connection found. App is running in offline mode.') + }) } export function unregister() { - if ("serviceWorker" in navigator) { + if ('serviceWorker' in navigator) { navigator.serviceWorker.ready.then(registration => { - registration.unregister(); - }); + registration.unregister() + }) } } diff --git a/packages/carlita/src/front.js b/packages/carlita/src/front.js index 5d97c4e4883..2e0fb367d22 100644 --- a/packages/carlita/src/front.js +++ b/packages/carlita/src/front.js @@ -14,7 +14,7 @@ export default function(part) { Point, paths, Path - } = part.shorthand(); + } = part.shorthand() /** * we're adding half of the proportionate amount of chest east for the bust span @@ -24,14 +24,11 @@ export default function(part) { measurements.bustSpan / 2 + ((measurements.bustSpan / measurements.bust) * options.chestEase) / 4, points.neck.y + measurements.highPointShoulderToBust - ); + ) // Draw the princess seam (ps) - points.psHem = new Point(points.bustPoint.x, points.hem.y); - points.bustPointCp1 = points.bustPoint.shift( - 90, - points.armholePitch.dy(points.bustPoint) / 2 - ); + points.psHem = new Point(points.bustPoint.x, points.hem.y) + points.bustPointCp1 = points.bustPoint.shift(90, points.armholePitch.dy(points.bustPoint) / 2) // Paths paths.seam = new Path() @@ -46,15 +43,11 @@ export default function(part) { .line(points.hemEdge) .line(points.psHem) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') paths.chestPiece = paths.chestPiece .curve(points.armholeCp2, points.armholeHollowCp1, points.armholeHollow) - .curve( - points.armholeHollowCp2, - points.armholePitchCp1, - points.armholePitch - ); + .curve(points.armholeHollowCp2, points.armholePitchCp1, points.armholePitch) paths.chestPocket = new Path() .move(points.chestPocketTopLeft) @@ -63,7 +56,7 @@ export default function(part) { .line(points.chestPocketTopRight) .line(points.chestPocketTopLeft) .close() - .attr("class", "fabric help"); + .attr('class', 'fabric help') ///////////////////////////////////////// @@ -74,146 +67,135 @@ export default function(part) { */ let side = [ - "bustPoint", - "bustPointCp1", - "psHem", - "hem", - "seat", - "seatCp2", - "waistCp1", - "waist", - "waistCp2", - "armhole", - "armholeCp2", - "armholeHollowCp1", - "armholeHollow", - "armholeHollowCp2", - "armholePitchCp1", - "armholePitch" - ]; + 'bustPoint', + 'bustPointCp1', + 'psHem', + 'hem', + 'seat', + 'seatCp2', + 'waistCp1', + 'waist', + 'waistCp2', + 'armhole', + 'armholeCp2', + 'armholeHollowCp1', + 'armholeHollow', + 'armholeHollowCp2', + 'armholePitchCp1', + 'armholePitch' + ] // Store these, we'll use them in the side part - store.set("side", side); + store.set('side', side) // How much (horizontal) room do we need to create? - let extra = measurements.bust - measurements.highBust; + let extra = measurements.bust - measurements.highBust /* Cut from armholePitch point to bustPoint and rotate * entire side panel until we have created enough room */ - let added = 0; - let delta = 10; - let count = 1; + let added = 0 + let delta = 10 + let count = 1 while (Math.abs(delta) > 0.5 && count < 50) { - for (let i of side) - points[i + "Rot1"] = points[i].rotate(delta / 5, points.armholePitch); - added = points.bustPoint.dx(points.bustPointRot1); - delta = extra - added; - count++; + for (let i of side) points[i + 'Rot1'] = points[i].rotate(delta / 5, points.armholePitch) + added = points.bustPoint.dx(points.bustPointRot1) + delta = extra - added + count++ } /* Now cut from armhole to rotated bustpoint and rotate * the lower part of the site until it's aligned vertically again * We'll also rotate the top point, thus closing the bust dart */ - let angle = -1 * (points.bustPointRot1.angle(points.psHemRot1) - 270); - for (let i of side) - points[i + "Rot2"] = points[i + "Rot1"].rotate(angle, points.bustPointRot1); + let angle = -1 * (points.bustPointRot1.angle(points.psHemRot1) - 270) + for (let i of side) points[i + 'Rot2'] = points[i + 'Rot1'].rotate(angle, points.bustPointRot1) // Also rotate original bustPoint and bustPointCp1 - points.bustPointRot2 = points.bustPoint.rotate(angle, points.bustPointRot1); - points.bustPointCp1Rot2 = points.bustPointCp1.rotate( - angle, - points.bustPointRot1 - ); + points.bustPointRot2 = points.bustPoint.rotate(angle, points.bustPointRot1) + points.bustPointCp1Rot2 = points.bustPointCp1.rotate(angle, points.bustPointRot1) // Now construct the new curve points.bustPointCp2 = points.bustPointCp1Rot2 .rotate(180, points.bustPointRot2) - .shiftFractionTowards(points.bustPointRot2, 0.5); - points.psWaist = new Point(points.psHemRot2.x, points.waistRot2.y); + .shiftFractionTowards(points.bustPointRot2, 0.5) + points.psWaist = new Point(points.psHemRot2.x, points.waistRot2.y) points.psWaistCp1 = points.psWaist.shift( 90, points.bustPointRot2.dy(points.psWaist) * options.contour - ); + ) // Adapt lenght of the front part let frontCurve = new Path() .move(points.armholePitch) ._curve(points.bustPointCp1, points.bustPoint) .line(new Point(points.psHem.x, points.waist.y)) - .length(); + .length() let sideCurve = new Path() .move(points.armholePitchRot2) ._curve(points.bustPointCp1Rot2, points.bustPointRot2) .curve(points.bustPointCp2, points.psWaistCp1, points.psWaist) - .length(); - let longer = sideCurve - frontCurve; + .length() + let longer = sideCurve - frontCurve let belowBust = [ - "button1Left", - "button2Left", - "button3Left", - "button1Right", - "button2Right", - "button3Right", - "rollLineStart", - "hemEdge", - "flbHem", - "psHem", - "pocketTopLeft", - "pocketTopRight", - "pocketBottomLeft", - "pocketBottomRight", - "pocketRoundLeftStart", - "pocketRoundLeftCp1", - "pocketRoundLeftCp2", - "pocketRoundLeftEnd", - "pocketRoundRightStart", - "pocketRoundRightCp1", - "pocketRoundRightCp2", - "pocketRoundRightEnd", - "pocketFlapTopLeft", - "pocketFlapTopRight", - "pocketFlapBottomLeft", - "pocketFlapBottomRight", - "pocketFlapRoundLeftStart", - "pocketFlapRoundLeftCp1", - "pocketFlapRoundLeftCp2", - "pocketFlapRoundLeftEnd", - "pocketFlapRoundRightStart", - "pocketFlapRoundRightCp1", - "pocketFlapRoundRightCp2", - "pocketFlapRoundRightEnd", - "innerPocketTopLeft", - "innerPocketTopRight", - "innerPocketBottomLeft", - "innerPocketBottomRight", - "chestPocketTopLeft", - "chestPocketTopRight", - "chestPocketBottomLeft", - "chestPocketBottomRight" - ]; + 'button1Left', + 'button2Left', + 'button3Left', + 'button1Right', + 'button2Right', + 'button3Right', + 'rollLineStart', + 'hemEdge', + 'flbHem', + 'psHem', + 'pocketTopLeft', + 'pocketTopRight', + 'pocketBottomLeft', + 'pocketBottomRight', + 'pocketRoundLeftStart', + 'pocketRoundLeftCp1', + 'pocketRoundLeftCp2', + 'pocketRoundLeftEnd', + 'pocketRoundRightStart', + 'pocketRoundRightCp1', + 'pocketRoundRightCp2', + 'pocketRoundRightEnd', + 'pocketFlapTopLeft', + 'pocketFlapTopRight', + 'pocketFlapBottomLeft', + 'pocketFlapBottomRight', + 'pocketFlapRoundLeftStart', + 'pocketFlapRoundLeftCp1', + 'pocketFlapRoundLeftCp2', + 'pocketFlapRoundLeftEnd', + 'pocketFlapRoundRightStart', + 'pocketFlapRoundRightCp1', + 'pocketFlapRoundRightCp2', + 'pocketFlapRoundRightEnd', + 'innerPocketTopLeft', + 'innerPocketTopRight', + 'innerPocketBottomLeft', + 'innerPocketBottomRight', + 'chestPocketTopLeft', + 'chestPocketTopRight', + 'chestPocketBottomLeft', + 'chestPocketBottomRight' + ] for (let i of belowBust) { // Round points depend on options, so add a check - if (typeof points[i] !== "undefined") { - points[i] = points[i].shift(-90, longer); - } else console.log(i); + if (typeof points[i] !== 'undefined') { + points[i] = points[i].shift(-90, longer) + } else console.log(i) } // Move the map/chest pocket into the princess seam points.chestPocketBottomLeft = new Point( points.bustPoint.x, points.button2Right.y - points.button3Right.dy(points.button2Right) / 10 - ); - points.chestPocketTopLeft = points.chestPocketBottomLeft.shift( - 90, - store.get("chestPocketHeight") - ); - points.chestPocketTopRight = points.chestPocketTopLeft.shift( - 0, - store.get("chestPocketWidth") - ); + ) + points.chestPocketTopLeft = points.chestPocketBottomLeft.shift(90, store.get('chestPocketHeight')) + points.chestPocketTopRight = points.chestPocketTopLeft.shift(0, store.get('chestPocketWidth')) points.chestPocketBottomRight = points.chestPocketBottomLeft.shift( 0, - store.get("chestPocketWidth") - ); + store.get('chestPocketWidth') + ) // Uncomment these to better understand the FBA /* @@ -256,8 +238,8 @@ export default function(part) { */ // Clean up - for (let i in paths) delete paths[i]; - for (let i in snippets) delete snippets[i]; + for (let i in paths) delete paths[i] + for (let i in snippets) delete snippets[i] // Paths paths.saBase = new Path() @@ -270,22 +252,22 @@ export default function(part) { .line(points.collarTip) ._curve(points.lapelStraightEndCp1, points.lapelStraightEnd) .line(points.hemEdge) - .line(points.flbHem); + .line(points.flbHem) paths.seam = paths.saBase .clone() .line(points.psHem) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') paths.rollLine = new Path() .move(points.rollLineStart) .line(points.rollLineEnd) - .attr("class", "lashed"); + .attr('class', 'lashed') paths.flb = new Path() .move(points.flbHem) .line(points.flbTop) - .attr("class", "lining lashed"); + .attr('class', 'lining lashed') paths.pocket = new Path() .move( @@ -297,15 +279,11 @@ export default function(part) { ) ) .line(points.pocketTopLeft) - .attr("class", "fabric help"); + .attr('class', 'fabric help') if (options.pocketRadius > 0) { paths.pocket = paths.pocket .line(points.pocketRoundLeftStart) - .curve( - points.pocketRoundLeftCp1, - points.pocketRoundLeftCp2, - points.pocketRoundLeftEnd - ); + .curve(points.pocketRoundLeftCp1, points.pocketRoundLeftCp2, points.pocketRoundLeftEnd) } else { paths.pocket = paths.pocket .line(points.pocketBottomLeft) @@ -316,7 +294,7 @@ export default function(part) { points.bustPoint, points.psHem ) - ); + ) } paths.pocketFlap = new Path() @@ -329,7 +307,7 @@ export default function(part) { ) ) .line(points.pocketFlapTopLeft) - .attr("class", "fabric help"); + .attr('class', 'fabric help') if (options.pocketFlapRadius > 0) { paths.pocketFlap = paths.pocketFlap .line(points.pocketFlapRoundLeftStart) @@ -337,7 +315,7 @@ export default function(part) { points.pocketFlapRoundLeftCp1, points.pocketFlapRoundLeftCp2, points.pocketFlapRoundLeftEnd - ); + ) } else { paths.pocketFlap = paths.pocketFlap .line(points.pocketFlapBottomLeft) @@ -348,7 +326,7 @@ export default function(part) { points.bustPoint, points.psHem ) - ); + ) } paths.chestPocket = new Path() @@ -358,7 +336,7 @@ export default function(part) { .line(points.chestPocketTopRight) .line(points.chestPocketTopLeft) .close() - .attr("class", "fabric help"); + .attr('class', 'fabric help') paths.innerPocket = new Path() .move(points.innerPocketTopLeft) @@ -367,180 +345,156 @@ export default function(part) { .line(points.innerPocketTopRight) .line(points.innerPocketTopLeft) .close() - .attr("class", "fabric help"); + .attr('class', 'fabric help') if (complete) { - snippets.button1Left = new Snippet("button", points.button1Left).attr( - "data-scale", - 2 - ); - snippets.button1Right = new Snippet("button", points.button1Right).attr( - "data-scale", - 2 - ); - snippets.button2Left = new Snippet("button", points.button2Left).attr( - "data-scale", - 2 - ); - snippets.button2Right = new Snippet("button", points.button2Right).attr( - "data-scale", - 2 - ); - snippets.button3Left = new Snippet("button", points.button3Left).attr( - "data-scale", - 2 - ); - snippets.button3Right = new Snippet("button", points.button3Right).attr( - "data-scale", - 2 - ); - macro("sprinkle", { - snippet: "notch", - on: [ - "cfNeck", - "rollLineStart", - "bustPoint", - "chestPocketTopLeft", - "chestPocketBottomLeft" - ] - }); - points.logo = points.cfSeat.shiftFractionTowards(points.cfHem, 0.5); - snippets.logo = new Snippet("logo", points.logo); - macro("title", { at: points.title, nr: "1a", title: "front" }); - macro("grainline", { from: points.cfHem, to: points.cfNeck }); + snippets.button1Left = new Snippet('button', points.button1Left).attr('data-scale', 2) + snippets.button1Right = new Snippet('button', points.button1Right).attr('data-scale', 2) + snippets.button2Left = new Snippet('button', points.button2Left).attr('data-scale', 2) + snippets.button2Right = new Snippet('button', points.button2Right).attr('data-scale', 2) + snippets.button3Left = new Snippet('button', points.button3Left).attr('data-scale', 2) + snippets.button3Right = new Snippet('button', points.button3Right).attr('data-scale', 2) + macro('sprinkle', { + snippet: 'notch', + on: ['cfNeck', 'rollLineStart', 'bustPoint', 'chestPocketTopLeft', 'chestPocketBottomLeft'] + }) + points.logo = points.cfSeat.shiftFractionTowards(points.cfHem, 0.5) + snippets.logo = new Snippet('logo', points.logo) + macro('title', { at: points.title, nr: '1a', title: 'front' }) + macro('grainline', { from: points.cfHem, to: points.cfNeck }) if (sa) { - let hemBase = new Path().move(points.flbHem).line(points.psHem); + let hemBase = new Path().move(points.flbHem).line(points.psHem) paths.sa = paths.saBase .offset(sa) .join(hemBase.offset(3 * sa)) .line(points.psHem.shift(-90, 3 * sa).shift(0, sa)) .close() - .attr("class", "fabric sa"); + .attr('class', 'fabric sa') } if (paperless) { - macro("ld", { + macro('ld', { from: points.hemEdge, to: points.flbHem, d: 15 - }); - macro("hd", { + }) + macro('hd', { from: points.hemEdge, to: points.psHem, y: points.psHem.y + 15 + 3 * sa - }); - macro("hd", { + }) + macro('hd', { from: points.rollLineStart, to: points.pocketTopLeft, y: points.pocketFlapBottomLeft.y - }); - macro("vd", { + }) + macro('vd', { from: points.pocketFlapTopLeft, to: points.button3Right, x: points.bustPoint.x + sa + 15 - }); - macro("vd", { + }) + macro('vd', { from: points.pocketTopLeft, to: points.button3Right, x: points.bustPoint.x + sa + 30 - }); - macro("vd", { + }) + macro('vd', { from: points.chestPocketBottomLeft, to: points.button3Right, x: points.bustPoint.x - 15 - }); - macro("hd", { + }) + macro('hd', { from: points.rollLineStart, to: points.chestPocketBottomLeft, y: points.chestPocketBottomLeft.y + 15 - }); - macro("hd", { + }) + macro('hd', { from: points.rollLineStart, to: points.button3Left, y: points.button3Left.y + 15 - }); - macro("hd", { + }) + macro('hd', { from: points.button3Left, to: points.button3Right, y: points.button3Left.y + 15 - }); - macro("vd", { + }) + macro('vd', { from: points.psHem, to: points.bustPoint, x: points.bustPoint.x + sa + 45 - }); - macro("vd", { + }) + macro('vd', { from: points.psHem, to: points.armholePitch, x: points.armholePitch.x + sa + 15 - }); - macro("vd", { + }) + macro('vd', { from: points.armholePitch, to: points.shoulder, x: points.shoulder.x + sa + 15 - }); - macro("vd", { + }) + macro('vd', { from: points.armholePitch, to: points.neck, x: points.shoulder.x + sa + 30 - }); - macro("vd", { + }) + macro('vd', { from: points.rollLineStart, to: points.collarTip, x: points.rollLineStart.x - sa - 15 - }); - macro("vd", { + }) + macro('vd', { from: points.button2Left, to: points.rollLineStart, x: points.rollLineStart.x - sa - 15 - }); - macro("vd", { + }) + macro('vd', { from: points.button1Left, to: points.button2Left, x: points.rollLineStart.x - sa - 15 - }); - macro("vd", { + }) + macro('vd', { from: points.hemEdge, to: points.collarTip, x: points.rollLineStart.x - sa - 30 - }); - macro("hd", { + }) + macro('hd', { from: points.lapelStraightEnd, to: points.collarTip, y: points.collarTip.y - sa - 15 - }); - macro("hd", { + }) + macro('hd', { from: points.lapelStraightEnd, to: points.cfNeck, y: points.collarTip.y - sa - 30 - }); - macro("hd", { + }) + macro('hd', { from: points.lapelStraightEnd, to: points.rollLineEnd, y: points.collarTip.y - sa - 45 - }); - macro("hd", { + }) + macro('hd', { from: points.lapelStraightEnd, to: points.neck, y: points.neck.y - sa - 15 - }); - macro("hd", { + }) + macro('hd', { from: points.lapelStraightEnd, to: points.armholePitch, y: points.neck.y - sa - 30 - }); - macro("hd", { + }) + macro('hd', { from: points.lapelStraightEnd, to: points.shoulder, y: points.neck.y - sa - 45 - }); - macro("hd", { + }) + macro('hd', { from: points.lapelStraightEnd, to: points.armhole, y: points.neck.y - sa - 60 - }); + }) } } - return part; + return part } diff --git a/packages/carlita/src/index.js b/packages/carlita/src/index.js index 5284b6e24da..efbefe2e71b 100644 --- a/packages/carlita/src/index.js +++ b/packages/carlita/src/index.js @@ -1,56 +1,56 @@ -import freesewing from "@freesewing/core"; -import plugins from "@freesewing/plugin-bundle"; -import buttons from "@freesewing/plugin-buttons"; -import bust from "@freesewing/plugin-bust"; -import Bent from "@freesewing/bent"; -import Carlton from "@freesewing/carlton"; -import config from "../config"; +import freesewing from '@freesewing/core' +import plugins from '@freesewing/plugin-bundle' +import buttons from '@freesewing/plugin-buttons' +import bust from '@freesewing/plugin-bust' +import Bent from '@freesewing/bent' +import Carlton from '@freesewing/carlton' +import config from '../config' // Parts -import draftFront from "./front"; -import draftSide from "./side"; +import draftFront from './front' +import draftSide from './side' // Create new design -const Pattern = new freesewing.Design(config, [plugins, buttons, bust]); +const Pattern = new freesewing.Design(config, [plugins, buttons, bust]) -let fromBent = ["Base", "Front", "Back", "Sleeve", "TopSleeve", "UnderSleeve"]; +let fromBent = ['Base', 'Front', 'Back', 'Sleeve', 'TopSleeve', 'UnderSleeve'] // Attach draft methods from Bent to prototype for (let m of fromBent) { - Pattern.prototype["draftBent" + m] = function(part) { - return new Bent(this.settings)["draft" + m](part); - }; + Pattern.prototype['draftBent' + m] = function(part) { + return new Bent(this.settings)['draft' + m](part) + } } // Attach draft methods from Carlton to prototype for (let m of [ - "draftBack", - "draftTail", - "draftTopSleeve", - "draftUnderSleeve", - "draftBelt", - "draftCollarStand", - "draftCollar", - "draftCuffFacing", - "draftPocket", - "draftPocketFlap", - "draftPocketLining", - "draftChestPocketWelt", - "draftChestPocketBag", - "draftInnerPocketWelt", - "draftInnerPocketBag", - "draftInnerPocketTab" + 'draftBack', + 'draftTail', + 'draftTopSleeve', + 'draftUnderSleeve', + 'draftBelt', + 'draftCollarStand', + 'draftCollar', + 'draftCuffFacing', + 'draftPocket', + 'draftPocketFlap', + 'draftPocketLining', + 'draftChestPocketWelt', + 'draftChestPocketBag', + 'draftInnerPocketWelt', + 'draftInnerPocketBag', + 'draftInnerPocketTab' ]) { Pattern.prototype[m] = function(part) { - return new Carlton(this.settings)[m](part); - }; + return new Carlton(this.settings)[m](part) + } } Pattern.prototype.draftCarltonFront = function(part) { - return new Carlton(this.settings).draftFront(part); -}; + return new Carlton(this.settings).draftFront(part) +} // Attach own draft methods to prototype -Pattern.prototype.draftFront = draftFront; -Pattern.prototype.draftSide = draftSide; +Pattern.prototype.draftFront = draftFront +Pattern.prototype.draftSide = draftSide -export default Pattern; +export default Pattern diff --git a/packages/carlita/src/side.js b/packages/carlita/src/side.js index f4bf9807c99..6471d4744a5 100644 --- a/packages/carlita/src/side.js +++ b/packages/carlita/src/side.js @@ -11,14 +11,14 @@ export default function(part) { Point, paths, Path - } = part.shorthand(); + } = part.shorthand() // Give points their original names - for (let i of store.get("side")) points[i] = points[i + "Rot2"].clone(); + for (let i of store.get('side')) points[i] = points[i + 'Rot2'].clone() // Clean up - for (let i in paths) delete paths[i]; - for (let i in snippets) delete snippets[i]; + for (let i in paths) delete paths[i] + for (let i in snippets) delete snippets[i] paths.saBase = new Path() .move(points.hem) @@ -29,34 +29,31 @@ export default function(part) { .curve(points.armholeHollowCp2, points.armholePitchCp1, points.armholePitch) ._curve(points.bustPointCp1, points.bustPoint) .curve(points.bustPointCp2, points.psWaistCp1, points.psWaist) - .line(points.psHem); + .line(points.psHem) paths.seam = paths.saBase .clone() .line(points.hem) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') if (complete) { - points.title = points.bustPoint.shiftFractionTowards(points.waist, 0.5); - macro("title", { + points.title = points.bustPoint.shiftFractionTowards(points.waist, 0.5) + macro('title', { at: points.title, - nr: "1b", - title: "side" - }); + nr: '1b', + title: 'side' + }) - points.logo = points.psHem.shiftFractionTowards(points.seat, 0.5); - snippets.logo = new Snippet("logo", points.logo); + points.logo = points.psHem.shiftFractionTowards(points.seat, 0.5) + snippets.logo = new Snippet('logo', points.logo) - points.grainlineFrom = points.psHem.shiftFractionTowards(points.hem, 0.5); - points.grainlineTo = new Point( - points.grainlineFrom.x, - points.armholePitchCp1.y - ); - macro("grainline", { + points.grainlineFrom = points.psHem.shiftFractionTowards(points.hem, 0.5) + points.grainlineTo = new Point(points.grainlineFrom.x, points.armholePitchCp1.y) + macro('grainline', { from: points.grainlineFrom, to: points.grainlineTo - }); - snippets.bust = new Snippet("notch", points.bustPoint); + }) + snippets.bust = new Snippet('notch', points.bustPoint) if (sa) { paths.sa = paths.saBase @@ -64,66 +61,66 @@ export default function(part) { .line(points.psHem.shift(-90, 3 * sa).shift(180, sa)) .line(points.hem.shift(-90, 3 * sa).shift(0, sa)) .close() - .attr("class", "fabric sa"); + .attr('class', 'fabric sa') } if (paperless) { - macro("vd", { + macro('vd', { from: points.psHem, to: points.psWaist, x: points.psWaist.x - sa - 15 - }); - macro("vd", { + }) + macro('vd', { from: points.psHem, to: points.bustPoint, x: points.bustPoint.x - sa - 15 - }); - macro("vd", { + }) + macro('vd', { from: points.hem, to: points.seat, x: points.hem.x + sa + 15 - }); - macro("vd", { + }) + macro('vd', { from: points.hem, to: points.waist, x: points.hem.x + sa + 30 - }); - macro("vd", { + }) + macro('vd', { from: points.hem, to: points.armhole, x: points.hem.x + sa + 45 - }); - macro("vd", { + }) + macro('vd', { from: points.hem, to: points.armholePitch, x: points.hem.x + sa + 60 - }); - macro("hd", { + }) + macro('hd', { from: points.psWaist, to: points.waist - }); - macro("hd", { + }) + macro('hd', { from: points.bustPoint, to: points.waist, y: points.bustPoint.y - }); - macro("hd", { + }) + macro('hd', { from: points.bustPoint, to: points.armholePitch, y: points.armholePitch.y - sa - 15 - }); - macro("hd", { + }) + macro('hd', { from: points.bustPoint, to: points.armhole, y: points.armholePitch.y - sa - 30 - }); - macro("hd", { + }) + macro('hd', { from: points.psHem, to: points.hem, y: points.hem.y + 3 * sa + 15 - }); + }) } } - return part; + return part } diff --git a/packages/carlton/example/src/App.js b/packages/carlton/example/src/App.js index e7936330e5d..115cdf683af 100644 --- a/packages/carlton/example/src/App.js +++ b/packages/carlton/example/src/App.js @@ -1,22 +1,15 @@ -import React from "react"; -import freesewing from "@freesewing/core"; -import Workbench from "@freesewing/components/Workbench"; -import "typeface-roboto-condensed"; -import "@freesewing/css-theme"; +import React from 'react' +import freesewing from '@freesewing/core' +import Workbench from '@freesewing/components/Workbench' +import 'typeface-roboto-condensed' +import '@freesewing/css-theme' -import Pattern from "pattern"; +import Pattern from 'pattern' const App = props => { - let instance = new Pattern(); - let config = instance.config; - return ( - - ); -}; + let instance = new Pattern() + let config = instance.config + return +} -export default App; +export default App diff --git a/packages/carlton/example/src/index.js b/packages/carlton/example/src/index.js index 7900787a4d2..9dd7ba788d4 100644 --- a/packages/carlton/example/src/index.js +++ b/packages/carlton/example/src/index.js @@ -1,11 +1,11 @@ -import React from "react"; -import ReactDOM from "react-dom"; -import App from "./App"; -import * as serviceWorker from "./serviceWorker"; +import React from 'react' +import ReactDOM from 'react-dom' +import App from './App' +import * as serviceWorker from './serviceWorker' -ReactDOM.render(, document.getElementById("root")); +ReactDOM.render(, document.getElementById('root')) // If you want your app to work offline and load faster, you can change // unregister() to register() below. Note this comes with some pitfalls. // Learn more about service workers: http://bit.ly/CRA-PWA -serviceWorker.unregister(); +serviceWorker.unregister() diff --git a/packages/carlton/example/src/serviceWorker.js b/packages/carlton/example/src/serviceWorker.js index 68fda5a0eb6..44e1b1b2f8c 100644 --- a/packages/carlton/example/src/serviceWorker.js +++ b/packages/carlton/example/src/serviceWorker.js @@ -9,46 +9,44 @@ // This link also includes instructions on opting out of this behavior. const isLocalhost = Boolean( - window.location.hostname === "localhost" || + window.location.hostname === 'localhost' || // [::1] is the IPv6 localhost address. - window.location.hostname === "[::1]" || + window.location.hostname === '[::1]' || // 127.0.0.1/8 is considered localhost for IPv4. - window.location.hostname.match( - /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ - ) -); + window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/) +) export function register(config) { - if (process.env.NODE_ENV === "production" && "serviceWorker" in navigator) { + if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) { // The URL constructor is available in all browsers that support SW. - const publicUrl = new URL(process.env.PUBLIC_URL, window.location); + const publicUrl = new URL(process.env.PUBLIC_URL, window.location) if (publicUrl.origin !== window.location.origin) { // Our service worker won't work if PUBLIC_URL is on a different origin // from what our page is served on. This might happen if a CDN is used to // serve assets; see https://github.com/facebook/create-react-app/issues/2374 - return; + return } - window.addEventListener("load", () => { - const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; + window.addEventListener('load', () => { + const swUrl = `${process.env.PUBLIC_URL}/service-worker.js` if (isLocalhost) { // This is running on localhost. Let's check if a service worker still exists or not. - checkValidServiceWorker(swUrl, config); + checkValidServiceWorker(swUrl, config) // Add some additional logging to localhost, pointing developers to the // service worker/PWA documentation. navigator.serviceWorker.ready.then(() => { console.log( - "This web app is being served cache-first by a service " + - "worker. To learn more, visit https://goo.gl/SC7cgQ" - ); - }); + 'This web app is being served cache-first by a service ' + + 'worker. To learn more, visit https://goo.gl/SC7cgQ' + ) + }) } else { // Is not local host. Just register service worker - registerValidSW(swUrl, config); + registerValidSW(swUrl, config) } - }); + }) } } @@ -57,38 +55,38 @@ function registerValidSW(swUrl, config) { .register(swUrl) .then(registration => { registration.onupdatefound = () => { - const installingWorker = registration.installing; + const installingWorker = registration.installing installingWorker.onstatechange = () => { - if (installingWorker.state === "installed") { + if (installingWorker.state === 'installed') { if (navigator.serviceWorker.controller) { // At this point, the old content will have been purged and // the fresh content will have been added to the cache. // It's the perfect time to display a "New content is // available; please refresh." message in your web app. - console.log("New content is available; please refresh."); + console.log('New content is available; please refresh.') // Execute callback if (config.onUpdate) { - config.onUpdate(registration); + config.onUpdate(registration) } } else { // At this point, everything has been precached. // It's the perfect time to display a // "Content is cached for offline use." message. - console.log("Content is cached for offline use."); + console.log('Content is cached for offline use.') // Execute callback if (config.onSuccess) { - config.onSuccess(registration); + config.onSuccess(registration) } } } - }; - }; + } + } }) .catch(error => { - console.error("Error during service worker registration:", error); - }); + console.error('Error during service worker registration:', error) + }) } function checkValidServiceWorker(swUrl, config) { @@ -98,30 +96,28 @@ function checkValidServiceWorker(swUrl, config) { // Ensure service worker exists, and that we really are getting a JS file. if ( response.status === 404 || - response.headers.get("content-type").indexOf("javascript") === -1 + response.headers.get('content-type').indexOf('javascript') === -1 ) { // No service worker found. Probably a different app. Reload the page. navigator.serviceWorker.ready.then(registration => { registration.unregister().then(() => { - window.location.reload(); - }); - }); + window.location.reload() + }) + }) } else { // Service worker found. Proceed as normal. - registerValidSW(swUrl, config); + registerValidSW(swUrl, config) } }) .catch(() => { - console.log( - "No internet connection found. App is running in offline mode." - ); - }); + console.log('No internet connection found. App is running in offline mode.') + }) } export function unregister() { - if ("serviceWorker" in navigator) { + if ('serviceWorker' in navigator) { navigator.serviceWorker.ready.then(registration => { - registration.unregister(); - }); + registration.unregister() + }) } } diff --git a/packages/carlton/src/back.js b/packages/carlton/src/back.js index 2012e7a3471..266ae8b4069 100644 --- a/packages/carlton/src/back.js +++ b/packages/carlton/src/back.js @@ -1,57 +1,68 @@ -import { calculateRatios } from "./shared"; +import { calculateRatios } from './shared' export default function(part) { - let { paperless, sa, snippets, Snippet, store, complete, points, measurements, options, macro, Point, paths, Path } = part.shorthand(); + let { + paperless, + sa, + snippets, + Snippet, + store, + complete, + points, + measurements, + options, + macro, + Point, + paths, + Path + } = part.shorthand() - calculateRatios(part); + calculateRatios(part) // Belt width - let bw = measurements.centerBackNeckToWaist * options.beltWidth; - store.set("beltWidth", bw); + let bw = measurements.centerBackNeckToWaist * options.beltWidth + store.set('beltWidth', bw) // Box pleat (bp) - points.bpStart = new Point(0, points.armholePitch.y); + points.bpStart = new Point(0, points.armholePitch.y) points.bpTop = new Point( measurements.chestCircumference * options.backPleat * -1, points.armholePitch.y - ); - points.bpBottom = new Point( - points.bpTop.x, - points.cbWaist.y - bw/2 - ); - points.bpTriangleEdge = points.bpStart.shift(0, points.bpTop.dx(points.bpStart)*0.6); - points.bpTriangleTip = points.bpStart.shift(90, points.bpStart.dx(points.bpTriangleEdge)); + ) + points.bpBottom = new Point(points.bpTop.x, points.cbWaist.y - bw / 2) + points.bpTriangleEdge = points.bpStart.shift(0, points.bpTop.dx(points.bpStart) * 0.6) + points.bpTriangleTip = points.bpStart.shift(90, points.bpStart.dx(points.bpTriangleEdge)) // Waist shaping points.waist = new Point( - store.get("chest")/4 - store.get("waistReduction") / 8, + store.get('chest') / 4 - store.get('waistReduction') / 8, points.bpBottom.y - ); - points.waistCp2 = points.waist.shift(90, points.armhole.dy(points.waist)/3); - points.cbWaist = new Point(0, points.bpBottom.y); + ) + points.waistCp2 = points.waist.shift(90, points.armhole.dy(points.waist) / 3) + points.cbWaist = new Point(0, points.bpBottom.y) // Dart - points.dartCenter = points.cbWaist.shiftFractionTowards(points.waist, 0.4); - points.dartTip = points.dartCenter.shift(90, points.armhole.dy(points.dartCenter)*0.85); - points.dartRight = points.dartCenter.shift(0, store.get("waistReduction")/8); - points.dartLeft = points.dartRight.flipX(points.dartCenter); - points.dartLeftCp = points.dartLeft.shift(90, points.dartTip.dy(points.dartCenter)*0.6); - points.dartRightCp = points.dartLeftCp.flipX(points.dartCenter); + points.dartCenter = points.cbWaist.shiftFractionTowards(points.waist, 0.4) + points.dartTip = points.dartCenter.shift(90, points.armhole.dy(points.dartCenter) * 0.85) + points.dartRight = points.dartCenter.shift(0, store.get('waistReduction') / 8) + points.dartLeft = points.dartRight.flipX(points.dartCenter) + points.dartLeftCp = points.dartLeft.shift(90, points.dartTip.dy(points.dartCenter) * 0.6) + points.dartRightCp = points.dartLeftCp.flipX(points.dartCenter) - store.set("cbToDart", points.dartLeft.x); - store.set("dartToSide", points.dartRight.dx(points.waist)); + store.set('cbToDart', points.dartLeft.x) + store.set('dartToSide', points.dartRight.dx(points.waist)) // Back stay (bs) - points.bsCp1 = points.bpStart.shiftFractionTowards(points.armholePitch, 0.5); - points.bsCp2 = points.armhole.shiftFractionTowards(points.cbArmhole, 0.3); + points.bsCp1 = points.bpStart.shiftFractionTowards(points.armholePitch, 0.5) + points.bsCp2 = points.armhole.shiftFractionTowards(points.cbArmhole, 0.3) // Store collar length store.set( - "backCollarLength", + 'backCollarLength', new Path() .move(points.cbNeck) ._curve(points.neckCp2, points.neck) .length() - ); + ) // Clean up for (let i in paths) delete paths[i] @@ -79,154 +90,147 @@ export default function(part) { .join(paths.dart) .join(paths.seam2) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') paths.backStay = new Path() .move(points.bpStart) .curve(points.bsCp1, points.bsCp2, points.armhole) - .attr("class", "canvas lashed"); + .attr('class', 'canvas lashed') paths.triangle = new Path() .move(points.bpTriangleTip) .line(points.bpTriangleEdge) .line(points.bpStart) - .attr("class", "dashed"); + .attr('class', 'dashed') if (complete) { - macro("sprinkle", { - snippet: "notch", - on: [ - "armholePitch", - "bpTriangleTip" - ] - }); + macro('sprinkle', { + snippet: 'notch', + on: ['armholePitch', 'bpTriangleTip'] + }) - macro("grainline", { + macro('grainline', { from: points.cbWaist, to: points.bpStart - }); + }) - points.logo = new Point( - points.armhole.x * 0.7, - points.dartTip.y - ); - snippets.logo = new Snippet("logo", points.logo); + points.logo = new Point(points.armhole.x * 0.7, points.dartTip.y) + snippets.logo = new Snippet('logo', points.logo) if (sa) { - paths.sa = - paths.seam1 + paths.sa = paths.seam1 .line(points.waist) .offset(sa) .join(paths.seam2.offset(sa)) .close() .trim() .close() - .attr("class", "fabric sa"); + .attr('class', 'fabric sa') } if (paperless) { - macro("hd", { + macro('hd', { from: points.bpBottom, to: points.cbWaist, y: points.cbWaist.y + 15 + sa - }); - macro("hd", { + }) + macro('hd', { from: points.cbWaist, to: points.dartLeft, y: points.cbWaist.y + 15 + sa - }); - macro("hd", { + }) + macro('hd', { from: points.dartLeft, to: points.dartRight, y: points.cbWaist.y + 15 + sa - }); - macro("hd", { + }) + macro('hd', { from: points.dartRight, to: points.waist, y: points.cbWaist.y + 15 + sa - }); - macro("hd", { + }) + macro('hd', { from: points.cbWaist, to: points.waist, y: points.cbWaist.y + 30 + sa - }); - macro("hd", { + }) + macro('hd', { from: points.bpBottom, to: points.waist, y: points.cbWaist.y + 45 + sa - }); - macro("vd", { + }) + macro('vd', { from: points.waist, to: points.armhole, x: points.armhole.x + 15 + sa - }); - macro("vd", { + }) + macro('vd', { from: points.armhole, to: points.armholePitch, x: points.armhole.x + 15 + sa - }); - macro("vd", { + }) + macro('vd', { from: points.armhole, to: points.shoulder, x: points.armhole.x + 30 + sa - }); - macro("vd", { + }) + macro('vd', { from: points.waist, to: points.shoulder, x: points.armhole.x + 45 + sa - }); - macro("vd", { + }) + macro('vd', { from: points.dartRight, to: points.dartTip, x: points.dartRight.x + 15 - }); - macro("vd", { + }) + macro('vd', { from: points.bpBottom, to: points.bpTop, x: points.bpTop.x - 15 - sa - }); - macro("vd", { + }) + macro('vd', { from: points.bpTop, to: points.cbNeck, x: points.bpTop.x - 15 - sa - }); - macro("vd", { + }) + macro('vd', { from: points.bpBottom, to: points.neck, x: points.bpTop.x - 30 - sa - }); - macro("vd", { + }) + macro('vd', { from: points.bpStart, to: points.bpTriangleTip, x: points.bpTriangleEdge.x + 15 - }); - macro("hd", { + }) + macro('hd', { from: points.bpStart, to: points.bpTriangleEdge, y: points.bpTriangleEdge.y + 15 - }); - macro("hd", { + }) + macro('hd', { from: points.cbNeck, to: points.neck, y: points.neck.y - 15 - sa - }); - macro("hd", { + }) + macro('hd', { from: points.cbNeck, to: points.armholePitch, y: points.neck.y - 30 - sa - }); - macro("hd", { + }) + macro('hd', { from: points.cbNeck, to: points.shoulder, y: points.neck.y - 45 - sa - }); - macro("hd", { + }) + macro('hd', { from: points.cbNeck, to: points.armhole, y: points.neck.y - 60 - sa - }); + }) } } - return part; + return part } diff --git a/packages/carlton/src/belt.js b/packages/carlton/src/belt.js index 864ca8d68ff..07cf7c11b1b 100644 --- a/packages/carlton/src/belt.js +++ b/packages/carlton/src/belt.js @@ -1,30 +1,44 @@ export default function(part) { - let { paperless, sa, snippets, Snippet, store, complete, points, measurements, options, macro, Point, paths, Path } = part.shorthand(); + let { + paperless, + sa, + snippets, + Snippet, + store, + complete, + points, + measurements, + options, + macro, + Point, + paths, + Path + } = part.shorthand() - let length = 1.6 * (store.get("cbToDart") + store.get("dartToSide")); - let width = measurements.centerBackNeckToWaist * options.beltWidth; + let length = 1.6 * (store.get('cbToDart') + store.get('dartToSide')) + let width = measurements.centerBackNeckToWaist * options.beltWidth - points.topLeft = new Point(0, 0); - points.topRight = new Point(length, 0); - points.bottomLeft = new Point(0, width); - points.bottomRight = new Point(length, width); - points.button = new Point(width/2, width/2); - macro("round", { + points.topLeft = new Point(0, 0) + points.topRight = new Point(length, 0) + points.bottomLeft = new Point(0, width) + points.bottomRight = new Point(length, width) + points.button = new Point(width / 2, width / 2) + macro('round', { from: points.topRight, to: points.bottomLeft, via: points.topLeft, - prefix: "roundTop", - radius: width/4, + prefix: 'roundTop', + radius: width / 4, render: true - }); - macro("round", { + }) + macro('round', { from: points.topLeft, to: points.bottomRight, via: points.bottomLeft, - prefix: "roundBottom", - radius: width/4, + prefix: 'roundBottom', + radius: width / 4, render: true - }); + }) // Paths paths.seam = new Path() @@ -36,50 +50,44 @@ export default function(part) { .line(points.topRight) .line(points.roundTopStart) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') if (complete) { - snippets.button = new Snippet("button", points.button).attr("data-scale", 2); - points.title = new Point( - points.bottomRight.x/2, - points.bottomRight.y/2 - ); - macro("title", { + snippets.button = new Snippet('button', points.button).attr('data-scale', 2) + points.title = new Point(points.bottomRight.x / 2, points.bottomRight.y / 2) + macro('title', { at: points.title, nr: 6, - title: "belt" - }); - points.logo = new Point( - points.bottomRight.x * 0.75, - points.bottomRight.y * 0.65 - ); - snippets.logo = new Snippet("logo", points.logo); + title: 'belt' + }) + points.logo = new Point(points.bottomRight.x * 0.75, points.bottomRight.y * 0.65) + snippets.logo = new Snippet('logo', points.logo) - if (sa) paths.sa = paths.seam.offset(sa).attr("class", "fabric sa"); + if (sa) paths.sa = paths.seam.offset(sa).attr('class', 'fabric sa') if (paperless) { - macro("hd", { + macro('hd', { from: points.roundBottomStart, to: points.roundBottomEnd, y: points.roundBottomEnd.y + sa + 15 - }); - macro("hd", { + }) + macro('hd', { from: points.roundBottomStart, to: points.button, y: points.roundBottomEnd.y + sa + 30 - }); - macro("hd", { + }) + macro('hd', { from: points.roundBottomStart, to: points.bottomRight, y: points.roundBottomEnd.y + sa + 45 - }); - macro("vd", { + }) + macro('vd', { from: points.bottomRight, to: points.topRight, x: points.topRight.x + sa + 15 - }); + }) } } - return part; + return part } diff --git a/packages/carlton/src/chestpocketbag.js b/packages/carlton/src/chestpocketbag.js index c7fdc5a351e..3fb455c93b8 100644 --- a/packages/carlton/src/chestpocketbag.js +++ b/packages/carlton/src/chestpocketbag.js @@ -10,28 +10,19 @@ export default function(part) { Point, paths, Path - } = part.shorthand(); + } = part.shorthand() - points.topLeft = new Point(0, 0); + points.topLeft = new Point(0, 0) points.bottomRight = new Point( - store.get("chestPocketHeight"), - store.get("chestPocketBagDepth") / 2 - ); - points.bottomLeft = new Point(points.topLeft.x, points.bottomRight.y); - points.topRight = new Point(points.bottomRight.x, points.topLeft.y); - points.startLeft = points.topLeft.shiftFractionTowards( - points.bottomLeft, - 0.33 - ); - points.endLeft = points.topLeft.shiftFractionTowards(points.bottomLeft, 0.66); - points.startRight = points.topRight.shiftFractionTowards( - points.bottomRight, - 0.33 - ); - points.endRight = points.topRight.shiftFractionTowards( - points.bottomRight, - 0.66 - ); + store.get('chestPocketHeight'), + store.get('chestPocketBagDepth') / 2 + ) + points.bottomLeft = new Point(points.topLeft.x, points.bottomRight.y) + points.topRight = new Point(points.bottomRight.x, points.topLeft.y) + points.startLeft = points.topLeft.shiftFractionTowards(points.bottomLeft, 0.33) + points.endLeft = points.topLeft.shiftFractionTowards(points.bottomLeft, 0.66) + points.startRight = points.topRight.shiftFractionTowards(points.bottomRight, 0.33) + points.endRight = points.topRight.shiftFractionTowards(points.bottomRight, 0.66) paths.seam = new Path() .move(points.startRight) @@ -42,45 +33,45 @@ export default function(part) { .line(points.bottomLeft) .line(points.bottomRight) .line(points.endRight) - .attr("class", "lining"); + .attr('class', 'lining') paths.hint = new Path() .move(points.startLeft) .line(points.endLeft) .move(points.endRight) .line(points.startRight) - .attr("class", "lining dashed"); + .attr('class', 'lining dashed') if (complete) { - points.title = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5); - macro("title", { + points.title = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5) + macro('title', { at: points.title, nr: 17, - title: "chestPocketBag" - }); + title: 'chestPocketBag' + }) - macro("grainline", { + macro('grainline', { from: points.bottomLeft.shift(0, 10), to: points.topLeft.shift(0, 10) - }); + }) if (sa) { - paths.sa = paths.seam.offset(sa).attr("class", "lining sa"); + paths.sa = paths.seam.offset(sa).attr('class', 'lining sa') } - macro("ld", { + macro('ld', { from: points.bottomRight.shift(180, 15), to: points.topRight.shift(180, 15), - text: units(store.get("chestPocketBagDepth") * 2) - }); + text: units(store.get('chestPocketBagDepth') * 2) + }) if (paperless) { - macro("hd", { + macro('hd', { from: points.bottomLeft, to: points.bottomRight, y: points.bottomLeft.y + sa + 15 - }); + }) } } - return part; + return part } diff --git a/packages/carlton/src/chestpocketwelt.js b/packages/carlton/src/chestpocketwelt.js index 80142531bf0..116c990b403 100644 --- a/packages/carlton/src/chestpocketwelt.js +++ b/packages/carlton/src/chestpocketwelt.js @@ -1,27 +1,12 @@ export default function(part) { - let { paperless, sa, store, complete, points, macro, Point, paths, Path } = part.shorthand(); + let { paperless, sa, store, complete, points, macro, Point, paths, Path } = part.shorthand() - points.topLeft = new Point(0, 0); - points.bottomRight = new Point( - store.get("chestPocketWidth") * 2, - store.get("chestPocketHeight") - ); - points.bottomLeft = new Point( - points.topLeft.x, - points.bottomRight.y - ); - points.topRight = new Point( - points.bottomRight.x, - points.topLeft.y - ); - points.topMid = new Point( - store.get("chestPocketWidth"), - points.topRight.y - ); - points.bottomMid = new Point( - points.topMid.x, - points.bottomRight.y - ); + points.topLeft = new Point(0, 0) + points.bottomRight = new Point(store.get('chestPocketWidth') * 2, store.get('chestPocketHeight')) + points.bottomLeft = new Point(points.topLeft.x, points.bottomRight.y) + points.topRight = new Point(points.bottomRight.x, points.topLeft.y) + points.topMid = new Point(store.get('chestPocketWidth'), points.topRight.y) + points.bottomMid = new Point(points.topMid.x, points.bottomRight.y) paths.seam = new Path() .move(points.topLeft) @@ -30,39 +15,36 @@ export default function(part) { .line(points.topRight) .line(points.topLeft) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') paths.fold = new Path() .move(points.topMid) .line(points.bottomMid) - .attr("class", "dashed"); + .attr('class', 'dashed') if (complete) { - points.title = new Point( - points.bottomRight.x/4, - points.bottomRight.y/2, - ); - macro("title", { + points.title = new Point(points.bottomRight.x / 4, points.bottomRight.y / 2) + macro('title', { at: points.title, nr: 12, - title: "chestPocketWelt" - }); + title: 'chestPocketWelt' + }) - if (sa) paths.sa = paths.seam.offset(sa).attr("class", "fabric sa"); + if (sa) paths.sa = paths.seam.offset(sa).attr('class', 'fabric sa') if (paperless) { - macro("hd", { + macro('hd', { from: points.bottomLeft, to: points.bottomRight, y: points.bottomLeft.y + sa + 15 - }); - macro("vd", { + }) + macro('vd', { from: points.bottomRight, to: points.topRight, x: points.topRight.x + sa + 15 - }); + }) } } - return part; + return part } diff --git a/packages/carlton/src/collar.js b/packages/carlton/src/collar.js index 64c186dd9ab..a5e80b203a0 100644 --- a/packages/carlton/src/collar.js +++ b/packages/carlton/src/collar.js @@ -5,74 +5,72 @@ */ export default function(part) { - let { paperless, sa, complete, points, options, macro, paths, Path } = part.shorthand(); + let { paperless, sa, complete, points, options, macro, paths, Path } = part.shorthand() // We're going to slash and spread this collar. Slashing first: // Divide top in 5 parts - points.cutTop1 = points.topLeft.shiftFractionTowards(points.topRight, 0.2); - points.cutTop2 = points.topLeft.shiftFractionTowards(points.topRight, 0.4); - points.cutTop3 = points.topLeft.shiftFractionTowards(points.topRight, 0.6); - points.cutTop4 = points.topLeft.shiftFractionTowards(points.topRight, 0.8); + points.cutTop1 = points.topLeft.shiftFractionTowards(points.topRight, 0.2) + points.cutTop2 = points.topLeft.shiftFractionTowards(points.topRight, 0.4) + points.cutTop3 = points.topLeft.shiftFractionTowards(points.topRight, 0.6) + points.cutTop4 = points.topLeft.shiftFractionTowards(points.topRight, 0.8) // Divide bottom in 4 parts - let bottom = new Path() - .move(points.standTop) - .curve_(points.standTopCp, points.standTip) - points.cutBottom1 = bottom.shiftFractionAlong(0.25); - points.cutBottom2 = bottom.shiftFractionAlong(0.5); - points.cutBottom3 = bottom.shiftFractionAlong(0.75); + let bottom = new Path().move(points.standTop).curve_(points.standTopCp, points.standTip) + points.cutBottom1 = bottom.shiftFractionAlong(0.25) + points.cutBottom2 = bottom.shiftFractionAlong(0.5) + points.cutBottom3 = bottom.shiftFractionAlong(0.75) // Split curve, extract control points from ops - let halves = bottom.split(points.cutBottom2); - let quarters = []; - quarters.push(...halves[0].split(points.cutBottom1)); - quarters.push(...halves[1].split(points.cutBottom3)); - points.q1Cp1 = quarters[0].ops[1].cp1; - points.q1Cp2 = quarters[0].ops[1].cp2; - points.q2Cp1 = quarters[1].ops[1].cp1; - points.q2Cp2 = quarters[1].ops[1].cp2; - points.q3Cp1 = quarters[2].ops[1].cp1; - points.q3Cp2 = quarters[2].ops[1].cp2; - points.q4Cp1 = quarters[3].ops[1].cp1; - points.q4Cp2 = quarters[3].ops[1].cp2; + let halves = bottom.split(points.cutBottom2) + let quarters = [] + quarters.push(...halves[0].split(points.cutBottom1)) + quarters.push(...halves[1].split(points.cutBottom3)) + points.q1Cp1 = quarters[0].ops[1].cp1 + points.q1Cp2 = quarters[0].ops[1].cp2 + points.q2Cp1 = quarters[1].ops[1].cp1 + points.q2Cp2 = quarters[1].ops[1].cp2 + points.q3Cp1 = quarters[2].ops[1].cp1 + points.q3Cp2 = quarters[2].ops[1].cp2 + points.q4Cp1 = quarters[3].ops[1].cp1 + points.q4Cp2 = quarters[3].ops[1].cp2 // Collar slashed, not let's spread by rotating let rotate = { 1: { - pivot: "cutBottom1", - points: ["cutBottom2", "cutTop1", "cutTop2", "q2Cp1", "q2Cp2"] + pivot: 'cutBottom1', + points: ['cutBottom2', 'cutTop1', 'cutTop2', 'q2Cp1', 'q2Cp2'] }, 2: { - pivot: "cutBottom2", - points: ["cutBottom3", "cutTop2", "cutTop3", "q3Cp1", "q3Cp2"] + pivot: 'cutBottom2', + points: ['cutBottom3', 'cutTop2', 'cutTop3', 'q3Cp1', 'q3Cp2'] }, 3: { - pivot: "cutBottom3", - points: ["standTip", "bottomRight", "cutTop4", "cutTop3", "q4Cp1"] + pivot: 'cutBottom3', + points: ['standTip', 'bottomRight', 'cutTop4', 'cutTop3', 'q4Cp1'] }, 4: { - pivot: "standTip", - points: ["topRight", "bottomRight", "cutTop4"] - }, - }; - - let angle = -1 * options.collarSpread; - let alsoRotate = []; - for (let nr of [4,3,2,1]) { - let step = rotate[nr]; - let pivot = step.pivot; - let first = false; - for (let pnt of step.points) { - if(first === false) first = pnt; - let id = `rot${nr}${pnt}`; - points[id] = points[pnt].rotate(angle, points[pivot]); - alsoRotate.push(id); + pivot: 'standTip', + points: ['topRight', 'bottomRight', 'cutTop4'] } - if(nr <4) for (let pnt of alsoRotate) points[pnt] = points[pnt].rotate(angle, points[pivot]); + } + + let angle = -1 * options.collarSpread + let alsoRotate = [] + for (let nr of [4, 3, 2, 1]) { + let step = rotate[nr] + let pivot = step.pivot + let first = false + for (let pnt of step.points) { + if (first === false) first = pnt + let id = `rot${nr}${pnt}` + points[id] = points[pnt].rotate(angle, points[pivot]) + alsoRotate.push(id) + } + if (nr < 4) for (let pnt of alsoRotate) points[pnt] = points[pnt].rotate(angle, points[pivot]) } // Shift panel 2 in place - angle = points.cutBottom2.angle(points.rot1cutBottom2) + 180; - let distance = -1 * points.cutBottom2.dist(points.rot1cutBottom2); + angle = points.cutBottom2.angle(points.rot1cutBottom2) + 180 + let distance = -1 * points.cutBottom2.dist(points.rot1cutBottom2) for (let i of [ 'cutBottom2', 'rot2cutTop2', @@ -80,31 +78,23 @@ export default function(part) { 'rot2cutBottom3', 'rot2q3Cp1', 'rot2q3Cp2' - ]) points[i] = points[i].shift(angle, distance); + ]) + points[i] = points[i].shift(angle, distance) // Shift panel 3 in place - angle = points.cutBottom3.angle(points.rot2cutBottom3) + 180; - distance = -1 * points.cutBottom3.dist(points.rot2cutBottom3); - for (let i of [ - 'cutBottom3', - 'rot3cutTop3', - 'rot3cutTop4', - 'rot3standTip', - 'rot3q4Cp1', - ]) points[i] = points[i].shift(angle, distance); + angle = points.cutBottom3.angle(points.rot2cutBottom3) + 180 + distance = -1 * points.cutBottom3.dist(points.rot2cutBottom3) + for (let i of ['cutBottom3', 'rot3cutTop3', 'rot3cutTop4', 'rot3standTip', 'rot3q4Cp1']) + points[i] = points[i].shift(angle, distance) // Shift panel 4 in place - angle = points.standTip.angle(points.rot3standTip) + 180; - distance = -1 * points.standTip.dist(points.rot3standTip); - for (let i of [ - 'standTip', - 'rot4cutTop4', - 'rot4topRight', - 'rot4bottomRight' - ]) points[i] = points[i].shift(angle, distance); + angle = points.standTip.angle(points.rot3standTip) + 180 + distance = -1 * points.standTip.dist(points.rot3standTip) + for (let i of ['standTip', 'rot4cutTop4', 'rot4topRight', 'rot4bottomRight']) + points[i] = points[i].shift(angle, distance) // Top control point - points.topLeftCp = points.topLeft.shift(0, points.rot4topRight.x * 0.6); + points.topLeftCp = points.topLeft.shift(0, points.rot4topRight.x * 0.6) // Paths /* Uncomment these paths to gain insight into what's happening here @@ -159,7 +149,6 @@ export default function(part) { .attr("class", "dashed"); */ - paths.saBase = new Path() .move(points.standTop) /** This is the non-slashed path. We use this instead of the slashed @@ -175,82 +164,83 @@ export default function(part) { //.curve_(points.rot3q4Cp1, points.rot3standTip) .line(points.rot4bottomRight) .line(points.rot4topRight) - ._curve(points.topLeftCp, points.topLeft); - paths.seam = paths.saBase.clone() + ._curve(points.topLeftCp, points.topLeft) + paths.seam = paths.saBase + .clone() .line(points.standTop) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') if (complete) { - points.title = points.standTopCp.clone(); - macro("title", { + points.title = points.standTopCp.clone() + macro('title', { at: points.title, nr: 8, - title: "collar" - }); + title: 'collar' + }) - macro("grainline", { + macro('grainline', { from: points.standTop.shift(0, 10), to: points.topLeft.shift(0, 10) - }); + }) if (sa) { - paths.sa = paths.saBase.offset(sa); + paths.sa = paths.saBase.offset(sa) paths.sa = paths.sa .line(points.topLeft) .move(points.standTop) .line(paths.sa.start()) - .attr("class", "fabric sa"); + .attr('class', 'fabric sa') } if (paperless) { - macro("hd", { + macro('hd', { from: points.standTop, to: points.rot3standTip, y: points.rot4bottomRight.y + sa + 15 - }); - macro("hd", { + }) + macro('hd', { from: points.standTop, to: points.rot4bottomRight, y: points.rot4bottomRight.y + sa + 30 - }); - macro("hd", { + }) + macro('hd', { from: points.standTop, to: points.rot4topRight, y: points.rot4bottomRight.y + sa + 45 - }); - macro("vd", { + }) + macro('vd', { from: points.standTop, to: points.topLeft, x: points.topLeft.x - 15 - }); - macro("vd", { + }) + macro('vd', { from: points.rot3standTip, to: points.topLeft, x: points.topLeft.x - 30 - }); - macro("vd", { + }) + macro('vd', { from: points.rot4topRight, to: points.topLeft, x: points.rot4topRight.x + sa + 15 - }); - macro("vd", { + }) + macro('vd', { from: points.rot4bottomRight, to: points.topLeft, x: points.rot4topRight.x + sa + 30 - }); - macro("ld", { + }) + macro('ld', { from: points.rot4bottomRight, to: points.rot4topRight, - d: -1*sa - 15 - }); - macro("ld", { + d: -1 * sa - 15 + }) + macro('ld', { from: points.rot3standTip, to: points.rot4bottomRight, - d: -1*sa - 15 - }); + d: -1 * sa - 15 + }) } } - return part; + return part } diff --git a/packages/carlton/src/collarstand.js b/packages/carlton/src/collarstand.js index 2befb5383d8..6d8a94ac447 100644 --- a/packages/carlton/src/collarstand.js +++ b/packages/carlton/src/collarstand.js @@ -1,20 +1,35 @@ export default function(part) { - let { paperless, sa, store, complete, points, measurements, options, macro, Point, paths, Path } = part.shorthand(); + let { + paperless, + sa, + store, + complete, + points, + measurements, + options, + macro, + Point, + paths, + Path + } = part.shorthand() - let height = measurements.chestCircumference * options.collarHeight; - let length = store.get("frontCollarLength") + store.get("backCollarLength"); - points.topLeft = new Point(0, 0); - points.bottomLeft = new Point(0, height); - points.topRight = new Point(length, height * -1 * options.collarFlare); + let height = measurements.chestCircumference * options.collarHeight + let length = store.get('frontCollarLength') + store.get('backCollarLength') + points.topLeft = new Point(0, 0) + points.bottomLeft = new Point(0, height) + points.topRight = new Point(length, height * -1 * options.collarFlare) points.bottomRight = new Point(length, height) - points.bottomLeftCp = points.bottomLeft.shift(0, points.bottomRight.x * 0.4); - points.standTop = points.bottomLeft.shiftFractionTowards(points.topLeft, 0.25); - points.standTip = new Point(points.topRight.x * 0.75, points.bottomLeft.y + points.topRight.x/8.5); - points.standTipCp = points.standTip.shift(180, points.standTop.dy(points.bottomLeft)); - points.standTopCp = points.standTop.shift(0, points.standTip.x * 0.9); + points.bottomLeftCp = points.bottomLeft.shift(0, points.bottomRight.x * 0.4) + points.standTop = points.bottomLeft.shiftFractionTowards(points.topLeft, 0.25) + points.standTip = new Point( + points.topRight.x * 0.75, + points.bottomLeft.y + points.topRight.x / 8.5 + ) + points.standTipCp = points.standTip.shift(180, points.standTop.dy(points.bottomLeft)) + points.standTopCp = points.standTop.shift(0, points.standTip.x * 0.9) - for (let i of ["standTopCp", "standTip", "standTipCp", "bottomLeftCp"]) { - points[i+"Left"] = points[i].flipX(); + for (let i of ['standTopCp', 'standTip', 'standTipCp', 'bottomLeftCp']) { + points[i + 'Left'] = points[i].flipX() } paths.seam = new Path() @@ -24,41 +39,41 @@ export default function(part) { .curve_(points.standTopCpLeft, points.standTipLeft) .curve(points.standTipCpLeft, points.bottomLeftCpLeft, points.bottomLeft) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') if (complete) { - points.title = points.bottomLeftCp.clone(); - macro("title", { + points.title = points.bottomLeftCp.clone() + macro('title', { at: points.title, nr: 7, - title: "collarStand" - }); + title: 'collarStand' + }) - macro("grainline", { + macro('grainline', { from: points.bottomLeft, to: points.standTop - }); + }) - if (sa) paths.sa = paths.seam.offset(sa).attr("class", "fabric sa"); + if (sa) paths.sa = paths.seam.offset(sa).attr('class', 'fabric sa') if (paperless) { - macro("hd", { + macro('hd', { from: points.standTipLeft, to: points.standTip, y: points.standTip.y + sa + 15 - }); - macro("vd", { + }) + macro('vd', { from: points.bottomLeft, to: points.standTop, x: points.standTip.x + sa + 15 - }); - macro("vd", { + }) + macro('vd', { from: points.standTip, to: points.standTop, x: points.standTip.x + sa + 30 - }); + }) } } - return part; + return part } diff --git a/packages/carlton/src/cufffacing.js b/packages/carlton/src/cufffacing.js index 9ed90485880..db32494df7f 100644 --- a/packages/carlton/src/cufffacing.js +++ b/packages/carlton/src/cufffacing.js @@ -1,33 +1,27 @@ export default function(part) { - let { paperless, sa, store, complete, points, macro, Point, paths, Path } = part.shorthand(); + let { paperless, sa, store, complete, points, macro, Point, paths, Path } = part.shorthand() - points.topLeft = new Point(0, 0); + points.topLeft = new Point(0, 0) points.bottomRight = new Point( - store.get("topCuffWidth") + store.get("underCuffWidth"), - store.get("cuffLength") * 1.5 - ); - points.bottomLeft = new Point( - points.topLeft.x, - points.bottomRight.y - ); - points.topRight = new Point( - points.bottomRight.x, - points.topLeft.y - ); - macro("round", { + store.get('topCuffWidth') + store.get('underCuffWidth'), + store.get('cuffLength') * 1.5 + ) + points.bottomLeft = new Point(points.topLeft.x, points.bottomRight.y) + points.topRight = new Point(points.bottomRight.x, points.topLeft.y) + macro('round', { from: points.topLeft, to: points.bottomRight, via: points.bottomLeft, - radius: store.get("cuffRadius"), - prefix: "roundLeft" - }); - macro("round", { + radius: store.get('cuffRadius'), + prefix: 'roundLeft' + }) + macro('round', { from: points.bottomLeft, to: points.topRight, via: points.bottomRight, - radius: store.get("cuffRadius"), - prefix: "roundRight" - }); + radius: store.get('cuffRadius'), + prefix: 'roundRight' + }) paths.seam = new Path() .move(points.topLeft) @@ -38,47 +32,46 @@ export default function(part) { .line(points.topRight) .line(points.topLeft) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') if (complete) { - points.title = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5); - macro("title", { + points.title = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5) + macro('title', { at: points.title, nr: 9, - title: "cuffFacing" - }); + title: 'cuffFacing' + }) - macro("grainline", { - from: points.bottomLeft.shift(0, 10+store.get("cuffRadius")), - to: points.topLeft.shift(0, 10+store.get("cuffRadius")), - }); + macro('grainline', { + from: points.bottomLeft.shift(0, 10 + store.get('cuffRadius')), + to: points.topLeft.shift(0, 10 + store.get('cuffRadius')) + }) - if (sa) paths.sa = paths.seam.offset(sa).attr("class", "fabric sa"); + if (sa) paths.sa = paths.seam.offset(sa).attr('class', 'fabric sa') if (paperless) { - macro("vd", { + macro('vd', { from: points.roundRightStart, to: points.roundRightEnd, x: points.topRight.x + sa + 15 - }); - macro("vd", { + }) + macro('vd', { from: points.roundRightStart, to: points.topRight, x: points.topRight.x + sa + 30 - }); - macro("hd", { + }) + macro('hd', { from: points.roundRightStart, to: points.roundRightEnd, y: points.bottomRight.y + sa + 15 - }); - macro("hd", { + }) + macro('hd', { from: points.roundLeftStart, to: points.roundRightEnd, y: points.bottomRight.y + sa + 30 - }); + }) } } - - return part; + return part } diff --git a/packages/carlton/src/front.js b/packages/carlton/src/front.js index 292e83855a8..d0a0f4ea1ae 100644 --- a/packages/carlton/src/front.js +++ b/packages/carlton/src/front.js @@ -1,164 +1,170 @@ -import { calculateRatios } from "./shared"; +import { calculateRatios } from './shared' export default function(part) { - let { paperless, sa, snippets, Snippet, utils, store, complete, points, measurements, options, macro, Point, paths, Path } = part.shorthand(); + let { + paperless, + sa, + snippets, + Snippet, + utils, + store, + complete, + points, + measurements, + options, + macro, + Point, + paths, + Path + } = part.shorthand() - calculateRatios(part); + calculateRatios(part) // Waist shaping - points.waist = points.cfWaist.shift(0, store.get("chest")/4 - store.get("waistReduction")/8); - points.waistCp1 = points.waist.shift(-90, points.waist.dy(points.hips)/2); - points.waistCp2 = points.waist.shift(90, points.armhole.dy(points.waist)/2); + points.waist = points.cfWaist.shift(0, store.get('chest') / 4 - store.get('waistReduction') / 8) + points.waistCp1 = points.waist.shift(-90, points.waist.dy(points.hips) / 2) + points.waistCp2 = points.waist.shift(90, points.armhole.dy(points.waist) / 2) // Seat shaping - points.cfSeat = points.cfWaist.shift(-90, measurements.naturalWaistToSeat); - points.seat = points.cfSeat.shift(0, store.get("seat")/4); - points.seatCp2 = points.seat.shift(90, points.waist.dy(points.seat)/3); + points.cfSeat = points.cfWaist.shift(-90, measurements.naturalWaistToSeat) + points.seat = points.cfSeat.shift(0, store.get('seat') / 4) + points.seatCp2 = points.seat.shift(90, points.waist.dy(points.seat) / 3) // Hem length - points.cfHem = points.cfWaist.shift(-90, measurements.naturalWaistToFloor * options.length); - points.hem = new Point( - points.seat.x, - points.cfHem.y - ); - store.set("waistToHem", points.cfHem.y - points.waist.y); + points.cfHem = points.cfWaist.shift(-90, measurements.naturalWaistToFloor * options.length) + points.hem = new Point(points.seat.x, points.cfHem.y) + store.set('waistToHem', points.cfHem.y - points.waist.y) // Buttonline - let buttonW = points.waist.x * options.buttonSpacingHorizontal; - let buttonH = points.waist.dy(points.hips) / 1.5; - points.button1Left = points.cfHips.shift(180, buttonW / 2); - points.button1Right = points.cfHips.shift(0, buttonW / 2); - points.button2Left = points.button1Left.shift(90, buttonH); - points.button2Right = points.button2Left.shift(0, buttonW); - points.button3Left = points.button2Left.shift(90, buttonH); - points.button3Right = points.button3Left.shift(0, buttonW); + let buttonW = points.waist.x * options.buttonSpacingHorizontal + let buttonH = points.waist.dy(points.hips) / 1.5 + points.button1Left = points.cfHips.shift(180, buttonW / 2) + points.button1Right = points.cfHips.shift(0, buttonW / 2) + points.button2Left = points.button1Left.shift(90, buttonH) + points.button2Right = points.button2Left.shift(0, buttonW) + points.button3Left = points.button2Left.shift(90, buttonH) + points.button3Right = points.button3Left.shift(0, buttonW) // Front closure edge points.collarEdge = new Point( points.button1Left.x - measurements.naturalWaist * options.frontOverlap, points.cfNeck.y - ); - points.hemEdge = new Point( - points.collarEdge.x, - points.hem.y - ); + ) + points.hemEdge = new Point(points.collarEdge.x, points.hem.y) // Collar - points.collarTip = points.collarEdge.shiftFractionTowards(points.cfNeck, options.lapelReduction); - points.lapelStraightEnd = new Point( - points.collarEdge.x, - points.armhole.y - ); - points.lapelStraightEndCp1 = points.lapelStraightEnd.shiftFractionTowards(points.collarEdge, 0.7); + points.collarTip = points.collarEdge.shiftFractionTowards(points.cfNeck, options.lapelReduction) + points.lapelStraightEnd = new Point(points.collarEdge.x, points.armhole.y) + points.lapelStraightEndCp1 = points.lapelStraightEnd.shiftFractionTowards(points.collarEdge, 0.7) // Pocket points.pocketTopLeft = new Point( points.button1Right.x + points.button1Right.dx(points.hips) * options.pocketPlacementHorizontal, - points.button1Right.y + points.button1Right.dy(points.button3Right) * options.pocketPlacementVertical - ); - let pocketWidth = points.button1Right.dx(points.hips) * options.pocketWidth; - let pocketHeight = pocketWidth * (1 + options.pocketHeight); - points.pocketTopRight = points.pocketTopLeft.shift(0, pocketWidth); - points.pocketBottomLeft = points.pocketTopLeft.shift(-90, pocketHeight); - points.pocketBottomRight = points.pocketTopRight.shift(-90, pocketHeight); + points.button1Right.y + + points.button1Right.dy(points.button3Right) * options.pocketPlacementVertical + ) + let pocketWidth = points.button1Right.dx(points.hips) * options.pocketWidth + let pocketHeight = pocketWidth * (1 + options.pocketHeight) + points.pocketTopRight = points.pocketTopLeft.shift(0, pocketWidth) + points.pocketBottomLeft = points.pocketTopLeft.shift(-90, pocketHeight) + points.pocketBottomRight = points.pocketTopRight.shift(-90, pocketHeight) if (options.pocketRadius > 0) { - let radius = pocketWidth * options.pocketRadius; - macro("round", { + let radius = pocketWidth * options.pocketRadius + macro('round', { from: points.pocketTopLeft, to: points.pocketBottomRight, via: points.pocketBottomLeft, - prefix: "pocketRoundLeft", + prefix: 'pocketRoundLeft', radius - }); - macro("round", { + }) + macro('round', { from: points.pocketBottomLeft, to: points.pocketTopRight, via: points.pocketBottomRight, - prefix: "pocketRoundRight", + prefix: 'pocketRoundRight', radius - }); - store.set("pocketRadius", radius); + }) + store.set('pocketRadius', radius) } - store.set("pocketWidth", pocketWidth); - store.set("pocketHeight", pocketHeight); + store.set('pocketWidth', pocketWidth) + store.set('pocketHeight', pocketHeight) // Pocket flap - points.pocketFlapMid = points.pocketTopLeft.shift(0, pocketWidth/2); - let pocketFlapHeight = pocketHeight * 0.3; - store.set("pocketFlapHeight", pocketFlapHeight); + points.pocketFlapMid = points.pocketTopLeft.shift(0, pocketWidth / 2) + let pocketFlapHeight = pocketHeight * 0.3 + store.set('pocketFlapHeight', pocketFlapHeight) points.pocketFlapTopLeft = new Point( points.pocketTopLeft.x - pocketWidth * 0.005, points.pocketTopLeft.y - pocketFlapHeight / 4 - ); + ) points.pocketFlapBottomLeft = new Point( points.pocketFlapTopLeft.x, points.pocketTopLeft.y + pocketFlapHeight * 0.75 - ); - points.pocketFlapTopRight = points.pocketFlapTopLeft.flipX(points.pocketFlapMid); - points.pocketFlapBottomRight = points.pocketFlapBottomLeft.flipX(points.pocketFlapMid); + ) + points.pocketFlapTopRight = points.pocketFlapTopLeft.flipX(points.pocketFlapMid) + points.pocketFlapBottomRight = points.pocketFlapBottomLeft.flipX(points.pocketFlapMid) if (options.pocketFlapRadius > 0) { - let radius = pocketWidth * options.pocketFlapRadius; - macro("round", { + let radius = pocketWidth * options.pocketFlapRadius + macro('round', { from: points.pocketFlapTopLeft, to: points.pocketFlapBottomRight, via: points.pocketFlapBottomLeft, - prefix: "pocketFlapRoundLeft", - radius, - }); - macro("round", { + prefix: 'pocketFlapRoundLeft', + radius + }) + macro('round', { from: points.pocketFlapBottomLeft, to: points.pocketFlapTopRight, via: points.pocketFlapBottomRight, - prefix: "pocketFlapRoundRight", - radius, - }); - store.set("pocketFlapRadius", radius); + prefix: 'pocketFlapRoundRight', + radius + }) + store.set('pocketFlapRadius', radius) } // Chest pocket points.chestPocketAnchor = new Point( points.waist.x * options.chestPocketPlacement, points.button2Right.shiftFractionTowards(points.button3Right, 0.2).y - ); - let chestPocketHeight = points.armhole.dy(points.chestPocketAnchor) * options.chestPocketHeight; - let chestPocketWidth = chestPocketHeight * options.chestPocketWidth; - store.set("chestPocketHeight", chestPocketHeight); - store.set("chestPocketWidth", chestPocketWidth); - points.chestPocketBottomLeft = points.chestPocketAnchor.shift(180, chestPocketWidth / 2); - points.chestPocketTopLeft = points.chestPocketBottomLeft.shift(90, chestPocketHeight); - points.chestPocketBottomRight = points.chestPocketBottomLeft.flipX(points.chestPocketAnchor); - points.chestPocketTopRight = points.chestPocketTopLeft.flipX(points.chestPocketAnchor); + ) + let chestPocketHeight = points.armhole.dy(points.chestPocketAnchor) * options.chestPocketHeight + let chestPocketWidth = chestPocketHeight * options.chestPocketWidth + store.set('chestPocketHeight', chestPocketHeight) + store.set('chestPocketWidth', chestPocketWidth) + points.chestPocketBottomLeft = points.chestPocketAnchor.shift(180, chestPocketWidth / 2) + points.chestPocketTopLeft = points.chestPocketBottomLeft.shift(90, chestPocketHeight) + points.chestPocketBottomRight = points.chestPocketBottomLeft.flipX(points.chestPocketAnchor) + points.chestPocketTopRight = points.chestPocketTopLeft.flipX(points.chestPocketAnchor) for (let i of [ - "chestPocketTopLeft", - "chestPocketBottomLeft", - "chestPocketTopRight", - "chestPocketBottomRight"]) points[i] = points[i].rotate(options.chestPocketAngle, points.chestPocketAnchor); - store.set("chestPocketBagDepth", points.button3Left.dx(points.chestPocketBottomLeft)); + 'chestPocketTopLeft', + 'chestPocketBottomLeft', + 'chestPocketTopRight', + 'chestPocketBottomRight' + ]) + points[i] = points[i].rotate(options.chestPocketAngle, points.chestPocketAnchor) + store.set('chestPocketBagDepth', points.button3Left.dx(points.chestPocketBottomLeft)) // Inner pocket points.innerPocketAnchor = new Point( points.waist.x * options.innerPocketPlacement, points.button2Right.shiftFractionTowards(points.button3Right, 1.5).y - ); - let innerPocketWidth = points.waist.x * options.innerPocketWidth; - let weltHeight = innerPocketWidth * options.innerPocketWeltHeight; - store.set("innerPocketWeltHeight", weltHeight); - store.set("innerPocketWidth", innerPocketWidth); - points.innerPocketTop = points.innerPocketAnchor.shift(90, weltHeight); - points.innerPocketBottom = points.innerPocketAnchor.shift(-90, weltHeight); - points.innerPocketLeft = points.innerPocketAnchor.shift(180, innerPocketWidth/2); - points.innerPocketRight = points.innerPocketLeft.flipX(points.innerPocketAnchor); - points.innerPocketTopLeft = points.innerPocketLeft.shift(90, weltHeight); - points.innerPocketTopRight = points.innerPocketTopLeft.flipX(points.innerPocketAnchor); - points.innerPocketBottomLeft = points.innerPocketLeft.shift(-90, weltHeight); - points.innerPocketBottomRight = points.innerPocketBottomLeft.flipX(points.innerPocketAnchor); + ) + let innerPocketWidth = points.waist.x * options.innerPocketWidth + let weltHeight = innerPocketWidth * options.innerPocketWeltHeight + store.set('innerPocketWeltHeight', weltHeight) + store.set('innerPocketWidth', innerPocketWidth) + points.innerPocketTop = points.innerPocketAnchor.shift(90, weltHeight) + points.innerPocketBottom = points.innerPocketAnchor.shift(-90, weltHeight) + points.innerPocketLeft = points.innerPocketAnchor.shift(180, innerPocketWidth / 2) + points.innerPocketRight = points.innerPocketLeft.flipX(points.innerPocketAnchor) + points.innerPocketTopLeft = points.innerPocketLeft.shift(90, weltHeight) + points.innerPocketTopRight = points.innerPocketTopLeft.flipX(points.innerPocketAnchor) + points.innerPocketBottomLeft = points.innerPocketLeft.shift(-90, weltHeight) + points.innerPocketBottomRight = points.innerPocketBottomLeft.flipX(points.innerPocketAnchor) // Roll line - points.rollLineEdge = points.shoulder.shiftFractionTowards(points.neck, 1.15); - points.rollLineStart = new Point( - points.collarEdge.x, - points.button3Left.y - ); + points.rollLineEdge = points.shoulder.shiftFractionTowards(points.neck, 1.15) + points.rollLineStart = new Point(points.collarEdge.x, points.button3Left.y) points.rollLineEnd = utils.lineIntersectsCurve( points.rollLineStart, points.rollLineEdge, @@ -166,39 +172,33 @@ export default function(part) { points.cfNeckCp1, points.neckCp2Front, points.neck - ); + ) // Facing/Lining border (flb) - points.flbX = points.button1Right.shift(0, points.button1Right.dx(points.pocketTopLeft)/2); - points.flbHem = new Point(points.flbX.x, points.hemEdge.y); - if (points.flbHem.x <= points.cfNeck.x) - points.flbTop = new Point(points.flbX.x, points.cfNeck.y); + points.flbX = points.button1Right.shift(0, points.button1Right.dx(points.pocketTopLeft) / 2) + points.flbHem = new Point(points.flbX.x, points.hemEdge.y) + if (points.flbHem.x <= points.cfNeck.x) points.flbTop = new Point(points.flbX.x, points.cfNeck.y) else if (points.flbHem.x < points.neck.x) points.flbTop = utils.lineIntersectsCurve( points.flbHem, - points.flbX.shift(90,points.flbHem.y * 2), + points.flbX.shift(90, points.flbHem.y * 2), points.cfNeck, points.cfNeckCp1, points.neckCp2Front, points.neck - ); + ) else if (points.flbHem.x < points.shoulder.x) - points.flbTop = utils.beamsIntersect( - points.flbHem, - points.flbX, - points.neck, - points.shoulder - ); - else throw new Error("Could not find intersection of facing/lining boundary with neckline"); + points.flbTop = utils.beamsIntersect(points.flbHem, points.flbX, points.neck, points.shoulder) + else throw new Error('Could not find intersection of facing/lining boundary with neckline') // Store collar length store.set( - "frontCollarLength", + 'frontCollarLength', new Path() .move(points.cfNeck) .curve(points.cfNeckCp1, points.neckCp2Front, points.neck) .length() - ); + ) // Clean up for (let i in paths) delete paths[i] @@ -218,33 +218,31 @@ export default function(part) { .line(points.collarTip) ._curve(points.lapelStraightEndCp1, points.lapelStraightEnd) .line(points.hemEdge) - .line(points.flbHem); - paths.hemBase = new Path() - .move(points.flbHem) - .line(points.hem); - paths.saBase.render = false; - paths.hemBase.render = false; + .line(points.flbHem) + paths.hemBase = new Path().move(points.flbHem).line(points.hem) + paths.saBase.render = false + paths.hemBase.render = false paths.seam = paths.saBase .join(paths.hemBase) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') paths.rollLine = new Path() .move(points.rollLineStart) .line(points.rollLineEnd) - .attr("class", "lashed"); + .attr('class', 'lashed') paths.chestPiece = new Path() .move(points.rollLineStart) .curve(points.button3Right, points.waistCp2, points.armhole) - .attr("class", "canvas lashed"); + .attr('class', 'canvas lashed') paths.flb = new Path() .move(points.flbHem) .line(points.flbTop) - .attr("class", "lining lashed"); + .attr('class', 'lining lashed') - paths.pocket = new Path().move(points.pocketTopLeft); + paths.pocket = new Path().move(points.pocketTopLeft) if (options.pocketRadius > 0) { paths.pocket = paths.pocket .line(points.pocketRoundLeftStart) @@ -252,33 +250,39 @@ export default function(part) { .line(points.pocketRoundRightStart) .curve(points.pocketRoundRightCp1, points.pocketRoundRightCp2, points.pocketRoundRightEnd) } else { - paths.pocket = paths.pocket - .line(points.pocketBottomLeft) - .line(points.pocketBottomRight) + paths.pocket = paths.pocket.line(points.pocketBottomLeft).line(points.pocketBottomRight) } paths.pocket = paths.pocket .line(points.pocketTopRight) .line(points.pocketTopLeft) .close() - .attr("class", "fabric help"); + .attr('class', 'fabric help') - paths.pocketFlap = new Path().move(points.pocketFlapTopLeft); + paths.pocketFlap = new Path().move(points.pocketFlapTopLeft) if (options.pocketFlapRadius > 0) { paths.pocketFlap = paths.pocketFlap .line(points.pocketFlapRoundLeftStart) - .curve(points.pocketFlapRoundLeftCp1, points.pocketFlapRoundLeftCp2, points.pocketFlapRoundLeftEnd) + .curve( + points.pocketFlapRoundLeftCp1, + points.pocketFlapRoundLeftCp2, + points.pocketFlapRoundLeftEnd + ) .line(points.pocketFlapRoundRightStart) - .curve(points.pocketFlapRoundRightCp1, points.pocketFlapRoundRightCp2, points.pocketFlapRoundRightEnd) + .curve( + points.pocketFlapRoundRightCp1, + points.pocketFlapRoundRightCp2, + points.pocketFlapRoundRightEnd + ) } else { paths.pocketFlap = paths.pocketFlap .line(points.pocketFlapBottomLeft) - .line(points.pocketFlapBottomRight); + .line(points.pocketFlapBottomRight) } paths.pocketFlap = paths.pocketFlap .line(points.pocketFlapTopRight) .line(points.pocketFlapTopLeft) .close() - .attr("class", "fabric help"); + .attr('class', 'fabric help') paths.chestPocket = new Path() .move(points.chestPocketTopLeft) @@ -287,7 +291,7 @@ export default function(part) { .line(points.chestPocketTopRight) .line(points.chestPocketTopLeft) .close() - .attr("class", "fabric help"); + .attr('class', 'fabric help') paths.innerPocket = new Path() .move(points.innerPocketTopLeft) @@ -296,190 +300,180 @@ export default function(part) { .line(points.innerPocketTopRight) .line(points.innerPocketTopLeft) .close() - .attr("class", "fabric help"); + .attr('class', 'fabric help') if (complete) { - snippets.button1Left = new Snippet("button", points.button1Left).attr("data-scale", 2); - snippets.button1Right = new Snippet("button", points.button1Right).attr("data-scale", 2); - snippets.button2Left = new Snippet("button", points.button2Left).attr("data-scale", 2); - snippets.button2Right = new Snippet("button", points.button2Right).attr("data-scale", 2); - snippets.button3Left = new Snippet("button", points.button3Left).attr("data-scale", 2); - snippets.button3Right = new Snippet("button", points.button3Right).attr("data-scale", 2); + snippets.button1Left = new Snippet('button', points.button1Left).attr('data-scale', 2) + snippets.button1Right = new Snippet('button', points.button1Right).attr('data-scale', 2) + snippets.button2Left = new Snippet('button', points.button2Left).attr('data-scale', 2) + snippets.button2Right = new Snippet('button', points.button2Right).attr('data-scale', 2) + snippets.button3Left = new Snippet('button', points.button3Left).attr('data-scale', 2) + snippets.button3Right = new Snippet('button', points.button3Right).attr('data-scale', 2) - macro("sprinkle", { - snippet: "notch", - on: [ - "armholePitch", - "cfNeck", - "rollLineStart", - "waist", - "seat" - ] - }); + macro('sprinkle', { + snippet: 'notch', + on: ['armholePitch', 'cfNeck', 'rollLineStart', 'waist', 'seat'] + }) - points.logo = new Point( - points.chestPocketTopRight.x, - points.armhole.y - ); - snippets.logo = new Snippet("logo", points.logo); + points.logo = new Point(points.chestPocketTopRight.x, points.armhole.y) + snippets.logo = new Snippet('logo', points.logo) - macro("grainline", { + macro('grainline', { from: points.cfHem, to: points.cfNeck - }); + }) if (sa) { paths.sa = paths.saBase .offset(sa) - .join(paths.hemBase.offset(sa*3)) + .join(paths.hemBase.offset(sa * 3)) .close() - .attr("class", "fabric sa"); + .attr('class', 'fabric sa') } if (paperless) { - macro("ld", { + macro('ld', { from: points.hemEdge, to: points.flbHem, d: 15 - }); - macro("ld", { + }) + macro('ld', { from: points.flbHem, to: points.hem, d: 15 - }); - macro("hd", { + }) + macro('hd', { from: points.hemEdge, to: points.hem, - y: points.hem.y + 15 + 3*sa - }); - macro("hd", { + y: points.hem.y + 15 + 3 * sa + }) + macro('hd', { from: points.rollLineStart, to: points.pocketTopLeft, y: points.pocketFlapBottomLeft.y - }); - macro("vd", { + }) + macro('vd', { from: points.pocketFlapTopRight, to: points.waist, x: points.pocketTopRight.x - 15 - }); - macro("vd", { + }) + macro('vd', { from: points.pocketTopRight, to: points.waist, x: points.pocketTopRight.x - 30 - }); - macro("vd", { + }) + macro('vd', { from: points.chestPocketBottomLeft, to: points.waist, x: points.chestPocketBottomLeft.x - 15 - }); - macro("hd", { + }) + macro('hd', { from: points.rollLineStart, to: points.chestPocketBottomLeft, y: points.chestPocketBottomLeft.y + 15 - }); - macro("hd", { + }) + macro('hd', { from: points.rollLineStart, to: points.button3Left, y: points.button3Left.y + 15 - }); - macro("hd", { + }) + macro('hd', { from: points.button3Left, to: points.button3Right, y: points.button3Left.y + 15 - }); - macro("vd", { + }) + macro('vd', { from: points.hem, to: points.seat, x: points.hem.x + sa + 15 - }); - macro("vd", { + }) + macro('vd', { from: points.hem, to: points.waist, x: points.hem.x + sa + 30 - }); - macro("vd", { + }) + macro('vd', { from: points.hem, to: points.armhole, x: points.hem.x + sa + 45 - }); - macro("vd", { + }) + macro('vd', { from: points.armhole, to: points.armholePitch, x: points.armhole.x + sa + 15 - }); - macro("vd", { + }) + macro('vd', { from: points.armhole, to: points.shoulder, x: points.armhole.x + sa + 30 - }); - macro("vd", { + }) + macro('vd', { from: points.armhole, to: points.neck, x: points.armhole.x + sa + 45 - }); - macro("vd", { + }) + macro('vd', { from: points.rollLineStart, to: points.collarTip, x: points.rollLineStart.x - sa - 15 - }); - macro("vd", { + }) + macro('vd', { from: points.button2Left, to: points.rollLineStart, x: points.rollLineStart.x - sa - 15 - }); - macro("vd", { + }) + macro('vd', { from: points.button1Left, to: points.button2Left, x: points.rollLineStart.x - sa - 15 - }); - macro("vd", { + }) + macro('vd', { from: points.hemEdge, to: points.collarTip, x: points.rollLineStart.x - sa - 30 - }); - macro("vd", { + }) + macro('vd', { from: points.hemEdge, to: points.neck, x: points.rollLineStart.x - sa - 45 - }); - macro("hd", { + }) + macro('hd', { from: points.lapelStraightEnd, to: points.collarTip, y: points.collarTip.y - sa - 15 - }); - macro("hd", { + }) + macro('hd', { from: points.lapelStraightEnd, to: points.cfNeck, y: points.collarTip.y - sa - 30 - }); - macro("hd", { + }) + macro('hd', { from: points.lapelStraightEnd, to: points.rollLineEnd, y: points.collarTip.y - sa - 45 - }); - macro("hd", { + }) + macro('hd', { from: points.lapelStraightEnd, to: points.neck, y: points.neck.y - sa - 15 - }); - macro("hd", { + }) + macro('hd', { from: points.lapelStraightEnd, to: points.armholePitch, y: points.neck.y - sa - 30 - }); - macro("hd", { + }) + macro('hd', { from: points.lapelStraightEnd, to: points.shoulder, y: points.neck.y - sa - 45 - }); - macro("hd", { + }) + macro('hd', { from: points.lapelStraightEnd, to: points.armhole, y: points.neck.y - sa - 60 - }); + }) } } - - return part; + return part } diff --git a/packages/carlton/src/index.js b/packages/carlton/src/index.js index 74d897d74a2..232aebb98b0 100644 --- a/packages/carlton/src/index.js +++ b/packages/carlton/src/index.js @@ -1,67 +1,67 @@ -import freesewing from "@freesewing/core"; -import plugins from "@freesewing/plugin-bundle"; -import buttons from "@freesewing/plugin-buttons"; -import Bent from "@freesewing/bent"; -import config from "../config"; +import freesewing from '@freesewing/core' +import plugins from '@freesewing/plugin-bundle' +import buttons from '@freesewing/plugin-buttons' +import Bent from '@freesewing/bent' +import config from '../config' // Parts -import draftFront from "./front"; -import draftBack from "./back"; -import draftTail from "./tail"; -import draftTopSleeve from "./topsleeve"; -import draftUnderSleeve from "./undersleeve"; -import draftBelt from "./belt"; -import draftCollarStand from "./collarstand"; -import draftCollar from "./collar"; -import draftCuffFacing from "./cufffacing"; -import draftPocket from "./pocket"; -import draftPocketFlap from "./pocketflap"; -import draftPocketLining from "./pocketlining"; -import draftChestPocketWelt from "./chestpocketwelt"; -import draftChestPocketBag from "./chestpocketbag"; -import draftInnerPocketWelt from "./innerpocketwelt"; -import draftInnerPocketBag from "./innerpocketbag"; -import draftInnerPocketTab from "./innerpockettab"; +import draftFront from './front' +import draftBack from './back' +import draftTail from './tail' +import draftTopSleeve from './topsleeve' +import draftUnderSleeve from './undersleeve' +import draftBelt from './belt' +import draftCollarStand from './collarstand' +import draftCollar from './collar' +import draftCuffFacing from './cufffacing' +import draftPocket from './pocket' +import draftPocketFlap from './pocketflap' +import draftPocketLining from './pocketlining' +import draftChestPocketWelt from './chestpocketwelt' +import draftChestPocketBag from './chestpocketbag' +import draftInnerPocketWelt from './innerpocketwelt' +import draftInnerPocketBag from './innerpocketbag' +import draftInnerPocketTab from './innerpockettab' // Create new design -const Pattern = new freesewing.Design(config, [plugins, buttons]); +const Pattern = new freesewing.Design(config, [plugins, buttons]) // Attach draft methods from Bent to prototype Pattern.prototype.draftBentBase = function(part) { - return new Bent(this.settings).draftBase(part); -}; + return new Bent(this.settings).draftBase(part) +} Pattern.prototype.draftBentFront = function(part) { - return new Bent(this.settings).draftFront(part); -}; + return new Bent(this.settings).draftFront(part) +} Pattern.prototype.draftBentBack = function(part) { - return new Bent(this.settings).draftBack(part); -}; + return new Bent(this.settings).draftBack(part) +} Pattern.prototype.draftBentSleeve = function(part) { - return new Bent(this.settings).draftSleeve(part); -}; + return new Bent(this.settings).draftSleeve(part) +} Pattern.prototype.draftBentTopSleeve = function(part) { - return new Bent(this.settings).draftTopSleeve(part); -}; + return new Bent(this.settings).draftTopSleeve(part) +} Pattern.prototype.draftBentUnderSleeve = function(part) { - return new Bent(this.settings).draftUnderSleeve(part); -}; + return new Bent(this.settings).draftUnderSleeve(part) +} // Attach own draft methods to prototype -Pattern.prototype.draftFront = draftFront; -Pattern.prototype.draftBack = draftBack; -Pattern.prototype.draftTail = draftTail; -Pattern.prototype.draftTopSleeve = draftTopSleeve; -Pattern.prototype.draftUnderSleeve = draftUnderSleeve; -Pattern.prototype.draftBelt = draftBelt; -Pattern.prototype.draftCollarStand = draftCollarStand; -Pattern.prototype.draftCollar = draftCollar; -Pattern.prototype.draftCuffFacing = draftCuffFacing; -Pattern.prototype.draftPocket = draftPocket; -Pattern.prototype.draftPocketFlap = draftPocketFlap; -Pattern.prototype.draftPocketLining = draftPocketLining; -Pattern.prototype.draftChestPocketWelt = draftChestPocketWelt; -Pattern.prototype.draftChestPocketBag = draftChestPocketBag; -Pattern.prototype.draftInnerPocketWelt = draftInnerPocketWelt; -Pattern.prototype.draftInnerPocketBag = draftInnerPocketBag; -Pattern.prototype.draftInnerPocketTab = draftInnerPocketTab; +Pattern.prototype.draftFront = draftFront +Pattern.prototype.draftBack = draftBack +Pattern.prototype.draftTail = draftTail +Pattern.prototype.draftTopSleeve = draftTopSleeve +Pattern.prototype.draftUnderSleeve = draftUnderSleeve +Pattern.prototype.draftBelt = draftBelt +Pattern.prototype.draftCollarStand = draftCollarStand +Pattern.prototype.draftCollar = draftCollar +Pattern.prototype.draftCuffFacing = draftCuffFacing +Pattern.prototype.draftPocket = draftPocket +Pattern.prototype.draftPocketFlap = draftPocketFlap +Pattern.prototype.draftPocketLining = draftPocketLining +Pattern.prototype.draftChestPocketWelt = draftChestPocketWelt +Pattern.prototype.draftChestPocketBag = draftChestPocketBag +Pattern.prototype.draftInnerPocketWelt = draftInnerPocketWelt +Pattern.prototype.draftInnerPocketBag = draftInnerPocketBag +Pattern.prototype.draftInnerPocketTab = draftInnerPocketTab -export default Pattern; +export default Pattern diff --git a/packages/carlton/src/innerpocketbag.js b/packages/carlton/src/innerpocketbag.js index cd25fe539df..04f1a8fdf92 100644 --- a/packages/carlton/src/innerpocketbag.js +++ b/packages/carlton/src/innerpocketbag.js @@ -1,23 +1,29 @@ export default function(part) { - let { units, paperless, sa, store, complete, points, options, macro, Point, paths, Path } = part.shorthand(); + let { + units, + paperless, + sa, + store, + complete, + points, + options, + macro, + Point, + paths, + Path + } = part.shorthand() - points.topLeft = new Point(0, 0); + points.topLeft = new Point(0, 0) points.bottomRight = new Point( - store.get("innerPocketWidth"), - store.get("innerPocketWidth") * options.innerPocketDepth / 2 - ); - points.bottomLeft = new Point( - points.topLeft.x, - points.bottomRight.y - ); - points.topRight = new Point( - points.bottomRight.x, - points.topLeft.y - ); - points.startLeft = points.topLeft.shiftFractionTowards(points.bottomLeft, 0.33); - points.endLeft = points.topLeft.shiftFractionTowards(points.bottomLeft, 0.66); - points.startRight = points.topRight.shiftFractionTowards(points.bottomRight, 0.33); - points.endRight = points.topRight.shiftFractionTowards(points.bottomRight, 0.66); + store.get('innerPocketWidth'), + (store.get('innerPocketWidth') * options.innerPocketDepth) / 2 + ) + points.bottomLeft = new Point(points.topLeft.x, points.bottomRight.y) + points.topRight = new Point(points.bottomRight.x, points.topLeft.y) + points.startLeft = points.topLeft.shiftFractionTowards(points.bottomLeft, 0.33) + points.endLeft = points.topLeft.shiftFractionTowards(points.bottomLeft, 0.66) + points.startRight = points.topRight.shiftFractionTowards(points.bottomRight, 0.33) + points.endRight = points.topRight.shiftFractionTowards(points.bottomRight, 0.66) paths.seam = new Path() .move(points.startRight) @@ -28,46 +34,45 @@ export default function(part) { .line(points.bottomLeft) .line(points.bottomRight) .line(points.endRight) - .attr("class", "lining"); + .attr('class', 'lining') paths.hint = new Path() .move(points.startLeft) .line(points.endLeft) .move(points.endRight) .line(points.startRight) - .attr("class", "lining dashed"); + .attr('class', 'lining dashed') if (complete) { - points.title = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5); - macro("title", { + points.title = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5) + macro('title', { at: points.title, nr: 14, - title: "innerPocketBag" - }); + title: 'innerPocketBag' + }) - macro("grainline", { + macro('grainline', { from: points.bottomLeft.shift(0, 10), to: points.topLeft.shift(0, 10) - }); + }) if (sa) { - paths.sa = paths.seam.offset(sa).attr("class", "lining sa"); + paths.sa = paths.seam.offset(sa).attr('class', 'lining sa') } - macro("ld", { + macro('ld', { from: points.bottomRight.shift(180, 15), to: points.topRight.shift(180, 15), - text: units(store.get("innerPocketWidth") * options.innerPocketDepth * 2) - - }); + text: units(store.get('innerPocketWidth') * options.innerPocketDepth * 2) + }) if (paperless) { - macro("hd", { + macro('hd', { from: points.bottomLeft, to: points.bottomRight, y: points.bottomLeft.y + sa + 15 - }); + }) } } - return part; + return part } diff --git a/packages/carlton/src/innerpockettab.js b/packages/carlton/src/innerpockettab.js index 72e6eabe205..49fe98ae0c4 100644 --- a/packages/carlton/src/innerpockettab.js +++ b/packages/carlton/src/innerpockettab.js @@ -1,19 +1,13 @@ export default function(part) { - let { paperless, sa, store, complete, points, macro, Point, paths, Path } = part.shorthand(); + let { paperless, sa, store, complete, points, macro, Point, paths, Path } = part.shorthand() - points.topLeft = new Point(0, 0); - points.topRight = new Point( - store.get("innerPocketWidth") * 1.2, - 0 - ); + points.topLeft = new Point(0, 0) + points.topRight = new Point(store.get('innerPocketWidth') * 1.2, 0) points.bottom = new Point( - store.get("innerPocketWidth") * 0.6, - store.get("innerPocketWidth") * 0.6, - ); - points.top = new Point( - store.get("innerPocketWidth") * 0.6, - 0 - ); + store.get('innerPocketWidth') * 0.6, + store.get('innerPocketWidth') * 0.6 + ) + points.top = new Point(store.get('innerPocketWidth') * 0.6, 0) paths.seam = new Path() .move(points.topLeft) @@ -21,46 +15,46 @@ export default function(part) { .line(points.topRight) .line(points.topLeft) .close() - .attr("class", "lining"); + .attr('class', 'lining') paths.hint = new Path() .move(points.top) .line(points.bottom) - .attr("class", "lining dashed"); + .attr('class', 'lining dashed') if (complete) { - points.title = points.top.shiftFractionTowards(points.bottom, 0.5); - macro("title", { + points.title = points.top.shiftFractionTowards(points.bottom, 0.5) + macro('title', { at: points.title, nr: 15, - title: "innerPocketTab" - }); + title: 'innerPocketTab' + }) - macro("grainline", { + macro('grainline', { from: points.top, - to: points.top.shift(-45, points.top.x*0.7) - }); + to: points.top.shift(-45, points.top.x * 0.7) + }) - if (sa) paths.sa = paths.seam.offset(sa).attr("class", "lining sa"); + if (sa) paths.sa = paths.seam.offset(sa).attr('class', 'lining sa') if (paperless) { - macro("hd", { + macro('hd', { from: points.topLeft, to: points.top, y: points.topLeft.y - sa - 15 - }); - macro("hd", { + }) + macro('hd', { from: points.topLeft, to: points.topRight, y: points.topLeft.y - sa - 30 - }); - macro("vd", { + }) + macro('vd', { from: points.bottom, to: points.topRight, x: points.topRight.x + sa + 15 - }); + }) } } - return part; + return part } diff --git a/packages/carlton/src/innerpocketwelt.js b/packages/carlton/src/innerpocketwelt.js index 5a3b87437b1..38077e96d9c 100644 --- a/packages/carlton/src/innerpocketwelt.js +++ b/packages/carlton/src/innerpocketwelt.js @@ -1,37 +1,22 @@ export default function(part) { - let { paperless, sa, store, complete, points, macro, Point, paths, Path } = part.shorthand(); + let { paperless, sa, store, complete, points, macro, Point, paths, Path } = part.shorthand() - points.topLeft = new Point(0, 0); + points.topLeft = new Point(0, 0) points.bottomRight = new Point( - store.get("innerPocketWidth") * 1.4, - store.get("innerPocketWeltHeight") * 6 - ); - points.bottomLeft = new Point( - points.topLeft.x, - points.bottomRight.y - ); - points.topRight = new Point( - points.bottomRight.x, - points.topLeft.y - ); - points.leftMid = new Point(0, points.bottomRight.y / 2); - points.rightMid = new Point(points.bottomRight.x, points.bottomRight.y / 2); + store.get('innerPocketWidth') * 1.4, + store.get('innerPocketWeltHeight') * 6 + ) + points.bottomLeft = new Point(points.topLeft.x, points.bottomRight.y) + points.topRight = new Point(points.bottomRight.x, points.topLeft.y) + points.leftMid = new Point(0, points.bottomRight.y / 2) + points.rightMid = new Point(points.bottomRight.x, points.bottomRight.y / 2) points.realTopLeft = new Point( - store.get("innerPocketWidth") * 0.2, - store.get("innerPocketWeltHeight") * 2 - ); - points.realTopRight = new Point( - store.get("innerPocketWidth") * 1.2, - points.realTopLeft.y - ); - points.realBottomLeft = new Point( - points.realTopLeft.x, - store.get("innerPocketWeltHeight") * 4 - ); - points.realBottomRight = new Point( - points.realTopRight.x, - points.realBottomLeft.y - ); + store.get('innerPocketWidth') * 0.2, + store.get('innerPocketWeltHeight') * 2 + ) + points.realTopRight = new Point(store.get('innerPocketWidth') * 1.2, points.realTopLeft.y) + points.realBottomLeft = new Point(points.realTopLeft.x, store.get('innerPocketWeltHeight') * 4) + points.realBottomRight = new Point(points.realTopRight.x, points.realBottomLeft.y) paths.seam = new Path() .move(points.topLeft) @@ -40,12 +25,12 @@ export default function(part) { .line(points.topRight) .line(points.topLeft) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') paths.fold = new Path() .move(points.leftMid) .line(points.rightMid) - .attr("class", "dashed"); + .attr('class', 'dashed') paths.welt = new Path() .move(points.realTopLeft) @@ -54,45 +39,45 @@ export default function(part) { .line(points.realTopRight) .line(points.realTopLeft) .close() - .attr("class", "lashed"); + .attr('class', 'lashed') if (complete) { - points.title = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5); - macro("title", { + points.title = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5) + macro('title', { at: points.title, nr: 13, - title: "innerPocketWelt" - }); + title: 'innerPocketWelt' + }) - macro("grainline", { + macro('grainline', { from: points.bottomLeft.shift(0, 10), to: points.topLeft.shift(0, 10) - }); + }) - if (sa) paths.sa = paths.seam.offset(sa).attr("class", "fabric sa"); + if (sa) paths.sa = paths.seam.offset(sa).attr('class', 'fabric sa') if (paperless) { - macro("vd", { + macro('vd', { from: points.realBottomRight, to: points.realTopRight, x: points.topRight.x + sa + 15 - }); - macro("vd", { + }) + macro('vd', { from: points.bottomRight, to: points.topRight, x: points.topRight.x + sa + 30 - }); - macro("hd", { + }) + macro('hd', { from: points.realBottomLeft, to: points.realBottomRight, y: points.bottomLeft.y + sa + 15 - }); - macro("hd", { + }) + macro('hd', { from: points.bottomLeft, to: points.bottomRight, y: points.bottomLeft.y + sa + 30 - }); + }) } } - return part; + return part } diff --git a/packages/carlton/src/pocket.js b/packages/carlton/src/pocket.js index 0167baa02c9..b27c581cc68 100644 --- a/packages/carlton/src/pocket.js +++ b/packages/carlton/src/pocket.js @@ -1,39 +1,38 @@ export default function(part) { - let { paperless, sa, store, complete, points, options, macro, Point, paths, Path } = part.shorthand(); + let { + paperless, + sa, + store, + complete, + points, + options, + macro, + Point, + paths, + Path + } = part.shorthand() - points.topLeft = new Point(0, 0); - points.bottomRight = new Point( - store.get("pocketWidth"), - store.get("pocketHeight") - ); - points.bottomLeft = new Point( - points.topLeft.x, - points.bottomRight.y - ); - points.topRight = new Point( - points.bottomRight.x, - points.topLeft.y - ); - points.edgeLeft = points.bottomLeft.shiftFractionTowards(points.topLeft, 1.25); - points.edgeRight = new Point( - points.topRight.x, - points.edgeLeft.y - ); + points.topLeft = new Point(0, 0) + points.bottomRight = new Point(store.get('pocketWidth'), store.get('pocketHeight')) + points.bottomLeft = new Point(points.topLeft.x, points.bottomRight.y) + points.topRight = new Point(points.bottomRight.x, points.topLeft.y) + points.edgeLeft = points.bottomLeft.shiftFractionTowards(points.topLeft, 1.25) + points.edgeRight = new Point(points.topRight.x, points.edgeLeft.y) if (options.pocketRadius > 0) { - macro("round", { + macro('round', { from: points.topLeft, to: points.bottomRight, via: points.bottomLeft, - radius: store.get("pocketRadius"), - prefix: "roundLeft" - }); - macro("round", { + radius: store.get('pocketRadius'), + prefix: 'roundLeft' + }) + macro('round', { from: points.bottomLeft, to: points.topRight, via: points.bottomRight, - radius: store.get("pocketRadius"), - prefix: "roundRight" - }); + radius: store.get('pocketRadius'), + prefix: 'roundRight' + }) paths.seam = new Path() .move(points.edgeLeft) @@ -42,63 +41,63 @@ export default function(part) { .line(points.roundRightStart) .curve(points.roundRightCp1, points.roundRightCp2, points.roundRightEnd) } else { - paths.seam = new Path() - .move(points.edgeLeft) - .line(points.bottomLeft) - .line(points.bottomRight); + paths.seam = new Path() + .move(points.edgeLeft) + .line(points.bottomLeft) + .line(points.bottomRight) } paths.seam = paths.seam .line(points.edgeRight) .line(points.edgeLeft) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') paths.fold = new Path() .move(points.topLeft) .line(points.topRight) - .attr("class", "fabric dashed"); + .attr('class', 'fabric dashed') if (complete) { - points.title = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5); - macro("title", { + points.title = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5) + macro('title', { at: points.title, nr: 10, - title: "pocket" - }); + title: 'pocket' + }) - macro("grainline", { - from: points.bottomLeft.shift(0, 10+ (store.get("pocketRadius") || 0)), - to: points.edgeLeft.shift(0, 10+ (store.get("pocketRadius") || 0)), - }); + macro('grainline', { + from: points.bottomLeft.shift(0, 10 + (store.get('pocketRadius') || 0)), + to: points.edgeLeft.shift(0, 10 + (store.get('pocketRadius') || 0)) + }) - if (sa) paths.sa = paths.seam.offset(sa).attr("class", "fabric sa"); + if (sa) paths.sa = paths.seam.offset(sa).attr('class', 'fabric sa') if (paperless) { - macro("vd", { + macro('vd', { from: points.bottomRight, to: points.topRight, x: points.topRight.x + sa + 15 - }); - macro("vd", { + }) + macro('vd', { from: points.bottomRight, to: points.edgeRight, x: points.topRight.x + sa + 30 - }); - macro("hd", { + }) + macro('hd', { from: points.edgeLeft, to: points.edgeRight, y: points.edgeRight.y - sa - 15 - }); + }) if (options.pocketRadius > 0) { - macro("hd", { + macro('hd', { from: points.roundRightStart, to: points.roundRightEnd, y: points.bottomRight.y + sa + 15 - }); + }) } } } - return part; + return part } diff --git a/packages/carlton/src/pocketflap.js b/packages/carlton/src/pocketflap.js index c053cf80e60..14ff2ce1ba5 100644 --- a/packages/carlton/src/pocketflap.js +++ b/packages/carlton/src/pocketflap.js @@ -1,34 +1,36 @@ export default function(part) { - let { paperless, sa, store, complete, points, options, macro, Point, paths, Path } = part.shorthand(); + let { + paperless, + sa, + store, + complete, + points, + options, + macro, + Point, + paths, + Path + } = part.shorthand() - points.topLeft = new Point(0, 0); - points.bottomRight = new Point( - store.get("pocketWidth"), - store.get("pocketFlapHeight") - ); - points.bottomLeft = new Point( - points.topLeft.x, - points.bottomRight.y - ); - points.topRight = new Point( - points.bottomRight.x, - points.topLeft.y - ); + points.topLeft = new Point(0, 0) + points.bottomRight = new Point(store.get('pocketWidth'), store.get('pocketFlapHeight')) + points.bottomLeft = new Point(points.topLeft.x, points.bottomRight.y) + points.topRight = new Point(points.bottomRight.x, points.topLeft.y) if (options.pocketFlapRadius > 0) { - macro("round", { + macro('round', { from: points.topLeft, to: points.bottomRight, via: points.bottomLeft, - radius: store.get("pocketFlapRadius"), - prefix: "roundLeft" - }); - macro("round", { + radius: store.get('pocketFlapRadius'), + prefix: 'roundLeft' + }) + macro('round', { from: points.bottomLeft, to: points.topRight, via: points.bottomRight, - radius: store.get("pocketFlapRadius"), - prefix: "roundRight" - }); + radius: store.get('pocketFlapRadius'), + prefix: 'roundRight' + }) paths.seam = new Path() .move(points.topLeft) @@ -37,63 +39,61 @@ export default function(part) { .line(points.roundRightStart) .curve(points.roundRightCp1, points.roundRightCp2, points.roundRightEnd) } else { - paths.seam = new Path() - .move(points.topLeft) - .line(points.bottomLeft) - .line(points.bottomRight); + paths.seam = new Path() + .move(points.topLeft) + .line(points.bottomLeft) + .line(points.bottomRight) } paths.seam = paths.seam .line(points.topRight) .line(points.topLeft) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') if (complete) { - points.title = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5); - macro("title", { + points.title = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5) + macro('title', { at: points.title, nr: 11, - title: "pocketFlap" - }); + title: 'pocketFlap' + }) - macro("grainline", { - from: points.bottomLeft.shift(0, points.topRight.x/5 ), - to: points.topLeft.shift(0, points.topRight.x/5) - }); + macro('grainline', { + from: points.bottomLeft.shift(0, points.topRight.x / 5), + to: points.topLeft.shift(0, points.topRight.x / 5) + }) if (sa) { - paths.sa = paths.seam.offset(sa).attr("class", "fabric sa"); + paths.sa = paths.seam.offset(sa).attr('class', 'fabric sa') } if (paperless) { - macro("hd", { + macro('hd', { from: points.topLeft, to: points.topRight, y: points.topLeft.y - sa - 15 - }); + }) if (options.pocketFlapRadius > 0) { - macro("vd", { + macro('vd', { from: points.roundRightStart, to: points.roundRightEnd, x: points.topRight.x + sa + 15 - }); - macro("vd", { + }) + macro('vd', { from: points.roundRightStart, to: points.topRight, x: points.topRight.x + sa + 30 - }); + }) } else { - macro("vd", { + macro('vd', { from: points.bottomRight, to: points.topRight, x: points.topRight.x + sa + 15 - }); + }) } - } } - - return part; + return part } diff --git a/packages/carlton/src/pocketlining.js b/packages/carlton/src/pocketlining.js index 66433348024..20e912b43cd 100644 --- a/packages/carlton/src/pocketlining.js +++ b/packages/carlton/src/pocketlining.js @@ -1,26 +1,34 @@ export default function(part) { - let { paperless, sa, store, complete, points, options, macro, Point, paths, Path } = part.shorthand(); + let { + paperless, + sa, + store, + complete, + points, + options, + macro, + Point, + paths, + Path + } = part.shorthand() - points.topLeft = points.bottomLeft.shiftFractionTowards(points.topLeft, 0.75); - points.topRight = new Point( - points.bottomRight.x, - points.topLeft.y - ); + points.topLeft = points.bottomLeft.shiftFractionTowards(points.topLeft, 0.75) + points.topRight = new Point(points.bottomRight.x, points.topLeft.y) if (options.pocketRadius > 0) { - macro("round", { + macro('round', { from: points.topLeft, to: points.bottomRight, via: points.bottomLeft, - radius: store.get("pocketRadius"), - prefix: "roundLeft" - }); - macro("round", { + radius: store.get('pocketRadius'), + prefix: 'roundLeft' + }) + macro('round', { from: points.bottomLeft, to: points.topRight, via: points.bottomRight, - radius: store.get("pocketRadius"), - prefix: "roundRight" - }); + radius: store.get('pocketRadius'), + prefix: 'roundRight' + }) paths.seam = new Path() .move(points.topLeft) @@ -29,55 +37,55 @@ export default function(part) { .line(points.roundRightStart) .curve(points.roundRightCp1, points.roundRightCp2, points.roundRightEnd) } else { - paths.seam = new Path() - .move(points.topLeft) - .line(points.bottomLeft) - .line(points.bottomRight); + paths.seam = new Path() + .move(points.topLeft) + .line(points.bottomLeft) + .line(points.bottomRight) } paths.seam = paths.seam .line(points.topRight) .line(points.topLeft) .close() - .attr("class", "lining"); + .attr('class', 'lining') - delete paths.fold; + delete paths.fold if (complete) { - points.title = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5); - macro("title", { + points.title = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5) + macro('title', { at: points.title, nr: 16, - title: "pocketLining" - }); + title: 'pocketLining' + }) - macro("grainline", { - from: points.bottomLeft.shift(0, 10+ (store.get("pocketRadius") || 0)), - to: points.topLeft.shift(0, 10+ (store.get("pocketRadius") || 0)), - }); + macro('grainline', { + from: points.bottomLeft.shift(0, 10 + (store.get('pocketRadius') || 0)), + to: points.topLeft.shift(0, 10 + (store.get('pocketRadius') || 0)) + }) - if (sa) paths.sa = paths.seam.offset(sa).attr("class", "lining sa"); + if (sa) paths.sa = paths.seam.offset(sa).attr('class', 'lining sa') if (paperless) { - macro("vd", { + macro('vd', { from: points.bottomRight, to: points.topRight, x: points.topRight.x + sa + 15 - }); - macro("hd", { + }) + macro('hd', { from: points.topLeft, to: points.topRight, y: points.topRight.y - sa - 15 - }); + }) if (options.pocketRadius > 0) { - macro("hd", { + macro('hd', { from: points.roundRightStart, to: points.roundRightEnd, y: points.bottomRight.y + sa + 15 - }); + }) } } } - return part; + return part } diff --git a/packages/carlton/src/shared.js b/packages/carlton/src/shared.js index 3168713e6e7..0e7abb2aa15 100644 --- a/packages/carlton/src/shared.js +++ b/packages/carlton/src/shared.js @@ -2,14 +2,14 @@ * This calculates a bunch of helper variables and stores them */ export const calculateRatios = part => { - let { store, measurements, options } = part.shorthand(); + let { store, measurements, options } = part.shorthand() // Calculate different values for reducing from chest to hips via waist - store.set("chest", measurements.chestCircumference * (1 + options.chestEase)); - store.set("waist", measurements.naturalWaist * (1 + options.waistEase)); - store.set("hips", measurements.hipsCircumference * (1 + options.hipsEase)); - store.set("seat", measurements.seatCircumference * (1 + options.seatEase)); + store.set('chest', measurements.chestCircumference * (1 + options.chestEase)) + store.set('waist', measurements.naturalWaist * (1 + options.waistEase)) + store.set('hips', measurements.hipsCircumference * (1 + options.hipsEase)) + store.set('seat', measurements.seatCircumference * (1 + options.seatEase)) - store.set("waistReduction", store.get("chest") - store.get("waist")); - store.set("hipsReduction", store.get("chest") - store.get("hips")); -}; + store.set('waistReduction', store.get('chest') - store.get('waist')) + store.set('hipsReduction', store.get('chest') - store.get('hips')) +} diff --git a/packages/carlton/src/tail.js b/packages/carlton/src/tail.js index fd87e718b7f..349b6502358 100644 --- a/packages/carlton/src/tail.js +++ b/packages/carlton/src/tail.js @@ -1,24 +1,35 @@ export default function(part) { - let { units, paperless, sa, store, complete, points, macro, Point, paths, Path } = part.shorthand(); + let { + units, + paperless, + sa, + store, + complete, + points, + macro, + Point, + paths, + Path + } = part.shorthand() - let length = store.get("waistToHem") - store.get("beltWidth")/2; + let length = store.get('waistToHem') - store.get('beltWidth') / 2 - points.cbTop = new Point(0,0); - points.fold1Top = points.cbTop.shift(0, store.get("cbToDart")/2); - points.fold2Top = points.cbTop.shift(0, store.get("cbToDart")); - points.fold3Top = points.cbTop.shift(0, store.get("cbToDart")*2); - points.fold4Top = points.fold3Top.shift(0, store.get("cbToDart")/2); - points.waistTop = points.fold4Top.shift(0, store.get("dartToSide")); + points.cbTop = new Point(0, 0) + points.fold1Top = points.cbTop.shift(0, store.get('cbToDart') / 2) + points.fold2Top = points.cbTop.shift(0, store.get('cbToDart')) + points.fold3Top = points.cbTop.shift(0, store.get('cbToDart') * 2) + points.fold4Top = points.fold3Top.shift(0, store.get('cbToDart') / 2) + points.waistTop = points.fold4Top.shift(0, store.get('dartToSide')) // 12cm will do as we're just drawing a rectangle. // But check that lenght > 12cm because doll clothes. - let drawnLength = length < 120 ? length : 120; + let drawnLength = length < 120 ? length : 120 - for (let i of ["cb", "fold1", "fold2", "fold3", "fold4", "waist"]) { - points[i+"Bottom"] = points[i+"Top"].shift(-90, drawnLength); - if (i === "cb" || i === "waist") { - points[i+"MidTop"] = points[i+"Top"].shift(-90, drawnLength * 0.4); - points[i+"MidBottom"] = points[i+"Top"].shift(-90, drawnLength * 0.6); + for (let i of ['cb', 'fold1', 'fold2', 'fold3', 'fold4', 'waist']) { + points[i + 'Bottom'] = points[i + 'Top'].shift(-90, drawnLength) + if (i === 'cb' || i === 'waist') { + points[i + 'MidTop'] = points[i + 'Top'].shift(-90, drawnLength * 0.4) + points[i + 'MidBottom'] = points[i + 'Top'].shift(-90, drawnLength * 0.6) } } @@ -32,7 +43,7 @@ export default function(part) { .move(points.waistMidTop) .line(points.waistTop) .line(points.cbTop) - .attr("class", "fabric"); + .attr('class', 'fabric') paths.folds = new Path() .move(points.fold1Top) @@ -43,69 +54,72 @@ export default function(part) { .line(points.fold3Bottom) .move(points.fold4Top) .line(points.fold4Bottom) - .attr("class", "lashed"); + .attr('class', 'lashed') paths.hint = new Path() .move(points.cbMidTop) .line(points.cbMidBottom) .move(points.waistMidBottom) .line(points.waistMidTop) - .attr("class", "fabric dashed"); + .attr('class', 'fabric dashed') if (complete) { - points.title = points.fold4Top.shiftFractionTowards(points.waistBottom, 0.5); - macro("title", { + points.title = points.fold4Top.shiftFractionTowards(points.waistBottom, 0.5) + macro('title', { at: points.title, nr: 3, - title: "tail" - }); + title: 'tail' + }) - macro("grainline", { + macro('grainline', { from: points.fold2Bottom.shift(0, 10), to: points.fold2Top.shift(0, 10) - }); + }) - if (sa) paths.sa = paths.seam.offset(sa).close().attr("class", "fabric sa"); - macro("vd", { + if (sa) + paths.sa = paths.seam + .offset(sa) + .close() + .attr('class', 'fabric sa') + macro('vd', { from: points.fold4Bottom.shift(0, 15), to: points.fold4Top.shift(0, 15), text: units(length) - }); + }) if (paperless) { - macro("hd", { + macro('hd', { from: points.cbBottom, to: points.fold1Bottom, y: points.cbBottom.y + sa + 15 - }); - macro("hd", { + }) + macro('hd', { from: points.fold1Bottom, to: points.fold2Bottom, y: points.cbBottom.y + sa + 15 - }); - macro("hd", { + }) + macro('hd', { from: points.fold2Bottom, to: points.fold3Bottom, y: points.cbBottom.y + sa + 15 - }); - macro("hd", { + }) + macro('hd', { from: points.fold3Bottom, to: points.fold4Bottom, y: points.cbBottom.y + sa + 15 - }); - macro("hd", { + }) + macro('hd', { from: points.fold4Bottom, to: points.waistBottom, y: points.cbBottom.y + sa + 15 - }); - macro("hd", { + }) + macro('hd', { from: points.cbBottom, to: points.waistBottom, y: points.cbBottom.y + sa + 30 - }); + }) } } - return part; + return part } - diff --git a/packages/carlton/src/topsleeve.js b/packages/carlton/src/topsleeve.js index 90151591d7b..d455050eda4 100644 --- a/packages/carlton/src/topsleeve.js +++ b/packages/carlton/src/topsleeve.js @@ -1,25 +1,36 @@ export default function(part) { - let { paperless, sa, store, complete, points, measurements, options, macro, paths, Path } = part.shorthand(); + let { + paperless, + sa, + store, + complete, + points, + measurements, + options, + macro, + paths, + Path + } = part.shorthand() // Add cuff - let length = measurements.shoulderToWrist * options.cuffLength; - let angle = points.tsWristRight.angle(points.tsWristLeft); - points.cuffBottomRight = points.tsWristRight.shift(angle+90, length); - points.cuffBottomLeft = points.tsWristLeft.shift(angle+90, length); - macro("round", { + let length = measurements.shoulderToWrist * options.cuffLength + let angle = points.tsWristRight.angle(points.tsWristLeft) + points.cuffBottomRight = points.tsWristRight.shift(angle + 90, length) + points.cuffBottomLeft = points.tsWristLeft.shift(angle + 90, length) + macro('round', { to: points.tsWristRight, from: points.cuffBottomLeft, via: points.cuffBottomRight, - radius: length/3, + radius: length / 3, render: true, - prefix: "round" - }); - store.set("topCuffWidth", points.tsWristLeft.dist(points.tsWristRight)); - store.set("cuffLength", length); - store.set("cuffRadius", length/3); + prefix: 'round' + }) + store.set('topCuffWidth', points.tsWristLeft.dist(points.tsWristRight)) + store.set('cuffLength', length) + store.set('cuffRadius', length / 3) // Clean up - for (let i in paths) delete paths[i]; + for (let i in paths) delete paths[i] // Paths paths.seam = new Path() @@ -37,90 +48,89 @@ export default function(part) { .curve(points.topCpLeft, points.frontPitchPointCpTop, points.frontPitchPoint) .curve(points.frontPitchPointCpBottom, points.tsLeftEdgeCpRight, points.tsLeftEdge) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') if (complete) { - - macro("grainline", { + macro('grainline', { from: points.boxBottom, to: points.top - }); + }) if (sa) { - paths.sa = paths.seam.offset(sa).attr("class", "fabric sa"); + paths.sa = paths.seam.offset(sa).attr('class', 'fabric sa') } if (paperless) { - macro("ld", { + macro('ld', { from: points.tsWristLeft, to: points.tsWristRight, d: -15 - }); - macro("vd", { + }) + macro('vd', { from: points.tsWristLeft, to: points.tsElbowLeft, x: points.tsLeftEdge.x - sa - 15 - }); - macro("vd", { + }) + macro('vd', { from: points.tsWristLeft, to: points.tsLeftEdge, x: points.tsLeftEdge.x - sa - 30 - }); - macro("ld", { + }) + macro('ld', { from: points.cuffBottomLeft, to: points.tsWristLeft, d: 15 + sa - }); - macro("vd", { + }) + macro('vd', { from: points.cuffBottomRight, to: points.usWristRight, x: points.usWristRight.x + 15 + sa - }); - macro("vd", { + }) + macro('vd', { from: points.usWristRight, to: points.elbowRight, x: points.elbowRight.x + 15 + sa - }); - macro("vd", { + }) + macro('vd', { from: points.usWristRight, to: points.tsRightEdge, x: points.elbowRight.x + 30 + sa - }); - macro("vd", { + }) + macro('vd', { from: points.usWristRight, to: points.backPitchPoint, x: points.elbowRight.x + 45 + sa - }); - macro("vd", { + }) + macro('vd', { from: points.usWristRight, to: points.top, x: points.elbowRight.x + 60 + sa - }); - macro("ld", { + }) + macro('ld', { from: points.tsElbowLeft, to: points.elbowRight - }); - macro("ld", { + }) + macro('ld', { from: points.tsLeftEdge, to: points.tsRightEdge - }); - macro("hd", { + }) + macro('hd', { from: points.tsLeftEdge, to: points.top, y: points.top.y - sa - 15 - }); - macro("hd", { + }) + macro('hd', { from: points.tsLeftEdge, to: points.backPitchPoint, y: points.top.y - sa - 30 - }); - macro("hd", { + }) + macro('hd', { from: points.tsLeftEdge, to: points.tsRightEdge, y: points.top.y - sa - 45 - }); + }) } } - return part; + return part } diff --git a/packages/carlton/src/undersleeve.js b/packages/carlton/src/undersleeve.js index 7709e003932..7ac202c1176 100644 --- a/packages/carlton/src/undersleeve.js +++ b/packages/carlton/src/undersleeve.js @@ -1,23 +1,35 @@ export default function(part) { - let { paperless, sa, store, complete, points, measurements, options, macro, Point, paths, Path } = part.shorthand(); + let { + paperless, + sa, + store, + complete, + points, + measurements, + options, + macro, + Point, + paths, + Path + } = part.shorthand() // Add cuff - let length = measurements.shoulderToWrist * options.cuffLength; - let angle = points.usWristRight.angle(points.usWristLeft); - points.cuffBottomRight = points.usWristRight.shift(angle+90, length); - points.cuffBottomLeft = points.usWristLeft.shift(angle+90, length); - macro("round", { + let length = measurements.shoulderToWrist * options.cuffLength + let angle = points.usWristRight.angle(points.usWristLeft) + points.cuffBottomRight = points.usWristRight.shift(angle + 90, length) + points.cuffBottomLeft = points.usWristLeft.shift(angle + 90, length) + macro('round', { to: points.usWristRight, from: points.cuffBottomLeft, via: points.cuffBottomRight, - radius: length/3, + radius: length / 3, render: true, - prefix: "round" - }); - store.set("underCuffWidth", points.usWristLeft.dist(points.usWristRight)); + prefix: 'round' + }) + store.set('underCuffWidth', points.usWristLeft.dist(points.usWristRight)) // Clean up - for (let i in paths) delete paths[i]; + for (let i in paths) delete paths[i] // Paths paths.seam = new Path() @@ -34,79 +46,75 @@ export default function(part) { .curve(points.usTipCpBottom, points.usLeftEdgeCpRight, points.usLeftEdgeRight) .line(points.usLeftEdge) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') if (complete) { - - macro("grainline", { + macro('grainline', { from: points.boxBottom, - to: new Point( - points.top.x, - points.usLeftEdge.y - ) - }); + to: new Point(points.top.x, points.usLeftEdge.y) + }) if (sa) { - paths.sa = paths.seam.offset(sa).attr("class", "fabric sa"); + paths.sa = paths.seam.offset(sa).attr('class', 'fabric sa') } if (paperless) { - macro("ld", { + macro('ld', { from: points.usWristLeft, to: points.usWristRight, d: -15 - }); - macro("vd", { + }) + macro('vd', { from: points.usWristLeft, to: points.usElbowLeft, x: points.usLeftEdge.x - sa - 15 - }); - macro("vd", { + }) + macro('vd', { from: points.usWristLeft, to: points.usLeftEdge, x: points.usLeftEdge.x - sa - 30 - }); - macro("ld", { + }) + macro('ld', { from: points.cuffBottomLeft, to: points.usWristLeft, d: 15 + sa - }); - macro("vd", { + }) + macro('vd', { from: points.cuffBottomRight, to: points.usWristRight, x: points.usWristRight.x + 15 + sa - }); - macro("vd", { + }) + macro('vd', { from: points.usWristRight, to: points.elbowRight, x: points.elbowRight.x + 15 + sa - }); - macro("vd", { + }) + macro('vd', { from: points.usWristRight, to: points.usTip, x: points.elbowRight.x + 30 + sa - }); - macro("ld", { + }) + macro('ld', { from: points.usElbowLeft, to: points.elbowRight - }); - macro("ld", { + }) + macro('ld', { from: points.usLeftEdge, to: points.usRightEdge, d: -15 - }); - macro("hd", { + }) + macro('hd', { from: points.usLeftEdge, to: points.usTip, y: points.usTip.y - sa - 15 - }); - macro("vd", { + }) + macro('vd', { from: points.usLeftEdge, to: points.usTip, x: points.usLeftEdge.x - sa - 15 - }); + }) } } - return part; + return part } diff --git a/packages/cathrin/example/src/App.js b/packages/cathrin/example/src/App.js index e7936330e5d..115cdf683af 100644 --- a/packages/cathrin/example/src/App.js +++ b/packages/cathrin/example/src/App.js @@ -1,22 +1,15 @@ -import React from "react"; -import freesewing from "@freesewing/core"; -import Workbench from "@freesewing/components/Workbench"; -import "typeface-roboto-condensed"; -import "@freesewing/css-theme"; +import React from 'react' +import freesewing from '@freesewing/core' +import Workbench from '@freesewing/components/Workbench' +import 'typeface-roboto-condensed' +import '@freesewing/css-theme' -import Pattern from "pattern"; +import Pattern from 'pattern' const App = props => { - let instance = new Pattern(); - let config = instance.config; - return ( - - ); -}; + let instance = new Pattern() + let config = instance.config + return +} -export default App; +export default App diff --git a/packages/cathrin/example/src/index.js b/packages/cathrin/example/src/index.js index 7900787a4d2..9dd7ba788d4 100644 --- a/packages/cathrin/example/src/index.js +++ b/packages/cathrin/example/src/index.js @@ -1,11 +1,11 @@ -import React from "react"; -import ReactDOM from "react-dom"; -import App from "./App"; -import * as serviceWorker from "./serviceWorker"; +import React from 'react' +import ReactDOM from 'react-dom' +import App from './App' +import * as serviceWorker from './serviceWorker' -ReactDOM.render(, document.getElementById("root")); +ReactDOM.render(, document.getElementById('root')) // If you want your app to work offline and load faster, you can change // unregister() to register() below. Note this comes with some pitfalls. // Learn more about service workers: http://bit.ly/CRA-PWA -serviceWorker.unregister(); +serviceWorker.unregister() diff --git a/packages/cathrin/example/src/serviceWorker.js b/packages/cathrin/example/src/serviceWorker.js index 68fda5a0eb6..44e1b1b2f8c 100644 --- a/packages/cathrin/example/src/serviceWorker.js +++ b/packages/cathrin/example/src/serviceWorker.js @@ -9,46 +9,44 @@ // This link also includes instructions on opting out of this behavior. const isLocalhost = Boolean( - window.location.hostname === "localhost" || + window.location.hostname === 'localhost' || // [::1] is the IPv6 localhost address. - window.location.hostname === "[::1]" || + window.location.hostname === '[::1]' || // 127.0.0.1/8 is considered localhost for IPv4. - window.location.hostname.match( - /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ - ) -); + window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/) +) export function register(config) { - if (process.env.NODE_ENV === "production" && "serviceWorker" in navigator) { + if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) { // The URL constructor is available in all browsers that support SW. - const publicUrl = new URL(process.env.PUBLIC_URL, window.location); + const publicUrl = new URL(process.env.PUBLIC_URL, window.location) if (publicUrl.origin !== window.location.origin) { // Our service worker won't work if PUBLIC_URL is on a different origin // from what our page is served on. This might happen if a CDN is used to // serve assets; see https://github.com/facebook/create-react-app/issues/2374 - return; + return } - window.addEventListener("load", () => { - const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; + window.addEventListener('load', () => { + const swUrl = `${process.env.PUBLIC_URL}/service-worker.js` if (isLocalhost) { // This is running on localhost. Let's check if a service worker still exists or not. - checkValidServiceWorker(swUrl, config); + checkValidServiceWorker(swUrl, config) // Add some additional logging to localhost, pointing developers to the // service worker/PWA documentation. navigator.serviceWorker.ready.then(() => { console.log( - "This web app is being served cache-first by a service " + - "worker. To learn more, visit https://goo.gl/SC7cgQ" - ); - }); + 'This web app is being served cache-first by a service ' + + 'worker. To learn more, visit https://goo.gl/SC7cgQ' + ) + }) } else { // Is not local host. Just register service worker - registerValidSW(swUrl, config); + registerValidSW(swUrl, config) } - }); + }) } } @@ -57,38 +55,38 @@ function registerValidSW(swUrl, config) { .register(swUrl) .then(registration => { registration.onupdatefound = () => { - const installingWorker = registration.installing; + const installingWorker = registration.installing installingWorker.onstatechange = () => { - if (installingWorker.state === "installed") { + if (installingWorker.state === 'installed') { if (navigator.serviceWorker.controller) { // At this point, the old content will have been purged and // the fresh content will have been added to the cache. // It's the perfect time to display a "New content is // available; please refresh." message in your web app. - console.log("New content is available; please refresh."); + console.log('New content is available; please refresh.') // Execute callback if (config.onUpdate) { - config.onUpdate(registration); + config.onUpdate(registration) } } else { // At this point, everything has been precached. // It's the perfect time to display a // "Content is cached for offline use." message. - console.log("Content is cached for offline use."); + console.log('Content is cached for offline use.') // Execute callback if (config.onSuccess) { - config.onSuccess(registration); + config.onSuccess(registration) } } } - }; - }; + } + } }) .catch(error => { - console.error("Error during service worker registration:", error); - }); + console.error('Error during service worker registration:', error) + }) } function checkValidServiceWorker(swUrl, config) { @@ -98,30 +96,28 @@ function checkValidServiceWorker(swUrl, config) { // Ensure service worker exists, and that we really are getting a JS file. if ( response.status === 404 || - response.headers.get("content-type").indexOf("javascript") === -1 + response.headers.get('content-type').indexOf('javascript') === -1 ) { // No service worker found. Probably a different app. Reload the page. navigator.serviceWorker.ready.then(registration => { registration.unregister().then(() => { - window.location.reload(); - }); - }); + window.location.reload() + }) + }) } else { // Service worker found. Proceed as normal. - registerValidSW(swUrl, config); + registerValidSW(swUrl, config) } }) .catch(() => { - console.log( - "No internet connection found. App is running in offline mode." - ); - }); + console.log('No internet connection found. App is running in offline mode.') + }) } export function unregister() { - if ("serviceWorker" in navigator) { + if ('serviceWorker' in navigator) { navigator.serviceWorker.ready.then(registration => { - registration.unregister(); - }); + registration.unregister() + }) } } diff --git a/packages/cathrin/src/base.js b/packages/cathrin/src/base.js index 33be3a9cd90..7c72270afc8 100644 --- a/packages/cathrin/src/base.js +++ b/packages/cathrin/src/base.js @@ -1,47 +1,27 @@ export default function(part) { - let { - measurements, - options, - store, - points, - paths, - Point, - Path, - utils, - debug - } = part.shorthand(); + let { measurements, options, store, points, paths, Point, Path, utils, debug } = part.shorthand() // Where to divide our corset into panels - if (options.panels === 11) store.set("gaps", [0.15, 0.275, 0.4, 0.6, 0.75]); - else store.set("gaps", [0.2, 0.35, 0.5, 0.65, 0.8]); + if (options.panels === 11) store.set('gaps', [0.15, 0.275, 0.4, 0.6, 0.75]) + else store.set('gaps', [0.2, 0.35, 0.5, 0.65, 0.8]) // Absolute values for some options - store.set( - "waistReduction", - measurements.naturalWaist * options.waistReduction - ); + store.set('waistReduction', measurements.naturalWaist * options.waistReduction) debug({ - type: "info", - label: "✅ Waist reduction", - msg: utils.units(store.get("waistReduction")) - }); - store.set("backOpening", measurements.underbust * options.backOpening); + type: 'info', + label: '✅ Waist reduction', + msg: utils.units(store.get('waistReduction')) + }) + store.set('backOpening', measurements.underbust * options.backOpening) debug({ - type: "info", - label: "✅ Back opening", - msg: utils.units(store.get("backOpening")) - }); - let len = - measurements.naturalWaistToUnderbust + measurements.naturalWaistToHip; - for (let option of [ - "backRise", - "backDrop", - "frontRise", - "frontDrop", - "hipRise" - ]) - store.set(option, len * options[option]); - store.set("length", len); + type: 'info', + label: '✅ Back opening', + msg: utils.units(store.get('backOpening')) + }) + let len = measurements.naturalWaistToUnderbust + measurements.naturalWaistToHip + for (let option of ['backRise', 'backDrop', 'frontRise', 'frontDrop', 'hipRise']) + store.set(option, len * options[option]) + store.set('length', len) /** * How much should we take in the corset at waist and bust @@ -50,62 +30,47 @@ export default function(part) { * Can I be sure? Maybe not, but a larger underbust than hip * measurements seems very rare to say the least. */ + store.set('width', 0.5 * (measurements.hipsCircumference - store.get('backOpening'))) store.set( - "width", - 0.5 * (measurements.hipsCircumference - store.get("backOpening")) - ); - store.set( - "waistIntake", - 0.5 * - (measurements.hipsCircumference - - measurements.naturalWaist + - store.get("waistReduction")) - ); - store.set( - "bustIntake", - 0.5 * (measurements.hipsCircumference - measurements.underbust) - ); + 'waistIntake', + 0.5 * (measurements.hipsCircumference - measurements.naturalWaist + store.get('waistReduction')) + ) + store.set('bustIntake', 0.5 * (measurements.hipsCircumference - measurements.underbust)) // Basic box (CB = Center back, CF = Center front) - let wid = store.get("width"); - points.underbustCF = new Point(0, 0); - points.hipsCF = new Point(0, len); - points.hipsCB = new Point(wid, len); - points.underbustCB = new Point(wid, 0); - points.topSide = points.underbustCF.shiftFractionTowards( - points.underbustCB, - 0.5 - ); - points.bottomSide = points.hipsCF.shiftFractionTowards(points.hipsCB, 0.5); - points.waistCF = points.underbustCF.shift( - -90, - measurements.naturalWaistToUnderbust - ); - points.waistCB = new Point(points.hipsCB.x, points.waistCF.y); + let wid = store.get('width') + points.underbustCF = new Point(0, 0) + points.hipsCF = new Point(0, len) + points.hipsCB = new Point(wid, len) + points.underbustCB = new Point(wid, 0) + points.topSide = points.underbustCF.shiftFractionTowards(points.underbustCB, 0.5) + points.bottomSide = points.hipsCF.shiftFractionTowards(points.hipsCB, 0.5) + points.waistCF = points.underbustCF.shift(-90, measurements.naturalWaistToUnderbust) + points.waistCB = new Point(points.hipsCB.x, points.waistCF.y) // frontRise - points.topCF = points.underbustCF.shift(90, store.get("frontRise")); - points.frontRiseStart = points.underbustCF.shift(0, wid * 0.15); - points.frontRiseStartCp2 = points.underbustCF.shift(0, wid * 0.11); - points.topCFCp1 = points.topCF.shift(0, wid * 0.11); + points.topCF = points.underbustCF.shift(90, store.get('frontRise')) + points.frontRiseStart = points.underbustCF.shift(0, wid * 0.15) + points.frontRiseStartCp2 = points.underbustCF.shift(0, wid * 0.11) + points.topCFCp1 = points.topCF.shift(0, wid * 0.11) // frontDrop - points.bottomCF = points.hipsCF.shift(-90, store.get("frontDrop")); - points.bottomCFCp2 = points.bottomCF.shift(0, wid * 0.11); + points.bottomCF = points.hipsCF.shift(-90, store.get('frontDrop')) + points.bottomCFCp2 = points.bottomCF.shift(0, wid * 0.11) // hipRise - points.hipRise = points.bottomSide.shift(90, store.get("hipRise")); - points.hipRiseCp1 = points.hipRise.shift(180, wid * 0.3); - points.hipRiseCp2 = points.hipRise.shift(0, wid * 0.2); + points.hipRise = points.bottomSide.shift(90, store.get('hipRise')) + points.hipRiseCp1 = points.hipRise.shift(180, wid * 0.3) + points.hipRiseCp2 = points.hipRise.shift(0, wid * 0.2) // backDrop - points.backDrop = points.hipsCB.shift(-90, store.get("backDrop")); - points.backDropCp1 = points.backDrop.shift(180, wid * 0.3); + points.backDrop = points.hipsCB.shift(-90, store.get('backDrop')) + points.backDropCp1 = points.backDrop.shift(180, wid * 0.3) // backRise - points.backRise = points.underbustCB.shift(90, store.get("backRise")); - points.backRiseCp1 = points.backRise.shift(180, wid * 0.4); - points.topSideCp1 = points.topSide.shift(0, wid * 0.2); + points.backRise = points.underbustCB.shift(90, store.get('backRise')) + points.backRiseCp1 = points.backRise.shift(180, wid * 0.4) + points.topSideCp1 = points.topSide.shift(0, wid * 0.2) // Paths paths.help1 = new Path() @@ -113,14 +78,14 @@ export default function(part) { .line(points.hipsCF) .line(points.hipsCB) .line(points.underbustCB) - .close(); + .close() paths.help2 = new Path() .move(points.topSide) .line(points.bottomSide) .line(points.waistCF) - .line(points.waistCB); - paths.help1.render = false; - paths.help2.render = false; + .line(points.waistCB) + paths.help1.render = false + paths.help2.render = false paths.outline = new Path() .move(points.bottomCF) @@ -131,7 +96,7 @@ export default function(part) { .line(points.frontRiseStart) .curve(points.frontRiseStartCp2, points.topCFCp1, points.topCF) .line(points.bottomCF) - .close(); + .close() - return part; + return part } diff --git a/packages/cathrin/src/index.js b/packages/cathrin/src/index.js index 72f7a88004a..61c59f1b9d9 100644 --- a/packages/cathrin/src/index.js +++ b/packages/cathrin/src/index.js @@ -1,27 +1,27 @@ -import freesewing from "@freesewing/core"; -import plugins from "@freesewing/plugin-bundle"; -import config from "../config"; +import freesewing from '@freesewing/core' +import plugins from '@freesewing/plugin-bundle' +import config from '../config' //Parts -import draftBase from "./base"; -import draftPanels from "./panels"; -import draftPanel1 from "./panel1"; -import draftPanel2 from "./panel2"; -import draftPanel3 from "./panel3"; -import draftPanel4 from "./panel4"; -import draftPanel5 from "./panel5"; -import draftPanel6 from "./panel6"; +import draftBase from './base' +import draftPanels from './panels' +import draftPanel1 from './panel1' +import draftPanel2 from './panel2' +import draftPanel3 from './panel3' +import draftPanel4 from './panel4' +import draftPanel5 from './panel5' +import draftPanel6 from './panel6' // Create design -const Pattern = new freesewing.Design(config, plugins); +const Pattern = new freesewing.Design(config, plugins) // Attach draft methods to prototype -Pattern.prototype.draftBase = draftBase; -Pattern.prototype.draftPanels = draftPanels; -Pattern.prototype.draftPanel1 = draftPanel1; -Pattern.prototype.draftPanel2 = draftPanel2; -Pattern.prototype.draftPanel3 = draftPanel3; -Pattern.prototype.draftPanel4 = draftPanel4; -Pattern.prototype.draftPanel5 = draftPanel5; -Pattern.prototype.draftPanel6 = draftPanel6; +Pattern.prototype.draftBase = draftBase +Pattern.prototype.draftPanels = draftPanels +Pattern.prototype.draftPanel1 = draftPanel1 +Pattern.prototype.draftPanel2 = draftPanel2 +Pattern.prototype.draftPanel3 = draftPanel3 +Pattern.prototype.draftPanel4 = draftPanel4 +Pattern.prototype.draftPanel5 = draftPanel5 +Pattern.prototype.draftPanel6 = draftPanel6 -export default Pattern; +export default Pattern diff --git a/packages/cathrin/src/panel1.js b/packages/cathrin/src/panel1.js index c6338e3ecdc..0655595b5b1 100644 --- a/packages/cathrin/src/panel1.js +++ b/packages/cathrin/src/panel1.js @@ -1,73 +1,70 @@ -import draftPanel1ab from "./panel1ab"; +import draftPanel1ab from './panel1ab' export default function(part) { - let { macro, sa, paths, options, complete, paperless } = part.shorthand(); + let { macro, sa, paths, options, complete, paperless } = part.shorthand() - delete paths.outline; - delete paths.panel2; - delete paths.panel3; - delete paths.panel4; - delete paths.panel5; - delete paths.panel6; + delete paths.outline + delete paths.panel2 + delete paths.panel3 + delete paths.panel4 + delete paths.panel5 + delete paths.panel6 - if (options.panels === 13) return draftPanel1ab(part); + if (options.panels === 13) return draftPanel1ab(part) // Complete pattern? if (complete) { - macro("cutonfold", { + macro('cutonfold', { to: points.bottomCF, from: points.topCF, grainline: true - }); - points.title = points.waistCF.shiftFractionTowards( - points.underbustGap1Left, - 0.5 - ); - macro("title", { + }) + points.title = points.waistCF.shiftFractionTowards(points.underbustGap1Left, 0.5) + macro('title', { nr: 1, - title: "", + title: '', at: points.title - }); - if (sa) paths.sa = paths.panel1.offset(sa).attr("class", "fabric sa"); + }) + if (sa) paths.sa = paths.panel1.offset(sa).attr('class', 'fabric sa') } // Paperless? if (paperless) { - macro("vd", { + macro('vd', { from: points.bottomCF, to: points.waistCF, x: points.topCF.x - sa - 15 - }); - macro("vd", { + }) + macro('vd', { from: points.waistCF, to: points.topCF, x: points.topCF.x - sa - 15 - }); - macro("vd", { + }) + macro('vd', { from: points.hipsGap1, to: points.waistGap1Left, x: points.hipsGap1.x + sa + 15 - }); - macro("vd", { + }) + macro('vd', { from: points.waistGap1Left, to: points.underbustGap1Left, x: points.hipsGap1.x + sa + 15 - }); - macro("hd", { + }) + macro('hd', { from: points.bottomCF, to: points.hipsGap1, y: points.bottomCF.y + sa + 15 - }); - macro("hd", { + }) + macro('hd', { from: points.topCF, to: points.underbustGap1Left, y: points.topCF.y - sa - 15 - }); - macro("ld", { + }) + macro('ld', { from: points.waistCF, to: points.waistGap1Left - }); + }) } - return part; + return part } diff --git a/packages/cathrin/src/panel1ab.js b/packages/cathrin/src/panel1ab.js index 37fa6c0d5a7..1a0cd533803 100644 --- a/packages/cathrin/src/panel1ab.js +++ b/packages/cathrin/src/panel1ab.js @@ -1,28 +1,14 @@ export default function(part) { - let { - macro, - utils, - sa, - points, - paths, - Point, - Path, - complete, - paperless - } = part.shorthand(); + let { macro, utils, sa, points, paths, Point, Path, complete, paperless } = part.shorthand() let top = new Path() .move(points.underbustGap1Left) - .curve(points.frontRiseStartCp2, points.topCFCp1, points.topCF); - points.topABsplit = top.shiftFractionAlong(0.3); + .curve(points.frontRiseStartCp2, points.topCFCp1, points.topCF) + points.topABsplit = top.shiftFractionAlong(0.3) let bottom = new Path() .move(points.bottomCF) - .curve( - paths.panel1.ops[1].cp1, - paths.panel1.ops[1].cp2, - paths.panel1.ops[1].to - ); - points.bottomABsplit = bottom.shiftFractionAlong(0.3); + .curve(paths.panel1.ops[1].cp1, paths.panel1.ops[1].cp2, paths.panel1.ops[1].to) + points.bottomABsplit = bottom.shiftFractionAlong(0.3) paths.panel1a = bottom .split(points.bottomABsplit)[0] @@ -30,144 +16,134 @@ export default function(part) { .join(top.split(points.topABsplit)[1]) .line(points.bottomCF) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') paths.panel1b = bottom .split(points.bottomABsplit)[1] .curve(points.hipsGap1Cp, points.waistGap1LeftCp1, points.waistGap1Left) - .curve( - points.waistGap1LeftCp2, - points.underbustGap1LeftCp, - points.underbustGap1Left - ) + .curve(points.waistGap1LeftCp2, points.underbustGap1LeftCp, points.underbustGap1Left) .join(top.split(points.topABsplit)[0]) .line(points.bottomABsplit) .close() - .attr("class", "fabric"); - let translation = 5; - if (sa) translation = 2 * sa + 5; - paths.panel1b = paths.panel1b.translate(translation, 0); - delete paths.panel1; + .attr('class', 'fabric') + let translation = 5 + if (sa) translation = 2 * sa + 5 + paths.panel1b = paths.panel1b.translate(translation, 0) + delete paths.panel1 // Complete pattern? if (complete) { if (sa) { - paths.saA = paths.panel1a.offset(sa).attr("class", "fabric sa"); - paths.saB = paths.panel1b.offset(sa).attr("class", "fabric sa"); + paths.saA = paths.panel1a.offset(sa).attr('class', 'fabric sa') + paths.saB = paths.panel1b.offset(sa).attr('class', 'fabric sa') } - macro("cutonfold", { + macro('cutonfold', { to: points.bottomCF, from: points.topCF, grainline: true - }); - macro("grainline", { + }) + macro('grainline', { to: points.topABsplit.translate(translation, 0), from: new Point( points.topABsplit.translate(translation, 0).x, points.hipsGap1.translate(translation, 0).y ) - }); - points.midwayAB = points.topABsplit.shiftFractionTowards( - points.bottomABsplit, - 0.5 - ); - points.titleA = points.underbustCF.shiftFractionTowards( - points.midwayAB, - 0.5 - ); - macro("title", { - nr: "1a", - prefix: "panel1a", + }) + points.midwayAB = points.topABsplit.shiftFractionTowards(points.bottomABsplit, 0.5) + points.titleA = points.underbustCF.shiftFractionTowards(points.midwayAB, 0.5) + macro('title', { + nr: '1a', + prefix: 'panel1a', at: points.titleA - }); + }) points.titleB = points.hipsGap1 .translate(translation, 0) - .shiftFractionTowards(points.midwayAB, 0.5); - macro("title", { - nr: "1b", - prefix: "panel1b", + .shiftFractionTowards(points.midwayAB, 0.5) + macro('title', { + nr: '1b', + prefix: 'panel1b', at: points.titleB - }); + }) } // Paperless? if (paperless) { // 1a - macro("vd", { + macro('vd', { from: points.bottomCF, to: points.waistCF, x: points.topCF.x - sa - 30 - }); - macro("vd", { + }) + macro('vd', { from: points.waistCF, to: points.topCF, x: points.topCF.x - sa - 30 - }); + }) points.waistAB = utils.beamsIntersect( points.topABsplit, points.bottomABsplit, points.waistCF, points.waistGap1 - ); - macro("vd", { + ) + macro('vd', { from: points.bottomABsplit, to: points.waistAB, x: points.topCF.x - sa - 15 - }); - macro("vd", { + }) + macro('vd', { from: points.waistAB, to: points.topABsplit, x: points.topCF.x - sa - 15 - }); - macro("hd", { + }) + macro('hd', { from: points.bottomCF, to: points.bottomABsplit, y: points.bottomCF.y + sa + 15 - }); - macro("ld", { + }) + macro('ld', { from: points.waistCF, to: points.waistAB - }); - macro("hd", { + }) + macro('hd', { from: points.topCF, to: points.topABsplit, y: points.topCF.y - sa - 15 - }); + }) // 1b - macro("vd", { + macro('vd', { from: points.hipsGap1.translate(translation, 0), to: points.waistGap1Left.translate(translation, 0), x: points.underbustGap1Left.translate(translation, 0).x + sa + 15 - }); - macro("vd", { + }) + macro('vd', { from: points.waistGap1Left.translate(translation, 0), to: points.underbustGap1Left.translate(translation, 0), x: points.underbustGap1Left.translate(translation, 0).x + sa + 15 - }); - macro("vd", { + }) + macro('vd', { from: points.bottomABsplit.translate(translation, 0), to: points.waistAB.translate(translation, 0), x: points.underbustGap1Left.translate(translation, 0).x + sa + 30 - }); - macro("vd", { + }) + macro('vd', { from: points.waistAB.translate(translation, 0), to: points.topABsplit.translate(translation, 0), x: points.underbustGap1Left.translate(translation, 0).x + sa + 30 - }); - macro("hd", { + }) + macro('hd', { from: points.bottomABsplit.translate(translation, 0), to: points.hipsGap1.translate(translation, 0), y: points.bottomABsplit.y + sa + 15 - }); - macro("ld", { + }) + macro('ld', { from: points.waistAB.translate(translation, 0), to: points.waistGap1Left.translate(translation, 0) - }); - macro("hd", { + }) + macro('hd', { from: points.topABsplit.translate(translation, 0), to: points.underbustGap1Left.translate(translation, 0), y: points.topABsplit.y - sa - 15 - }); + }) } - return part; + return part } diff --git a/packages/cathrin/src/panel2.js b/packages/cathrin/src/panel2.js index 8e2d83574b7..0ea53cb91ce 100644 --- a/packages/cathrin/src/panel2.js +++ b/packages/cathrin/src/panel2.js @@ -1,84 +1,70 @@ export default function(part) { - let { - macro, - sa, - points, - paths, - Point, - complete, - paperless - } = part.shorthand(); + let { macro, sa, points, paths, Point, complete, paperless } = part.shorthand() - delete paths.outline; - delete paths.panel1; - delete paths.panel3; - delete paths.panel4; - delete paths.panel5; - delete paths.panel6; + delete paths.outline + delete paths.panel1 + delete paths.panel3 + delete paths.panel4 + delete paths.panel5 + delete paths.panel6 // Complete pattern? if (complete) { points.grainlineTop = new Point( points.waistGap1Right.shiftFractionTowards(points.waistGap2Left, 0.5).x, points.underbustGap1Right.y - ); - points.grainlineBottom = new Point( - points.grainlineTop.x, - points.hipsGap2.y - ); - macro("grainline", { + ) + points.grainlineBottom = new Point(points.grainlineTop.x, points.hipsGap2.y) + macro('grainline', { from: points.grainlineBottom, to: points.grainlineTop - }); - points.title = points.grainlineTop.shift( - -90, - points.grainlineTop.dy(points.waistGap2Left) / 2 - ); - macro("title", { + }) + points.title = points.grainlineTop.shift(-90, points.grainlineTop.dy(points.waistGap2Left) / 2) + macro('title', { nr: 2, - title: "", + title: '', at: points.title - }); - if (sa) paths.sa = paths.panel2.offset(sa).attr("class", "fabric sa"); + }) + if (sa) paths.sa = paths.panel2.offset(sa).attr('class', 'fabric sa') } // Paperless? if (paperless) { - macro("hd", { + macro('hd', { from: points.hipsGap1, to: points.hipsGap2, y: points.hipsGap1.y + sa + 15 - }); - macro("ld", { + }) + macro('ld', { from: points.waistGap1Right, to: points.waistGap2Left - }); - macro("hd", { + }) + macro('hd', { from: points.underbustGap1Right, to: points.underbustGap2Left, y: points.underbustGap1Right.y - sa - 15 - }); - macro("vd", { + }) + macro('vd', { from: points.hipsGap1, to: points.waistGap1Right, x: points.hipsGap1.x - sa - 15 - }); - macro("vd", { + }) + macro('vd', { from: points.waistGap1Right, to: points.underbustGap1Right, x: points.hipsGap1.x - sa - 15 - }); - macro("vd", { + }) + macro('vd', { from: points.hipsGap2, to: points.waistGap1Right, x: points.hipsGap2.x + sa + 15 - }); - macro("vd", { + }) + macro('vd', { from: points.waistGap1Right, to: points.underbustGap2Left, x: points.hipsGap2.x + sa + 15 - }); + }) } - return part; + return part } diff --git a/packages/cathrin/src/panel3.js b/packages/cathrin/src/panel3.js index e5204bc155e..96cab4dca95 100644 --- a/packages/cathrin/src/panel3.js +++ b/packages/cathrin/src/panel3.js @@ -1,84 +1,70 @@ export default function(part) { - let { - macro, - sa, - points, - paths, - Point, - complete, - paperless - } = part.shorthand(); + let { macro, sa, points, paths, Point, complete, paperless } = part.shorthand() - delete paths.outline; - delete paths.panel1; - delete paths.panel2; - delete paths.panel4; - delete paths.panel5; - delete paths.panel6; + delete paths.outline + delete paths.panel1 + delete paths.panel2 + delete paths.panel4 + delete paths.panel5 + delete paths.panel6 // Complete pattern? if (complete) { points.grainlineTop = new Point( points.waistGap2Right.shiftFractionTowards(points.waistGap3Left, 0.5).x, points.underbustGap2Right.y - ); - points.grainlineBottom = new Point( - points.grainlineTop.x, - points.hipsGap3.y - ); - macro("grainline", { + ) + points.grainlineBottom = new Point(points.grainlineTop.x, points.hipsGap3.y) + macro('grainline', { from: points.grainlineBottom, to: points.grainlineTop - }); - points.title = points.grainlineTop.shift( - -90, - points.grainlineTop.dy(points.waistGap3Left) / 2 - ); - macro("title", { + }) + points.title = points.grainlineTop.shift(-90, points.grainlineTop.dy(points.waistGap3Left) / 2) + macro('title', { nr: 3, - title: "", + title: '', at: points.title - }); - if (sa) paths.sa = paths.panel3.offset(sa).attr("class", "fabric sa"); + }) + if (sa) paths.sa = paths.panel3.offset(sa).attr('class', 'fabric sa') } // Paperless? if (paperless) { - macro("hd", { + macro('hd', { from: points.hipsGap2, to: points.hipsGap3, y: points.hipsGap2.y + sa + 15 - }); - macro("ld", { + }) + macro('ld', { from: points.waistGap2Right, to: points.waistGap3Left - }); - macro("hd", { + }) + macro('hd', { from: points.underbustGap2Right, to: points.underbustGap3Left, y: points.underbustGap2Right.y - sa - 15 - }); - macro("vd", { + }) + macro('vd', { from: points.hipsGap2, to: points.waistGap2Right, x: points.hipsGap2.x - sa - 15 - }); - macro("vd", { + }) + macro('vd', { from: points.waistGap2Right, to: points.underbustGap2Right, x: points.hipsGap2.x - sa - 15 - }); - macro("vd", { + }) + macro('vd', { from: points.hipsGap3, to: points.waistGap2Right, x: points.hipsGap3.x + sa + 15 - }); - macro("vd", { + }) + macro('vd', { from: points.waistGap2Right, to: points.underbustGap3Left, x: points.hipsGap3.x + sa + 15 - }); + }) } - return part; + return part } diff --git a/packages/cathrin/src/panel4.js b/packages/cathrin/src/panel4.js index 1bef21891d1..119d704c2ad 100644 --- a/packages/cathrin/src/panel4.js +++ b/packages/cathrin/src/panel4.js @@ -1,92 +1,73 @@ export default function(part) { - let { - macro, - sa, - snippets, - Snippet, - points, - paths, - Point, - complete, - paperless - } = part.shorthand(); + let { macro, sa, snippets, Snippet, points, paths, Point, complete, paperless } = part.shorthand() - delete paths.outline; - delete paths.panel1; - delete paths.panel2; - delete paths.panel3; - delete paths.panel5; - delete paths.panel6; + delete paths.outline + delete paths.panel1 + delete paths.panel2 + delete paths.panel3 + delete paths.panel5 + delete paths.panel6 // Complete pattern? if (complete) { points.grainlineTop = new Point( points.waistGap3Right.shiftFractionTowards(points.waistGap4Left, 0.5).x, points.underbustGap3Right.y - ); - points.grainlineBottom = new Point( - points.grainlineTop.x, - points.hipsGap4.y - ); - macro("grainline", { + ) + points.grainlineBottom = new Point(points.grainlineTop.x, points.hipsGap4.y) + macro('grainline', { from: points.grainlineBottom, to: points.grainlineTop - }); - points.title = points.grainlineTop.shift( - -90, - points.grainlineTop.dy(points.waistGap4Left) / 2 - ); - macro("title", { + }) + points.title = points.grainlineTop.shift(-90, points.grainlineTop.dy(points.waistGap4Left) / 2) + macro('title', { nr: 4, - title: "", + title: '', at: points.title - }); - points.logo = points.grainlineTop.shiftFractionTowards( - points.grainlineBottom, - 0.8 - ); - snippets.logo = new Snippet("logo", points.logo).attr("data-scale", 0.8); + }) + points.logo = points.grainlineTop.shiftFractionTowards(points.grainlineBottom, 0.8) + snippets.logo = new Snippet('logo', points.logo).attr('data-scale', 0.8) - if (sa) paths.sa = paths.panel4.offset(sa).attr("class", "fabric sa"); + if (sa) paths.sa = paths.panel4.offset(sa).attr('class', 'fabric sa') } // Paperless? if (paperless) { - macro("hd", { + macro('hd', { from: points.hipsGap3, to: points.hipsGap4, y: points.hipsGap3.y + sa + 15 - }); - macro("ld", { + }) + macro('ld', { from: points.waistGap3Right, to: points.waistGap4Left - }); - macro("hd", { + }) + macro('hd', { from: points.underbustGap3Right, to: points.underbustGap4Left, y: points.underbustGap4Left.y - sa - 15 - }); - macro("vd", { + }) + macro('vd', { from: points.hipsGap3, to: points.waistGap3Right, x: points.hipsGap3.x - sa - 15 - }); - macro("vd", { + }) + macro('vd', { from: points.waistGap3Right, to: points.underbustGap3Right, x: points.hipsGap3.x - sa - 15 - }); - macro("vd", { + }) + macro('vd', { from: points.hipsGap4, to: points.waistGap3Right, x: points.hipsGap4.x + sa + 15 - }); - macro("vd", { + }) + macro('vd', { from: points.waistGap3Right, to: points.underbustGap4Left, x: points.hipsGap4.x + sa + 15 - }); + }) } - return part; + return part } diff --git a/packages/cathrin/src/panel5.js b/packages/cathrin/src/panel5.js index 84757155c55..89cbd51ccde 100644 --- a/packages/cathrin/src/panel5.js +++ b/packages/cathrin/src/panel5.js @@ -1,84 +1,70 @@ export default function(part) { - let { - macro, - sa, - points, - paths, - Point, - complete, - paperless - } = part.shorthand(); + let { macro, sa, points, paths, Point, complete, paperless } = part.shorthand() - delete paths.outline; - delete paths.panel1; - delete paths.panel2; - delete paths.panel3; - delete paths.panel4; - delete paths.panel6; + delete paths.outline + delete paths.panel1 + delete paths.panel2 + delete paths.panel3 + delete paths.panel4 + delete paths.panel6 // Complete pattern? if (complete) { points.grainlineTop = new Point( points.waistGap4Right.shiftFractionTowards(points.waistGap5Left, 0.5).x, points.underbustGap4Right.y - ); - points.grainlineBottom = new Point( - points.grainlineTop.x, - points.hipsGap5.y - ); - macro("grainline", { + ) + points.grainlineBottom = new Point(points.grainlineTop.x, points.hipsGap5.y) + macro('grainline', { from: points.grainlineBottom, to: points.grainlineTop - }); - points.title = points.grainlineTop.shift( - -90, - points.grainlineTop.dy(points.waistGap5Left) / 2 - ); - macro("title", { + }) + points.title = points.grainlineTop.shift(-90, points.grainlineTop.dy(points.waistGap5Left) / 2) + macro('title', { nr: 5, - title: "", + title: '', at: points.title - }); - if (sa) paths.sa = paths.panel5.offset(sa).attr("class", "fabric sa"); + }) + if (sa) paths.sa = paths.panel5.offset(sa).attr('class', 'fabric sa') } // Paperless? if (paperless) { - macro("hd", { + macro('hd', { from: points.hipsGap4, to: points.hipsGap5, y: points.hipsGap4.y + sa + 15 - }); - macro("ld", { + }) + macro('ld', { from: points.waistGap4Right, to: points.waistGap5Left - }); - macro("hd", { + }) + macro('hd', { from: points.underbustGap4Right, to: points.underbustGap5Left, y: points.underbustGap5Left.y - sa - 15 - }); - macro("vd", { + }) + macro('vd', { from: points.hipsGap4, to: points.waistGap4Right, x: points.hipsGap4.x - sa - 15 - }); - macro("vd", { + }) + macro('vd', { from: points.waistGap4Right, to: points.underbustGap4Right, x: points.hipsGap4.x - sa - 15 - }); - macro("vd", { + }) + macro('vd', { from: points.hipsGap5, to: points.waistGap4Right, x: points.hipsGap5.x + sa + 15 - }); - macro("vd", { + }) + macro('vd', { from: points.waistGap4Right, to: points.underbustGap5Left, x: points.hipsGap5.x + sa + 15 - }); + }) } - return part; + return part } diff --git a/packages/cathrin/src/panel6.js b/packages/cathrin/src/panel6.js index 9099834f335..881a8464ec0 100644 --- a/packages/cathrin/src/panel6.js +++ b/packages/cathrin/src/panel6.js @@ -1,89 +1,75 @@ export default function(part) { - let { - macro, - sa, - points, - paths, - Point, - complete, - paperless - } = part.shorthand(); + let { macro, sa, points, paths, Point, complete, paperless } = part.shorthand() - delete paths.outline; - delete paths.panel1; - delete paths.panel2; - delete paths.panel3; - delete paths.panel4; - delete paths.panel5; + delete paths.outline + delete paths.panel1 + delete paths.panel2 + delete paths.panel3 + delete paths.panel4 + delete paths.panel5 // Complete pattern? if (complete) { points.grainlineTop = new Point( points.waistGap5Right.shiftFractionTowards(points.waistCB, 0.5).x, points.underbustGap5Right.y - ); - points.grainlineBottom = new Point( - points.grainlineTop.x, - points.hipsGap5.y - ); - macro("grainline", { + ) + points.grainlineBottom = new Point(points.grainlineTop.x, points.hipsGap5.y) + macro('grainline', { from: points.grainlineBottom, to: points.grainlineTop - }); - points.title = points.grainlineTop.shift( - -90, - points.grainlineTop.dy(points.waistGap5Right) / 2 - ); - macro("title", { + }) + points.title = points.grainlineTop.shift(-90, points.grainlineTop.dy(points.waistGap5Right) / 2) + macro('title', { nr: 6, - title: "", + title: '', at: points.title - }); - points.scalebox = new Point(points.grainlineTop.x, points.hipsGap5.y - 55); - macro("scalebox", { + }) + points.scalebox = new Point(points.grainlineTop.x, points.hipsGap5.y - 55) + macro('scalebox', { at: points.scalebox, rotate: 90 - }); - if (sa) paths.sa = paths.panel6.offset(sa).attr("class", "fabric sa"); + }) + if (sa) paths.sa = paths.panel6.offset(sa).attr('class', 'fabric sa') } // Paperless? if (paperless) { - macro("hd", { + macro('hd', { from: points.hipsGap5, to: points.backDrop, y: points.backDrop.y + sa + 15 - }); - macro("ld", { + }) + macro('ld', { from: points.waistGap5Right, to: points.waistCB - }); - macro("hd", { + }) + macro('hd', { from: points.underbustGap5Right, to: points.backRise, y: points.backRise.y - sa - 15 - }); - macro("vd", { + }) + macro('vd', { from: points.hipsGap5, to: points.waistGap5Right, x: points.hipsGap5.x - sa - 15 - }); - macro("vd", { + }) + macro('vd', { from: points.waistGap5Right, to: points.underbustGap5Right, x: points.hipsGap5.x - sa - 15 - }); - macro("vd", { + }) + macro('vd', { from: points.backDrop, to: points.waistCB, x: points.backDrop.x + sa + 15 - }); - macro("vd", { + }) + macro('vd', { from: points.waistCB, to: points.backRise, x: points.backDrop.x + sa + 15 - }); + }) } - return part; + return part } diff --git a/packages/cathrin/src/panels.js b/packages/cathrin/src/panels.js index c35f72f6186..2dd46433509 100644 --- a/packages/cathrin/src/panels.js +++ b/packages/cathrin/src/panels.js @@ -1,205 +1,141 @@ export default function(part) { - let { - measurements, - options, - store, - points, - paths, - Point, - Path, - debug - } = part.shorthand(); - let count = 1; + let { measurements, options, store, points, paths, Point, Path, debug } = part.shorthand() + let count = 1 let bottom = new Path() .move(points.bottomCF) .curve(points.bottomCFCp2, points.hipRiseCp1, points.hipRise) .curve(points.hipRiseCp2, points.backDropCp1, points.backDrop) - .attr("class", "lashed various stroke-xl"); - for (let gap of store.get("gaps")) { + .attr('class', 'lashed various stroke-xl') + for (let gap of store.get('gaps')) { // Underbust - points[`underbustGap${count}`] = new Point(store.get("width") * gap, 0); + points[`underbustGap${count}`] = new Point(store.get('width') * gap, 0) points[`underbustGap${count}Right`] = points[`underbustGap${count}`].shift( 0, - store.get("bustIntake") * 0.1 - ); + store.get('bustIntake') * 0.1 + ) points[`underbustGap${count}Left`] = points[`underbustGap${count}`].shift( 180, - store.get("bustIntake") * 0.1 - ); - points[`underbustGap${count}RightCp`] = points[ - `underbustGap${count}Right` - ].shift(-90, measurements.naturalWaistToUnderbust * 0.15); - points[`underbustGap${count}LeftCp`] = points[ - `underbustGap${count}Left` - ].shift(-90, measurements.naturalWaistToUnderbust * 0.15); + store.get('bustIntake') * 0.1 + ) + points[`underbustGap${count}RightCp`] = points[`underbustGap${count}Right`].shift( + -90, + measurements.naturalWaistToUnderbust * 0.15 + ) + points[`underbustGap${count}LeftCp`] = points[`underbustGap${count}Left`].shift( + -90, + measurements.naturalWaistToUnderbust * 0.15 + ) // Waist - points[`waistGap${count}`] = new Point( - store.get("width") * gap, - points.waistCF.y - ); + points[`waistGap${count}`] = new Point(store.get('width') * gap, points.waistCF.y) points[`waistGap${count}Right`] = points[`waistGap${count}`].shift( 0, - store.get("waistIntake") * 0.1 - ); + store.get('waistIntake') * 0.1 + ) points[`waistGap${count}Left`] = points[`waistGap${count}`].shift( 180, - store.get("waistIntake") * 0.1 - ); + store.get('waistIntake') * 0.1 + ) points[`waistGap${count}RightCp1`] = points[`waistGap${count}Right`].shift( 90, measurements.naturalWaistToUnderbust * 0.2 - ); + ) points[`waistGap${count}LeftCp2`] = points[`waistGap${count}Left`].shift( 90, measurements.naturalWaistToUnderbust * 0.2 - ); + ) points[`waistGap${count}RightCp2`] = points[`waistGap${count}Right`].shift( -90, measurements.naturalWaistToHip * 0.2 - ); + ) points[`waistGap${count}LeftCp1`] = points[`waistGap${count}Left`].shift( -90, measurements.naturalWaistToHip * 0.2 - ); + ) // Hips - points[`hipsGap${count}`] = new Point( - store.get("width") * gap, - points.hipsCF.y - ); - points[`hipsGap${count}`] = bottom - .intersectsX(points[`waistGap${count}`].x) - .pop(); - points[`hipsGap${count}Cp`] = points[ - `hipsGap${count}` - ].shiftFractionTowards(points[`waistGap${count}`], 0.2); + points[`hipsGap${count}`] = new Point(store.get('width') * gap, points.hipsCF.y) + points[`hipsGap${count}`] = bottom.intersectsX(points[`waistGap${count}`].x).pop() + points[`hipsGap${count}Cp`] = points[`hipsGap${count}`].shiftFractionTowards( + points[`waistGap${count}`], + 0.2 + ) - count++; + count++ } // Paths paths.panel1 = bottom .split(points.hipsGap1)[0] .curve(points.hipsGap1Cp, points.waistGap1LeftCp1, points.waistGap1Left) - .curve( - points.waistGap1LeftCp2, - points.underbustGap1LeftCp, - points.underbustGap1Left - ) + .curve(points.waistGap1LeftCp2, points.underbustGap1LeftCp, points.underbustGap1Left) .curve(points.frontRiseStartCp2, points.topCFCp1, points.topCF) .line(points.bottomCF) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') paths.panel2 = bottom .split(points.hipsGap2)[0] .split(points.hipsGap1)[1] .curve(points.hipsGap2Cp, points.waistGap2LeftCp1, points.waistGap2Left) - .curve( - points.waistGap2LeftCp2, - points.underbustGap2LeftCp, - points.underbustGap2Left - ) + .curve(points.waistGap2LeftCp2, points.underbustGap2LeftCp, points.underbustGap2Left) .line(points.underbustGap1Right) - .curve( - points.underbustGap1RightCp, - points.waistGap1RightCp1, - points.waistGap1Right - ) + .curve(points.underbustGap1RightCp, points.waistGap1RightCp1, points.waistGap1Right) .curve(points.waistGap1RightCp2, points.hipsGap1Cp, points.hipsGap1) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') let panel3 = new Path() .move(points.bottomCF) .curve(points.bottomCFCp2, points.hipRiseCp1, points.hipRise) - .split(points.hipsGap2)[1]; - if (options.panels === 11) panel3 = panel3.split(points.hipsGap3)[0]; + .split(points.hipsGap2)[1] + if (options.panels === 11) panel3 = panel3.split(points.hipsGap3)[0] paths.panel3 = panel3 .curve(points.hipsGap3Cp, points.waistGap3LeftCp1, points.waistGap3Left) - .curve( - points.waistGap3LeftCp2, - points.underbustGap3LeftCp, - points.underbustGap3Left - ) + .curve(points.waistGap3LeftCp2, points.underbustGap3LeftCp, points.underbustGap3Left) .line(points.underbustGap2Right) - .curve( - points.underbustGap2RightCp, - points.waistGap2RightCp1, - points.waistGap2Right - ) + .curve(points.underbustGap2RightCp, points.waistGap2RightCp1, points.waistGap2Right) .curve(points.waistGap2RightCp2, points.hipsGap2Cp, points.hipsGap2) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') let topBack = new Path() .move(points.backRise) - .curve(points.backRiseCp1, points.topSideCp1, points.topSide); - points.underbustGap4Left = topBack - .intersectsX(points.underbustGap4Left.x) - .pop(); + .curve(points.backRiseCp1, points.topSideCp1, points.topSide) + points.underbustGap4Left = topBack.intersectsX(points.underbustGap4Left.x).pop() paths.panel4 = new Path() .move(points.hipRise) .curve(points.hipRiseCp2, points.backDropCp1, points.backDrop) .split(points.hipsGap4)[0] .curve(points.hipsGap4Cp, points.waistGap4LeftCp1, points.waistGap4Left) - .curve( - points.waistGap4LeftCp2, - points.underbustGap4LeftCp, - points.underbustGap4Left - ) - .join(topBack.split(points.underbustGap4Left)[1]); - if (options.panels === 11) paths.panel4.line(points.underbustGap3Right); + .curve(points.waistGap4LeftCp2, points.underbustGap4LeftCp, points.underbustGap4Left) + .join(topBack.split(points.underbustGap4Left)[1]) + if (options.panels === 11) paths.panel4.line(points.underbustGap3Right) paths.panel4 - .curve( - points.underbustGap3RightCp, - points.waistGap3RightCp1, - points.waistGap3Right - ) + .curve(points.underbustGap3RightCp, points.waistGap3RightCp1, points.waistGap3Right) .curve(points.waistGap3RightCp2, points.hipsGap3Cp, points.hipsGap3) .close() - .attr("class", "fabric"); - points.underbustGap4Right = topBack - .intersectsX(points.underbustGap4Right.x) - .pop(); - points.underbustGap5Left = topBack - .intersectsX(points.underbustGap5Left.x) - .pop(); - let top5 = topBack - .split(points.underbustGap5Left)[1] - .split(points.underbustGap4Right)[0]; + .attr('class', 'fabric') + points.underbustGap4Right = topBack.intersectsX(points.underbustGap4Right.x).pop() + points.underbustGap5Left = topBack.intersectsX(points.underbustGap5Left.x).pop() + let top5 = topBack.split(points.underbustGap5Left)[1].split(points.underbustGap4Right)[0] paths.panel5 = bottom .split(points.hipsGap5)[0] .split(points.hipsGap4)[1] .curve(points.hipsGap5Cp, points.waistGap5LeftCp1, points.waistGap5Left) - .curve( - points.waistGap5LeftCp2, - points.underbustGap5LeftCp, - points.underbustGap5Left - ) + .curve(points.waistGap5LeftCp2, points.underbustGap5LeftCp, points.underbustGap5Left) .curve(top5.ops[1].cp1, top5.ops[1].cp2, top5.ops[1].to) - .curve( - points.underbustGap4RightCp, - points.waistGap4RightCp1, - points.waistGap4Right - ) + .curve(points.underbustGap4RightCp, points.waistGap4RightCp1, points.waistGap4Right) .curve(points.waistGap4RightCp2, points.hipsGap4Cp, points.hipsGap4) .close() - .attr("class", "fabric"); - points.underbustGap5Right = topBack - .intersectsX(points.underbustGap5Right.x) - .pop(); + .attr('class', 'fabric') + points.underbustGap5Right = topBack.intersectsX(points.underbustGap5Right.x).pop() paths.panel6 = bottom .split(points.hipsGap5)[1] .line(points.backRise) .join(topBack.split(points.underbustGap5Right)[0]) - .curve( - points.underbustGap5RightCp, - points.waistGap5RightCp1, - points.waistGap5Right - ) + .curve(points.underbustGap5RightCp, points.waistGap5RightCp1, points.waistGap5Right) .curve(points.waistGap5RightCp2, points.hipsGap5Cp, points.hipsGap5) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') - paths.outline.render = false; + paths.outline.render = false - return part; + return part } diff --git a/packages/components/src/index.js b/packages/components/src/index.js index 1b4eaf794b9..adcb17c9f5c 100644 --- a/packages/components/src/index.js +++ b/packages/components/src/index.js @@ -1,19 +1,19 @@ export default [ - "Blockquote", - "Draft", - "DraftConfigurator", - "Emblem", - "Example", - "Footer", - "Icon", - "Logo", - "Navbar", - "Ogol", - "Robot", - "Spinner", - "SampleConfigurator", - "withGist", - "withLanguage", - "withStorage", - "Workbench" -]; + 'Blockquote', + 'Draft', + 'DraftConfigurator', + 'Emblem', + 'Example', + 'Footer', + 'Icon', + 'Logo', + 'Navbar', + 'Ogol', + 'Robot', + 'Spinner', + 'SampleConfigurator', + 'withGist', + 'withLanguage', + 'withStorage', + 'Workbench' +] diff --git a/packages/core/src/attributes.js b/packages/core/src/attributes.js index 1217a9fc6c3..05d39a3f385 100644 --- a/packages/core/src/attributes.js +++ b/packages/core/src/attributes.js @@ -1,99 +1,99 @@ function Attributes() { - this.list = {}; + this.list = {} } /** Adds an attribute */ Attributes.prototype.add = function(name, value) { - if (typeof this.list[name] === "undefined") { - this.list[name] = []; + if (typeof this.list[name] === 'undefined') { + this.list[name] = [] } - this.list[name].push(value); + this.list[name].push(value) - return this; -}; + return this +} /** Sets an attribute, overwriting existing value */ Attributes.prototype.set = function(name, value) { - this.list[name] = [value]; + this.list[name] = [value] - return this; -}; + return this +} /** Removes an attribute */ Attributes.prototype.remove = function(name) { - delete this.list[name]; + delete this.list[name] - return this; -}; + return this +} /** Retrieves an attribute */ Attributes.prototype.get = function(name) { - if (typeof this.list[name] === "undefined") return false; - else return this.list[name].join(" "); -}; + if (typeof this.list[name] === 'undefined') return false + else return this.list[name].join(' ') +} /** Retrieves an attribute as array*/ Attributes.prototype.getAsArray = function(name) { - if (typeof this.list[name] === "undefined") return false; - else return this.list[name]; -}; + if (typeof this.list[name] === 'undefined') return false + else return this.list[name] +} /** Returns SVG code for attributes */ Attributes.prototype.render = function() { - let svg = ""; + let svg = '' for (let key in this.list) { - svg += ` ${key}="${this.list[key].join(" ")}"`; + svg += ` ${key}="${this.list[key].join(' ')}"` } - return svg; -}; + return svg +} /** Returns CSS code for attributes */ Attributes.prototype.renderAsCss = function() { - let css = ""; + let css = '' for (let key in this.list) { - css += ` ${key}:${this.list[key].join(" ")};`; + css += ` ${key}:${this.list[key].join(' ')};` } - return css; -}; + return css +} /** Returns SVG code for attributes with a fiven prefix * typically used for data-text*/ -Attributes.prototype.renderIfPrefixIs = function(prefix = "") { - let svg = ""; - let prefixLen = prefix.length; +Attributes.prototype.renderIfPrefixIs = function(prefix = '') { + let svg = '' + let prefixLen = prefix.length for (let key in this.list) { if (key.substr(0, prefixLen) === prefix) { - svg += ` ${key.substr(prefixLen)}="${this.list[key].join(" ")}"`; + svg += ` ${key.substr(prefixLen)}="${this.list[key].join(' ')}"` } } - return svg; -}; + return svg +} /** Returns a props object for attributes with a fiven prefix * typically used for data-text*/ -Attributes.prototype.asPropsIfPrefixIs = function(prefix = "") { - let props = {}; - let prefixLen = prefix.length; +Attributes.prototype.asPropsIfPrefixIs = function(prefix = '') { + let props = {} + let prefixLen = prefix.length for (let key in this.list) { if (key.substr(0, prefixLen) === prefix) { - let propKey = key.substr(prefixLen); - if (propKey === "class") propKey = "className"; - props[propKey] = this.get(key); + let propKey = key.substr(prefixLen) + if (propKey === 'class') propKey = 'className' + props[propKey] = this.get(key) } } - return props; -}; + return props +} /** Returns a deep copy of this */ Attributes.prototype.clone = function() { - let clone = new Attributes(); - clone.list = JSON.parse(JSON.stringify(this.list)); + let clone = new Attributes() + clone.list = JSON.parse(JSON.stringify(this.list)) - return clone; -}; + return clone +} -export default Attributes; +export default Attributes diff --git a/packages/core/src/design.js b/packages/core/src/design.js index 919fcd34821..568ee9f1875 100644 --- a/packages/core/src/design.js +++ b/packages/core/src/design.js @@ -1,18 +1,18 @@ -import Pattern from "./pattern"; +import Pattern from './pattern' export default function Design(config, plugins = false) { const pattern = function(settings) { - Pattern.call(this, config); - if (Array.isArray(plugins)) for (let plugin of plugins) this.use(plugin); - else if (plugins) this.use(plugins); - this.apply(settings); + Pattern.call(this, config) + if (Array.isArray(plugins)) for (let plugin of plugins) this.use(plugin) + else if (plugins) this.use(plugins) + this.apply(settings) - return this; - }; + return this + } // Set up inheritance - pattern.prototype = Object.create(Pattern.prototype); - pattern.prototype.constructor = pattern; + pattern.prototype = Object.create(Pattern.prototype) + pattern.prototype.constructor = pattern - return pattern; + return pattern } diff --git a/packages/core/src/hooks.js b/packages/core/src/hooks.js index e12d11beee5..70a7f93fb31 100644 --- a/packages/core/src/hooks.js +++ b/packages/core/src/hooks.js @@ -8,5 +8,5 @@ export default function Hooks() { postRender: [], insertText: [], debug: [] - }; + } } diff --git a/packages/core/src/index.js b/packages/core/src/index.js index cf705d04717..dde036cae7d 100644 --- a/packages/core/src/index.js +++ b/packages/core/src/index.js @@ -1,10 +1,10 @@ -import Design from "./design"; -import Pattern from "./pattern"; -import Point from "./point"; -import Path from "./path"; -import Snippet from "./snippet"; -import * as utils from "./utils"; -import { version } from "../package.json"; +import Design from './design' +import Pattern from './pattern' +import Point from './point' +import Path from './path' +import Snippet from './snippet' +import * as utils from './utils' +import { version } from '../package.json' export default { version, @@ -16,4 +16,4 @@ export default { utils, patterns: {}, plugins: {} -}; +} diff --git a/packages/core/src/option.js b/packages/core/src/option.js index 8ffb704f44b..7b4c3c1bcd2 100644 --- a/packages/core/src/option.js +++ b/packages/core/src/option.js @@ -1,9 +1,9 @@ function Option(config) { - this.id = config.id; - this.config = config; - this.val = config.val; + this.id = config.id + this.config = config + this.val = config.val - return this; + return this } -export default Option; +export default Option diff --git a/packages/core/src/part.js b/packages/core/src/part.js index 08652ce212c..e379b59af2b 100644 --- a/packages/core/src/part.js +++ b/packages/core/src/part.js @@ -1,202 +1,196 @@ -import * as utils from "./utils"; -import Point from "./point"; -import Path from "./path"; -import Snippet from "./snippet"; -import Attributes from "./attributes"; -import Hooks from "./hooks"; +import * as utils from './utils' +import Point from './point' +import Path from './path' +import Snippet from './snippet' +import Attributes from './attributes' +import Hooks from './hooks' function Part() { - this.attributes = new Attributes(); - this.points = {}; - this.paths = {}; - this.snippets = {}; - this.freeId = 0; - this.topLeft = false; - this.bottomRight = false; - this.width = false; - this.height = false; - this.render = true; - this.utils = utils; + this.attributes = new Attributes() + this.points = {} + this.paths = {} + this.snippets = {} + this.freeId = 0 + this.topLeft = false + this.bottomRight = false + this.width = false + this.height = false + this.render = true + this.utils = utils // Constructors so macros can create objects - this.Point = Point; - this.Path = Path; - this.Snippet = Snippet; + this.Point = Point + this.Path = Path + this.Snippet = Snippet - this.hooks = new Hooks(); // Hooks container + this.hooks = new Hooks() // Hooks container - return this; + return this } Part.prototype.macroClosure = function(args) { - let self = this; + let self = this let method = function(key, args) { - let macro = utils.macroName(key); - if (typeof self[macro] === "function") { - self[macro](args); + let macro = utils.macroName(key) + if (typeof self[macro] === 'function') { + self[macro](args) } else { self.debug({ - type: "warning", - label: "🚨 Macro not found", + type: 'warning', + label: '🚨 Macro not found', msg: `Macro ${key} is not registered` - }); - } - }; - - return method; -}; - -Part.prototype.debugClosure = function() { - let self = this; - let method = function(data) { - self.debug(data); - }; - - return method; -}; - -Part.prototype.runHooks = function(hookName, data = false) { - if (data === false) data = this; - let hooks = this.hooks[hookName]; - if (hooks && hooks.length > 0) { - for (let hook of hooks) { - hook.method(data, hook.data); + }) } } -}; + + return method +} + +Part.prototype.debugClosure = function() { + let self = this + let method = function(data) { + self.debug(data) + } + + return method +} + +Part.prototype.runHooks = function(hookName, data = false) { + if (data === false) data = this + let hooks = this.hooks[hookName] + if (hooks && hooks.length > 0) { + for (let hook of hooks) { + hook.method(data, hook.data) + } + } +} /** Debug method */ Part.prototype.debug = function(data) { - this.runHooks("debug", data); -}; + this.runHooks('debug', data) +} /** Returns an unused ID */ Part.prototype.getId = function() { - this.freeId += 1; + this.freeId += 1 - return "" + this.freeId; -}; + return '' + this.freeId +} /** Returns a value formatted for units provided in settings */ Part.prototype.unitsClosure = function(value) { - let self = this; + let self = this let method = function(value) { - return utils.units(value, self.context.settings.units); - }; + return utils.units(value, self.context.settings.units) + } - return method; -}; + return method +} /** Calculates the part's bounding box and sets it */ Part.prototype.boundary = function() { - if (this.topLeft) return this; // Cached + if (this.topLeft) return this // Cached - let topLeft = new Point(Infinity, Infinity); - let bottomRight = new Point(-Infinity, -Infinity); + let topLeft = new Point(Infinity, Infinity) + let bottomRight = new Point(-Infinity, -Infinity) for (let key in this.paths) { - let path = this.paths[key].boundary(); + let path = this.paths[key].boundary() if (path.render) { - if (path.topLeft.x < topLeft.x) topLeft.x = path.topLeft.x; - if (path.topLeft.y < topLeft.y) topLeft.y = path.topLeft.y; - if (path.bottomRight.x > bottomRight.x) - bottomRight.x = path.bottomRight.x; - if (path.bottomRight.y > bottomRight.y) - bottomRight.y = path.bottomRight.y; + if (path.topLeft.x < topLeft.x) topLeft.x = path.topLeft.x + if (path.topLeft.y < topLeft.y) topLeft.y = path.topLeft.y + if (path.bottomRight.x > bottomRight.x) bottomRight.x = path.bottomRight.x + if (path.bottomRight.y > bottomRight.y) bottomRight.y = path.bottomRight.y } } for (let key in this.points) { - let point = this.points[key]; - let radius = point.attributes.get("data-circle"); + let point = this.points[key] + let radius = point.attributes.get('data-circle') if (radius) { - radius = parseFloat(radius); - if (point.x - radius < topLeft.x) topLeft.x = point.x - radius; - if (point.y - radius < topLeft.y) topLeft.y = point.y - radius; - if (point.x + radius > bottomRight.x) bottomRight.x = point.x + radius; - if (point.y + radius > bottomRight.y) bottomRight.y = point.y + radius; + radius = parseFloat(radius) + if (point.x - radius < topLeft.x) topLeft.x = point.x - radius + if (point.y - radius < topLeft.y) topLeft.y = point.y - radius + if (point.x + radius > bottomRight.x) bottomRight.x = point.x + radius + if (point.y + radius > bottomRight.y) bottomRight.y = point.y + radius } } // Fix infinity if part has no paths - if (topLeft.x === Infinity) topLeft.x = 0; - if (topLeft.y === Infinity) topLeft.y = 0; - if (bottomRight.x === -Infinity) bottomRight.x = 0; - if (bottomRight.y === -Infinity) bottomRight.y = 0; + if (topLeft.x === Infinity) topLeft.x = 0 + if (topLeft.y === Infinity) topLeft.y = 0 + if (bottomRight.x === -Infinity) bottomRight.x = 0 + if (bottomRight.y === -Infinity) bottomRight.y = 0 // Add margin - let margin = this.context.settings.margin; - if (this.context.settings.paperless && margin < 10) margin = 10; - this.topLeft = new Point(topLeft.x - margin, topLeft.y - margin); - this.bottomRight = new Point(bottomRight.x + margin, bottomRight.y + margin); - this.width = this.bottomRight.x - this.topLeft.x; - this.height = this.bottomRight.y - this.topLeft.y; + let margin = this.context.settings.margin + if (this.context.settings.paperless && margin < 10) margin = 10 + this.topLeft = new Point(topLeft.x - margin, topLeft.y - margin) + this.bottomRight = new Point(bottomRight.x + margin, bottomRight.y + margin) + this.width = this.bottomRight.x - this.topLeft.x + this.height = this.bottomRight.y - this.topLeft.y - return this; -}; + return this +} /** Stacks part so that its top left corner is in (0,0) */ Part.prototype.stack = function() { - if (this.topLeft !== false) return this; - else this.boundary(); - if (this.topLeft.x == 0 && this.topLeft.y == 0) return this; - else - this.attr( - "transform", - `translate(${this.topLeft.x * -1}, ${this.topLeft.y * -1})` - ); + if (this.topLeft !== false) return this + else this.boundary() + if (this.topLeft.x == 0 && this.topLeft.y == 0) return this + else this.attr('transform', `translate(${this.topLeft.x * -1}, ${this.topLeft.y * -1})`) - return this; -}; + return this +} /** Adds an attribute. This is here to make this call chainable in assignment */ Part.prototype.attr = function(name, value, overwrite = false) { - if (overwrite) this.attributes.set(name, value); - else this.attributes.add(name, value); + if (overwrite) this.attributes.set(name, value) + else this.attributes.add(name, value) - return this; -}; + return this +} /** Copies point/path/snippet data from part orig into this */ Part.prototype.inject = function(orig) { const findBasePoint = p => { for (let i in orig.points) { - if (orig.points[i] === p) return i; + if (orig.points[i] === p) return i } - return false; - }; + return false + } - for (let i in orig.points) this.points[i] = orig.points[i].clone(); + for (let i in orig.points) this.points[i] = orig.points[i].clone() for (let i in orig.paths) { - this.paths[i] = orig.paths[i].clone(); + this.paths[i] = orig.paths[i].clone() // Keep link between points and path ops where possible for (let j in orig.paths[i].ops) { - let op = orig.paths[i].ops[j]; - if (op.type !== "close") { - let toPoint = findBasePoint(op.to); - if (toPoint) this.paths[i].ops[j].to = this.points[toPoint]; + let op = orig.paths[i].ops[j] + if (op.type !== 'close') { + let toPoint = findBasePoint(op.to) + if (toPoint) this.paths[i].ops[j].to = this.points[toPoint] } - if (op.type === "curve") { - let cp1Point = findBasePoint(op.cp1); - if (cp1Point) this.paths[i].ops[j].cp1 = this.points[cp1Point]; - let cp2Point = findBasePoint(op.cp2); - if (cp2Point) this.paths[i].ops[j].cp2 = this.points[cp2Point]; + if (op.type === 'curve') { + let cp1Point = findBasePoint(op.cp1) + if (cp1Point) this.paths[i].ops[j].cp1 = this.points[cp1Point] + let cp2Point = findBasePoint(op.cp2) + if (cp2Point) this.paths[i].ops[j].cp2 = this.points[cp2Point] } } } for (let i in orig.snippets) { - this.snippets[i] = orig.snippets[i].clone(); + this.snippets[i] = orig.snippets[i].clone() } - return this; -}; + return this +} Part.prototype.units = function(input) { - return utils.units(input, this.context.settings.units); -}; + return utils.units(input, this.context.settings.units) +} /** Returns an object with shorthand access for pattern design */ Part.prototype.shorthand = function() { - let complete = this.context.settings.complete ? true : false; - let paperless = this.context.settings.paperless === true ? true : false; - let sa = this.context.settings.complete ? this.context.settings.sa || 0 : 0; + let complete = this.context.settings.complete ? true : false + let paperless = this.context.settings.paperless === true ? true : false + let sa = this.context.settings.complete ? this.context.settings.sa || 0 : 0 return { sa, measurements: this.context.settings.measurements || {}, @@ -214,7 +208,7 @@ Part.prototype.shorthand = function() { complete, paperless, debug: this.debugClosure() - }; -}; + } +} -export default Part; +export default Part diff --git a/packages/core/src/path.js b/packages/core/src/path.js index 39f4e12b049..9537b383842 100644 --- a/packages/core/src/path.js +++ b/packages/core/src/path.js @@ -1,6 +1,6 @@ -import Attributes from "./attributes"; -import Point from "./point"; -import Bezier from "bezier-js"; +import Attributes from './attributes' +import Point from './point' +import Bezier from 'bezier-js' import { linesIntersect, lineIntersectsCurve, @@ -9,290 +9,287 @@ import { pointOnCurve, curveEdge, round -} from "./utils"; +} from './utils' function Path() { - this.render = true; - this.topLeft = false; - this.bottomRight = false; - this.attributes = new Attributes(); - this.ops = []; + this.render = true + this.topLeft = false + this.bottomRight = false + this.attributes = new Attributes() + this.ops = [] } /** Chainable way to set the render property */ Path.prototype.setRender = function(render = true) { - if (render) this.render = true; - else this.render = false; + if (render) this.render = true + else this.render = false - return this; -}; + return this +} /** Adds a move operation to Point to */ Path.prototype.move = function(to) { - this.ops.push({ type: "move", to }); + this.ops.push({ type: 'move', to }) - return this; -}; + return this +} /** Adds a line operation to Point to */ Path.prototype.line = function(to) { - this.ops.push({ type: "line", to }); + this.ops.push({ type: 'line', to }) - return this; -}; + return this +} /** Adds a curve operation via cp1 & cp2 to Point to */ Path.prototype.curve = function(cp1, cp2, to) { - this.ops.push({ type: "curve", cp1, cp2, to }); + this.ops.push({ type: 'curve', cp1, cp2, to }) - return this; -}; + return this +} /** Adds a curve operation without cp1 via cp2 to Point to */ Path.prototype._curve = function(cp2, to) { - let cp1 = this.ops.slice(-1).pop().to; - this.ops.push({ type: "curve", cp1, cp2, to }); + let cp1 = this.ops.slice(-1).pop().to + this.ops.push({ type: 'curve', cp1, cp2, to }) - return this; -}; + return this +} /** Adds a curve operation via cp1 with no cp2 to Point to */ Path.prototype.curve_ = function(cp1, to) { - let cp2 = to.copy(); - this.ops.push({ type: "curve", cp1, cp2, to }); + let cp2 = to.copy() + this.ops.push({ type: 'curve', cp1, cp2, to }) - return this; -}; + return this +} /** Adds a close operation */ Path.prototype.close = function() { - this.ops.push({ type: "close" }); + this.ops.push({ type: 'close' }) - return this; -}; + return this +} /** Adds an attribute. This is here to make this call chainable in assignment */ Path.prototype.attr = function(name, value, overwrite = false) { - if (overwrite) this.attributes.set(name, value); - else this.attributes.add(name, value); + if (overwrite) this.attributes.set(name, value) + else this.attributes.add(name, value) - return this; -}; + return this +} /** Returns SVG pathstring for this path */ Path.prototype.asPathstring = function() { - let d = ""; + let d = '' for (let op of this.ops) { switch (op.type) { - case "move": - d += `M ${op.to.x},${op.to.y}`; - break; - case "line": - d += ` L ${op.to.x},${op.to.y}`; - break; - case "curve": - d += ` C ${op.cp1.x},${op.cp1.y} ${op.cp2.x},${op.cp2.y} ${op.to.x},${op.to.y}`; - break; - case "close": - d += " z"; - break; + case 'move': + d += `M ${op.to.x},${op.to.y}` + break + case 'line': + d += ` L ${op.to.x},${op.to.y}` + break + case 'curve': + d += ` C ${op.cp1.x},${op.cp1.y} ${op.cp2.x},${op.cp2.y} ${op.to.x},${op.to.y}` + break + case 'close': + d += ' z' + break } } - return d; -}; + return d +} /** Returns offset of this path as a new path */ Path.prototype.offset = function(distance) { - return pathOffset(this, distance); -}; + return pathOffset(this, distance) +} /** Returns the length of this path */ Path.prototype.length = function() { - let current, start; - let length = 0; + let current, start + let length = 0 for (let i in this.ops) { - let op = this.ops[i]; - if (op.type === "move") { - start = op.to; - } else if (op.type === "line") { - length += current.dist(op.to); - } else if (op.type === "curve") { + let op = this.ops[i] + if (op.type === 'move') { + start = op.to + } else if (op.type === 'line') { + length += current.dist(op.to) + } else if (op.type === 'curve') { length += new Bezier( { x: current.x, y: current.y }, { x: op.cp1.x, y: op.cp1.y }, { x: op.cp2.x, y: op.cp2.y }, { x: op.to.x, y: op.to.y } - ).length(); - } else if (op.type === "close") { - length += current.dist(start); + ).length() + } else if (op.type === 'close') { + length += current.dist(start) } - if (op.to) current = op.to; + if (op.to) current = op.to } - return round(length); -}; + return round(length) +} /** Returns the startpoint of the path */ Path.prototype.start = function() { - return this.ops[0].to; -}; + return this.ops[0].to +} /** Returns the endpoint of the path */ Path.prototype.end = function() { - let op = this.ops[this.ops.length - 1]; + let op = this.ops[this.ops.length - 1] - if (op.type === "close") return this.start(); - else return op.to; -}; + if (op.type === 'close') return this.start() + else return op.to +} /** Finds the bounding box of a path */ Path.prototype.boundary = function() { - if (this.topLeft) return this; // Cached + if (this.topLeft) return this // Cached - let current; - let topLeft = new Point(Infinity, Infinity); - let bottomRight = new Point(-Infinity, -Infinity); - let edges = []; + let current + let topLeft = new Point(Infinity, Infinity) + let bottomRight = new Point(-Infinity, -Infinity) + let edges = [] for (let i in this.ops) { - let op = this.ops[i]; - if (op.type === "move" || op.type === "line") { + let op = this.ops[i] + if (op.type === 'move' || op.type === 'line') { if (op.to.x < topLeft.x) { - topLeft.x = op.to.x; - edges["leftOp"] = i; + topLeft.x = op.to.x + edges['leftOp'] = i } if (op.to.y < topLeft.y) { - topLeft.y = op.to.y; - edges["topOp"] = i; + topLeft.y = op.to.y + edges['topOp'] = i } if (op.to.x > bottomRight.x) { - bottomRight.x = op.to.x; - edges["rightOp"] = i; + bottomRight.x = op.to.x + edges['rightOp'] = i } if (op.to.y > bottomRight.y) { - bottomRight.y = op.to.y; - edges["bottomOp"] = i; + bottomRight.y = op.to.y + edges['bottomOp'] = i } - } else if (op.type === "curve") { + } else if (op.type === 'curve') { let bb = new Bezier( { x: current.x, y: current.y }, { x: op.cp1.x, y: op.cp1.y }, { x: op.cp2.x, y: op.cp2.y }, { x: op.to.x, y: op.to.y } - ).bbox(); + ).bbox() if (bb.x.min < topLeft.x) { - topLeft.x = bb.x.min; - edges["leftOp"] = i; + topLeft.x = bb.x.min + edges['leftOp'] = i } if (bb.y.min < topLeft.y) { - topLeft.y = bb.y.min; - edges["topOp"] = i; + topLeft.y = bb.y.min + edges['topOp'] = i } if (bb.x.max > bottomRight.x) { - bottomRight.x = bb.x.max; - edges["rightOp"] = i; + bottomRight.x = bb.x.max + edges['rightOp'] = i } if (bb.y.max > bottomRight.y) { - bottomRight.y = bb.y.max; - edges["bottomOp"] = i; + bottomRight.y = bb.y.max + edges['bottomOp'] = i } } - if (op.to) current = op.to; + if (op.to) current = op.to } - this.topLeft = topLeft; - this.bottomRight = bottomRight; + this.topLeft = topLeft + this.bottomRight = bottomRight - for (let side of ["top", "left", "bottom", "right"]) { - let s = side + "Op"; - this[s] = this.ops[edges[s]]; - this[s].from = - this[s].type === "move" ? this[s].to : this.ops[edges[s] - 1].to; + for (let side of ['top', 'left', 'bottom', 'right']) { + let s = side + 'Op' + this[s] = this.ops[edges[s]] + this[s].from = this[s].type === 'move' ? this[s].to : this.ops[edges[s] - 1].to } - return this; -}; + return this +} /** Returns a deep copy of this */ Path.prototype.clone = function() { - let clone = new Path(); - clone.render = this.render; - if (this.topLeft) clone.topLeft = this.topLeft.clone(); - else clone.topLeft = false; - if (this.bottomRight) clone.bottomRight = this.bottomRight.clone(); - else clone.bottomRight = false; - clone.attributes = this.attributes.clone(); - clone.ops = []; + let clone = new Path() + clone.render = this.render + if (this.topLeft) clone.topLeft = this.topLeft.clone() + else clone.topLeft = false + if (this.bottomRight) clone.bottomRight = this.bottomRight.clone() + else clone.bottomRight = false + clone.attributes = this.attributes.clone() + clone.ops = [] for (let i in this.ops) { - let op = this.ops[i]; - clone.ops[i] = { type: op.type }; - if (op.type === "move" || op.type === "line") { - clone.ops[i].to = op.to.clone(); - } else if (op.type === "curve") { - clone.ops[i].to = op.to.clone(); - clone.ops[i].cp1 = op.cp1.clone(); - clone.ops[i].cp2 = op.cp2.clone(); + let op = this.ops[i] + clone.ops[i] = { type: op.type } + if (op.type === 'move' || op.type === 'line') { + clone.ops[i].to = op.to.clone() + } else if (op.type === 'curve') { + clone.ops[i].to = op.to.clone() + clone.ops[i].cp1 = op.cp1.clone() + clone.ops[i].cp2 = op.cp2.clone() } } - return clone; -}; + return clone +} /** Joins this with that path, closes them if wanted */ Path.prototype.join = function(that, closed = false) { - return joinPaths([this, that], closed); -}; + return joinPaths([this, that], closed) +} /** Offsets a path by distance */ function pathOffset(path, distance) { - let offset = []; - let current; - let start = false; - let closed = false; + let offset = [] + let current + let start = false + let closed = false for (let i in path.ops) { - let op = path.ops[i]; - if (op.type === "line") { - let segment = offsetLine(current, op.to, distance); - if (segment) offset.push(segment); - } else if (op.type === "curve") { + let op = path.ops[i] + if (op.type === 'line') { + let segment = offsetLine(current, op.to, distance) + if (segment) offset.push(segment) + } else if (op.type === 'curve') { // We need to avoid a control point sitting on top of start or end // because that will break the offset in bezier-js - let cp1, cp2; + let cp1, cp2 if (current.sitsRoughlyOn(op.cp1)) { cp1 = new Path() .move(current) .curve(op.cp1, op.cp2, op.to) - .shiftAlong(2); - } else cp1 = op.cp1; + .shiftAlong(2) + } else cp1 = op.cp1 if (op.cp2.sitsRoughlyOn(op.to)) { cp2 = new Path() .move(op.to) .curve(op.cp2, op.cp1, current) - .shiftAlong(2); - } else cp2 = op.cp2; + .shiftAlong(2) + } else cp2 = op.cp2 let b = new Bezier( { x: current.x, y: current.y }, { x: cp1.x, y: cp1.y }, { x: cp2.x, y: cp2.y }, { x: op.to.x, y: op.to.y } - ); - for (let bezier of b.offset(distance)) offset.push(asPath(bezier)); - } else if (op.type === "close") closed = true; - if (op.to) current = op.to; - if (!start) start = current; + ) + for (let bezier of b.offset(distance)) offset.push(asPath(bezier)) + } else if (op.type === 'close') closed = true + if (op.to) current = op.to + if (!start) start = current } - return joinPaths(offset, closed); + return joinPaths(offset, closed) } /** Offsets a line by distance */ function offsetLine(from, to, distance) { - if (from.x === to.x && from.y === to.y) return false; - let angle = from.angle(to) - 90; + if (from.x === to.x && from.y === to.y) return false + let angle = from.angle(to) - 90 - return new Path() - .move(from.shift(angle, distance)) - .line(to.shift(angle, distance)); + return new Path().move(from.shift(angle, distance)).line(to.shift(angle, distance)) } /** Converts a bezier-js instance to a path */ @@ -303,93 +300,91 @@ function asPath(bezier) { new Point(bezier.points[1].x, bezier.points[1].y), new Point(bezier.points[2].x, bezier.points[2].y), new Point(bezier.points[3].x, bezier.points[3].y) - ); + ) } /** Joins path segments together into one path */ function joinPaths(paths, closed = false) { - let joint = new Path().move(paths[0].ops[0].to); - let current; + let joint = new Path().move(paths[0].ops[0].to) + let current for (let p of paths) { for (let op of p.ops) { - if (op.type === "curve") { - joint.curve(op.cp1, op.cp2, op.to); - } else if (op.type !== "close") { + if (op.type === 'curve') { + joint.curve(op.cp1, op.cp2, op.to) + } else if (op.type !== 'close') { // We're using sitsRoughlyOn here to avoid miniscule line segments - if (current && !op.to.sitsRoughlyOn(current)) joint.line(op.to); + if (current && !op.to.sitsRoughlyOn(current)) joint.line(op.to) } else { - throw new Error("Cannot join a closed paths with another"); + throw new Error('Cannot join a closed paths with another') } - if (op.to) current = op.to; + if (op.to) current = op.to } } - if (closed) joint.close(); + if (closed) joint.close() - return joint; + return joint } /** Returns a point that lies at distance along this */ Path.prototype.shiftAlong = function(distance) { - let len = 0; - let current; + let len = 0 + let current for (let i in this.ops) { - let op = this.ops[i]; - if (op.type === "line") { - let thisLen = op.to.dist(current); - if (len + thisLen > distance) - return current.shiftTowards(op.to, distance - len); - else len += thisLen; - } else if (op.type === "curve") { + let op = this.ops[i] + if (op.type === 'line') { + let thisLen = op.to.dist(current) + if (len + thisLen > distance) return current.shiftTowards(op.to, distance - len) + else len += thisLen + } else if (op.type === 'curve') { let bezier = new Bezier( { x: current.x, y: current.y }, { x: op.cp1.x, y: op.cp1.y }, { x: op.cp2.x, y: op.cp2.y }, { x: op.to.x, y: op.to.y } - ); - let thisLen = bezier.length(); - if (len + thisLen > distance) - return shiftAlongBezier(distance - len, bezier); - else len += thisLen; + ) + let thisLen = bezier.length() + if (len + thisLen > distance) return shiftAlongBezier(distance - len, bezier) + else len += thisLen } - current = op.to; + current = op.to } throw new Error( `Error in Path.shiftAlong(): Ran out of path to shift along. Distance requested was ${distance}, path length is${this.length()}.` - ); -}; + ) +} /** Returns a point that lies at fraction along this */ Path.prototype.shiftFractionAlong = function(fraction) { - return this.shiftAlong(this.length() * fraction); -}; + return this.shiftAlong(this.length() * fraction) +} /** Returns a point that lies at distance along bezier */ function shiftAlongBezier(distance, bezier) { - let steps = 100; - let previous, next, t, thisLen; - let len = 0; + let steps = 100 + let previous, next, t, thisLen + let len = 0 for (let i = 0; i <= steps; i++) { - t = i / steps; - next = bezier.get(t); - next = new Point(next.x, next.y); + t = i / steps + next = bezier.get(t) + next = new Point(next.x, next.y) if (i > 0) { - thisLen = next.dist(previous); - if (len + thisLen > distance) return next; - else len += thisLen; + thisLen = next.dist(previous) + if (len + thisLen > distance) return next + else len += thisLen } - previous = next; + previous = next } } /** Returns a point at the top edge of a bounding box of this */ Path.prototype.bbox = function() { - let bbs = []; - let current; + let bbs = [] + let current for (let i in this.ops) { - let op = this.ops[i]; - if (op.type === "line") { - bbs.push(lineBoundingBox({ from: current, to: op.to })); - } else if (op.type === "curve") { + let op = this.ops[i] + if (op.type === 'line') { + bbs.push(lineBoundingBox({ from: current, to: op.to })) + } else if (op.type === 'curve') { bbs.push( curveBoundingBox( new Bezier( @@ -399,124 +394,121 @@ Path.prototype.bbox = function() { { x: op.to.x, y: op.to.y } ) ) - ); + ) } - if (op.to) current = op.to; + if (op.to) current = op.to } - return bbbbox(bbs); -}; + return bbbbox(bbs) +} function lineBoundingBox(line) { - let from = line.from; - let to = line.to; + let from = line.from + let to = line.to if (from.x === to.x) { - if (from.y < to.y) return { topLeft: from, bottomRight: to }; - else return { topLeft: to, bottomRight: from }; + if (from.y < to.y) return { topLeft: from, bottomRight: to } + else return { topLeft: to, bottomRight: from } } else if (from.y === to.y) { - if (from.x < to.x) return { topLeft: from, bottomRight: to }; - else return { topLeft: to, bottomRight: from }; + if (from.x < to.x) return { topLeft: from, bottomRight: to } + else return { topLeft: to, bottomRight: from } } else if (from.x < to.x) { - if (from.y < to.y) return { topLeft: from, bottomRight: to }; + if (from.y < to.y) return { topLeft: from, bottomRight: to } else return { topLeft: new Point(from.x, to.y), bottomRight: new Point(to.x, from.y) - }; + } } else if (from.x > to.x) { if (from.y < to.y) return { topLeft: new Point(to.x, from.y), bottomRight: new Point(from.x, to.y) - }; + } else return { topLeft: new Point(to.x, to.y), bottomRight: new Point(from.x, from.y) - }; + } } } function curveBoundingBox(curve) { - let bb = curve.bbox(); + let bb = curve.bbox() return { topLeft: new Point(bb.x.min, bb.y.min), bottomRight: new Point(bb.x.max, bb.y.max) - }; + } } function bbbbox(boxes) { - let minX = Infinity; - let maxX = -Infinity; - let minY = Infinity; - let maxY = -Infinity; + let minX = Infinity + let maxX = -Infinity + let minY = Infinity + let maxY = -Infinity for (let box of boxes) { - if (box.topLeft.x < minX) minX = box.topLeft.x; - if (box.topLeft.y < minY) minY = box.topLeft.y; - if (box.bottomRight.x > maxX) maxX = box.bottomRight.x; - if (box.bottomRight.y > maxY) maxY = box.bottomRight.y; + if (box.topLeft.x < minX) minX = box.topLeft.x + if (box.topLeft.y < minY) minY = box.topLeft.y + if (box.bottomRight.x > maxX) maxX = box.bottomRight.x + if (box.bottomRight.y > maxY) maxY = box.bottomRight.y } - return { topLeft: new Point(minX, minY), bottomRight: new Point(maxX, maxY) }; + return { topLeft: new Point(minX, minY), bottomRight: new Point(maxX, maxY) } } /** Returns a reversed version of this */ Path.prototype.reverse = function() { - let sections = []; - let current; - let closed = false; + let sections = [] + let current + let closed = false for (let i in this.ops) { - let op = this.ops[i]; - if (op.type === "line") { - if (!op.to.sitsOn(current)) - sections.push(new Path().move(op.to).line(current)); - } else if (op.type === "curve") { - sections.push(new Path().move(op.to).curve(op.cp2, op.cp1, current)); - } else if (op.type === "close") { - closed = true; + let op = this.ops[i] + if (op.type === 'line') { + if (!op.to.sitsOn(current)) sections.push(new Path().move(op.to).line(current)) + } else if (op.type === 'curve') { + sections.push(new Path().move(op.to).curve(op.cp2, op.cp1, current)) + } else if (op.type === 'close') { + closed = true } - if (op.to) current = op.to; + if (op.to) current = op.to } - let rev = new Path().move(current); - for (let section of sections.reverse()) rev.ops.push(section.ops[1]); - if (closed) rev.close(); + let rev = new Path().move(current) + for (let section of sections.reverse()) rev.ops.push(section.ops[1]) + if (closed) rev.close() - return rev; -}; + return rev +} /** Returns the point at an edge of this path */ Path.prototype.edge = function(side) { - this.boundary(); - if (side === "topLeft") return this.topLeft; - else if (side === "bottomRight") return this.bottomRight; - else if (side === "topRight") - return new Point(this.bottomRight.x, this.topLeft.y); - else if (side === "bottomLeft") - return new Point(this.topLeft.x, this.bottomRight.y); + this.boundary() + if (side === 'topLeft') return this.topLeft + else if (side === 'bottomRight') return this.bottomRight + else if (side === 'topRight') return new Point(this.bottomRight.x, this.topLeft.y) + else if (side === 'bottomLeft') return new Point(this.topLeft.x, this.bottomRight.y) else { - let s = side + "Op"; - if (this[s].type === "move") return this[s].to; - else if (this[s].type === "line") { - if (side === "top") { - if (this.topOp.to.y < this.topOp.from.y) return this.topOp.to; - else return this.topOp.from; - } else if (side === "left") { - if (this.leftOp.to.x < this.leftOp.from.x) return this.leftOp.to; - else return this.leftOp.from; - } else if (side === "bottom") { - if (this.bottomOp.to.y > this.bottomOp.from.y) return this.bottomOp.to; - else return this.bottomOp.from; - } else if (side === "right") { - if (this.rightOp.to.x > this.rightOp.from.x) return this.rightOp.to; - else return this.rightOp.from; + let s = side + 'Op' + if (this[s].type === 'move') return this[s].to + else if (this[s].type === 'line') { + if (side === 'top') { + if (this.topOp.to.y < this.topOp.from.y) return this.topOp.to + else return this.topOp.from + } else if (side === 'left') { + if (this.leftOp.to.x < this.leftOp.from.x) return this.leftOp.to + else return this.leftOp.from + } else if (side === 'bottom') { + if (this.bottomOp.to.y > this.bottomOp.from.y) return this.bottomOp.to + else return this.bottomOp.from + } else if (side === 'right') { + if (this.rightOp.to.x > this.rightOp.from.x) return this.rightOp.to + else return this.rightOp.from } - } else if (this[s].type === "curve") { - let curve = edgeCurveAsBezier(this[s]); - return curveEdge(curve, side); + } else if (this[s].type === 'curve') { + let curve = edgeCurveAsBezier(this[s]) + return curveEdge(curve, side) } } -}; +} function edgeCurveAsBezier(op) { return new Bezier( @@ -524,56 +516,53 @@ function edgeCurveAsBezier(op) { { x: op.cp1.x, y: op.cp1.y }, { x: op.cp2.x, y: op.cp2.y }, { x: op.to.x, y: op.to.y } - ); + ) } /** Divides a path into atomic paths */ Path.prototype.divide = function() { - let paths = []; - let current, start; + let paths = [] + let current, start for (let i in this.ops) { - let op = this.ops[i]; - if (op.type === "move") { - start = op.to; - } else if (op.type === "line") { - if (!op.to.sitsRoughlyOn(current)) - paths.push(new Path().move(current).line(op.to)); - } else if (op.type === "curve") { - paths.push(new Path().move(current).curve(op.cp1, op.cp2, op.to)); - } else if (op.type === "close") { - paths.push(new Path().move(current).line(start)); + let op = this.ops[i] + if (op.type === 'move') { + start = op.to + } else if (op.type === 'line') { + if (!op.to.sitsRoughlyOn(current)) paths.push(new Path().move(current).line(op.to)) + } else if (op.type === 'curve') { + paths.push(new Path().move(current).curve(op.cp1, op.cp2, op.to)) + } else if (op.type === 'close') { + paths.push(new Path().move(current).line(start)) } - if (op.to) current = op.to; + if (op.to) current = op.to } - return paths; -}; + return paths +} /** Finds intersections between this path and an X value */ Path.prototype.intersectsX = function(x) { - return this.intersectsAxis(x, "x"); -}; + return this.intersectsAxis(x, 'x') +} /** Finds intersections between this path and an Y value */ Path.prototype.intersectsY = function(y) { - return this.intersectsAxis(y, "y"); -}; + return this.intersectsAxis(y, 'y') +} /** Finds intersections between this path and a X or Y value */ Path.prototype.intersectsAxis = function(val = false, mode) { - if (val === false) - throw new Error("Path.intersects[X-Y] requires an value as parameter"); - let intersections = []; - let lineStart = - mode === "x" ? new Point(val, -100000) : new Point(-10000, val); - let lineEnd = mode === "x" ? new Point(val, 100000) : new Point(100000, val); + if (val === false) throw new Error('Path.intersects[X-Y] requires an value as parameter') + let intersections = [] + let lineStart = mode === 'x' ? new Point(val, -100000) : new Point(-10000, val) + let lineEnd = mode === 'x' ? new Point(val, 100000) : new Point(100000, val) for (let path of this.divide()) { - if (path.ops[1].type === "line") { + if (path.ops[1].type === 'line') { addIntersectionsToArray( linesIntersect(path.ops[0].to, path.ops[1].to, lineStart, lineEnd), intersections - ); - } else if (path.ops[1].type === "curve") { + ) + } else if (path.ops[1].type === 'curve') { addIntersectionsToArray( lineIntersectsCurve( lineStart, @@ -584,34 +573,27 @@ Path.prototype.intersectsAxis = function(val = false, mode) { path.ops[1].to ), intersections - ); + ) } } - return intersections; -}; + return intersections +} /** Finds intersections between this path and another path */ Path.prototype.intersects = function(path) { if (this === path) - throw new Error( - "Calculating intersections between two identical paths is bad idea" - ); - let intersections = []; + throw new Error('Calculating intersections between two identical paths is bad idea') + let intersections = [] for (let pathA of this.divide()) { for (let pathB of path.divide()) { - if (pathA.ops[1].type === "line") { - if (pathB.ops[1].type === "line") { + if (pathA.ops[1].type === 'line') { + if (pathB.ops[1].type === 'line') { addIntersectionsToArray( - linesIntersect( - pathA.ops[0].to, - pathA.ops[1].to, - pathB.ops[0].to, - pathB.ops[1].to - ), + linesIntersect(pathA.ops[0].to, pathA.ops[1].to, pathB.ops[0].to, pathB.ops[1].to), intersections - ); - } else if (pathB.ops[1].type === "curve") { + ) + } else if (pathB.ops[1].type === 'curve') { addIntersectionsToArray( lineIntersectsCurve( pathA.ops[0].to, @@ -622,10 +604,10 @@ Path.prototype.intersects = function(path) { pathB.ops[1].to ), intersections - ); + ) } - } else if (pathA.ops[1].type === "curve") { - if (pathB.ops[1].type === "line") { + } else if (pathA.ops[1].type === 'curve') { + if (pathB.ops[1].type === 'line') { addIntersectionsToArray( lineIntersectsCurve( pathB.ops[0].to, @@ -636,8 +618,8 @@ Path.prototype.intersects = function(path) { pathA.ops[1].to ), intersections - ); - } else if (pathB.ops[1].type === "curve") { + ) + } else if (pathB.ops[1].type === 'curve') { addIntersectionsToArray( curvesIntersect( pathA.ops[0].to, @@ -650,57 +632,51 @@ Path.prototype.intersects = function(path) { pathB.ops[1].to ), intersections - ); + ) } } } } - return intersections; -}; + return intersections +} function addIntersectionsToArray(candidates, intersections) { - if (!candidates) return; - if (typeof candidates === "object") { - if (typeof candidates.x === "number") intersections.push(candidates); + if (!candidates) return + if (typeof candidates === 'object') { + if (typeof candidates.x === 'number') intersections.push(candidates) else { - for (let candidate of candidates) intersections.push(candidate); + for (let candidate of candidates) intersections.push(candidate) } } } /** Splits path on point, and retuns both halves */ Path.prototype.split = function(point) { - let divided = this.divide(); - let firstHalf = false; - let secondHalf = false; + let divided = this.divide() + let firstHalf = false + let secondHalf = false for (let pi = 0; pi < divided.length; pi++) { - let path = divided[pi]; - if (path.ops[1].type === "line") { + let path = divided[pi] + if (path.ops[1].type === 'line') { if (pointOnLine(path.ops[0].to, path.ops[1].to, point)) { - firstHalf = divided.slice(0, pi); - firstHalf.push(new Path().move(path.ops[0].to).line(point)); - pi++; - secondHalf = divided.slice(pi); - secondHalf.unshift(new Path().move(point).line(path.ops[1].to)); + firstHalf = divided.slice(0, pi) + firstHalf.push(new Path().move(path.ops[0].to).line(point)) + pi++ + secondHalf = divided.slice(pi) + secondHalf.unshift(new Path().move(point).line(path.ops[1].to)) } - } else if (path.ops[1].type === "curve") { - let t = pointOnCurve( - path.ops[0].to, - path.ops[1].cp1, - path.ops[1].cp2, - path.ops[1].to, - point - ); + } else if (path.ops[1].type === 'curve') { + let t = pointOnCurve(path.ops[0].to, path.ops[1].cp1, path.ops[1].cp2, path.ops[1].to, point) if (t !== false) { let curve = new Bezier( { x: path.ops[0].to.x, y: path.ops[0].to.y }, { x: path.ops[1].cp1.x, y: path.ops[1].cp1.y }, { x: path.ops[1].cp2.x, y: path.ops[1].cp2.y }, { x: path.ops[1].to.x, y: path.ops[1].to.y } - ); - let split = curve.split(t); - firstHalf = divided.slice(0, pi); + ) + let split = curve.split(t) + firstHalf = divided.slice(0, pi) firstHalf.push( new Path() .move(new Point(split.left.points[0].x, split.left.points[0].y)) @@ -709,9 +685,9 @@ Path.prototype.split = function(point) { new Point(split.left.points[2].x, split.left.points[2].y), new Point(split.left.points[3].x, split.left.points[3].y) ) - ); - pi++; - secondHalf = divided.slice(pi); + ) + pi++ + secondHalf = divided.slice(pi) secondHalf.unshift( new Path() .move(new Point(split.right.points[0].x, split.right.points[0].y)) @@ -720,88 +696,82 @@ Path.prototype.split = function(point) { new Point(split.right.points[2].x, split.right.points[2].y), new Point(split.right.points[3].x, split.right.points[3].y) ) - ); + ) } } } - if (firstHalf) firstHalf = joinPaths(firstHalf); - if (secondHalf) secondHalf = joinPaths(secondHalf); + if (firstHalf) firstHalf = joinPaths(firstHalf) + if (secondHalf) secondHalf = joinPaths(secondHalf) - return [firstHalf, secondHalf]; -}; + return [firstHalf, secondHalf] +} /** Removes self-intersections (overlap) from the path */ Path.prototype.trim = function() { - let chunks = this.divide(); + let chunks = this.divide() for (let i = 0; i < chunks.length; i++) { - let firstCandidate = parseInt(i) + 2; - let lastCandidate = parseInt(chunks.length) - 1; + let firstCandidate = parseInt(i) + 2 + let lastCandidate = parseInt(chunks.length) - 1 for (let j = firstCandidate; j < lastCandidate; j++) { - let intersections = chunks[i].intersects(chunks[j]); + let intersections = chunks[i].intersects(chunks[j]) if (intersections.length > 0) { - let intersection = intersections.pop(); - let trimmedStart = chunks.slice(0, i); - let trimmedEnd = chunks.slice(parseInt(j) + 1); - let glue = new Path(); - let first = true; + let intersection = intersections.pop() + let trimmedStart = chunks.slice(0, i) + let trimmedEnd = chunks.slice(parseInt(j) + 1) + let glue = new Path() + let first = true for (let k of [i, j]) { - let ops = chunks[k].ops; - if (ops[1].type === "line") { - glue.line(intersection); - } else if (ops[1].type === "curve") { + let ops = chunks[k].ops + if (ops[1].type === 'line') { + glue.line(intersection) + } else if (ops[1].type === 'curve') { // handle curve let curve = new Bezier( { x: ops[0].to.x, y: ops[0].to.y }, { x: ops[1].cp1.x, y: ops[1].cp1.y }, { x: ops[1].cp2.x, y: ops[1].cp2.y }, { x: ops[1].to.x, y: ops[1].to.y } - ); - let t = pointOnCurve( - ops[0].to, - ops[1].cp1, - ops[1].cp2, - ops[1].to, - intersection - ); - let split = curve.split(t); - let side; - if (first) side = split.left; - else side = split.right; + ) + let t = pointOnCurve(ops[0].to, ops[1].cp1, ops[1].cp2, ops[1].to, intersection) + let split = curve.split(t) + let side + if (first) side = split.left + else side = split.right glue.curve( new Point(side.points[1].x, side.points[1].y), new Point(side.points[2].x, side.points[2].y), new Point(side.points[3].x, side.points[3].y) - ); + ) } - first = false; + first = false } - let joint; - if (trimmedStart.length > 0) joint = joinPaths(trimmedStart).join(glue); - else joint = glue; - if (trimmedEnd.length > 0) joint = joint.join(joinPaths(trimmedEnd)); + let joint + if (trimmedStart.length > 0) joint = joinPaths(trimmedStart).join(glue) + else joint = glue + if (trimmedEnd.length > 0) joint = joint.join(joinPaths(trimmedEnd)) - return joint.trim(); + return joint.trim() } } } - return this; -}; + return this +} /** Applies a path translate transform */ Path.prototype.translate = function(x, y) { - let clone = this.clone(); + let clone = this.clone() for (let op of clone.ops) { - if (op.type !== "close") { - op.to = op.to.translate(x, y); + if (op.type !== 'close') { + op.to = op.to.translate(x, y) } - if (op.type === "curve") { - op.cp1 = op.cp1.translate(x, y); - op.cp2 = op.cp2.translate(x, y); + if (op.type === 'curve') { + op.cp1 = op.cp1.translate(x, y) + op.cp2 = op.cp2.translate(x, y) } } - return clone; -}; + return clone +} -export default Path; +export default Path diff --git a/packages/core/src/pattern.js b/packages/core/src/pattern.js index 0b2c1d18017..076652984bd 100644 --- a/packages/core/src/pattern.js +++ b/packages/core/src/pattern.js @@ -1,72 +1,63 @@ -import { macroName, round, sampleStyle, capitalize } from "./utils"; -import Part from "./part"; -import Point from "./point"; -import Path from "./path"; -import Snippet from "./snippet"; -import Svg from "./svg"; -import pack from "bin-pack"; -import Store from "./store"; -import Hooks from "./hooks"; -import Attributes from "./attributes"; +import { macroName, round, sampleStyle, capitalize } from './utils' +import Part from './part' +import Point from './point' +import Path from './path' +import Snippet from './snippet' +import Svg from './svg' +import pack from 'bin-pack' +import Store from './store' +import Hooks from './hooks' +import Attributes from './attributes' export default function Pattern(config = { options: {} }) { - this.config = config; // Pattern configuration - this.width = 0; // Will be set after render - this.height = 0; // Will be set after render - this.is = ""; // Will be set when drafting/sampling + this.config = config // Pattern configuration + this.width = 0 // Will be set after render + this.height = 0 // Will be set after render + this.is = '' // Will be set when drafting/sampling - this.store = new Store(); // Store for sharing data across parts - this.parts = {}; // Parts container - this.hooks = new Hooks(); // Hooks container - this.Point = Point; // Point constructor - this.Path = Path; // Path constructor - this.Snippet = Snippet; // Snippet constructor - this.Attributes = Attributes; // Attributes constructor + this.store = new Store() // Store for sharing data across parts + this.parts = {} // Parts container + this.hooks = new Hooks() // Hooks container + this.Point = Point // Point constructor + this.Path = Path // Path constructor + this.Snippet = Snippet // Snippet constructor + this.Attributes = Attributes // Attributes constructor // Default settings this.settings = { complete: true, - idPrefix: "fs-", - locale: "en", - units: "metric", + idPrefix: 'fs-', + locale: 'en', + units: 'metric', margin: 2, layout: true, options: {} - }; + } - if (typeof this.config.dependencies === "undefined") - this.config.dependencies = {}; - if (typeof this.config.inject === "undefined") this.config.inject = {}; - if (typeof this.config.hide === "undefined") this.config.hide = []; - this.config.resolvedDependencies = this.resolveDependencies( - this.config.dependencies - ); - this.config.draftOrder = this.draftOrder(this.config.resolvedDependencies); + if (typeof this.config.dependencies === 'undefined') this.config.dependencies = {} + if (typeof this.config.inject === 'undefined') this.config.inject = {} + if (typeof this.config.hide === 'undefined') this.config.hide = [] + this.config.resolvedDependencies = this.resolveDependencies(this.config.dependencies) + this.config.draftOrder = this.draftOrder(this.config.resolvedDependencies) // Convert options for (let i in config.options) { - let option = config.options[i]; - if (typeof option === "object") { - if (typeof option.pct !== "undefined") - this.settings.options[i] = option.pct / 100; - else if (typeof option.mm !== "undefined") - this.settings.options[i] = option.mm; - else if (typeof option.deg !== "undefined") - this.settings.options[i] = option.deg; - else if (typeof option.count !== "undefined") - this.settings.options[i] = option.count; - else if (typeof option.bool !== "undefined") - this.settings.options[i] = option.bool; - else if (typeof option.dflt !== "undefined") - this.settings.options[i] = option.dflt; - else throw new Error("Unknown option type: " + JSON.stringify(option)); + let option = config.options[i] + if (typeof option === 'object') { + if (typeof option.pct !== 'undefined') this.settings.options[i] = option.pct / 100 + else if (typeof option.mm !== 'undefined') this.settings.options[i] = option.mm + else if (typeof option.deg !== 'undefined') this.settings.options[i] = option.deg + else if (typeof option.count !== 'undefined') this.settings.options[i] = option.count + else if (typeof option.bool !== 'undefined') this.settings.options[i] = option.bool + else if (typeof option.dflt !== 'undefined') this.settings.options[i] = option.dflt + else throw new Error('Unknown option type: ' + JSON.stringify(option)) } else { - this.settings.options[i] = option; + this.settings.options[i] = option } } // Macros - this.macros = {}; + this.macros = {} // Context object to add to Part closure const context = { @@ -75,406 +66,385 @@ export default function Pattern(config = { options: {} }) { settings: this.settings, store: this.store, macros: this.macros - }; + } // Part closure this.Part = function() { - let part = new Part(); - part.context = context; + let part = new Part() + part.context = context for (let macro in context.macros) { - part[macroName(macro)] = context.macros[macro]; + part[macroName(macro)] = context.macros[macro] } - return part; - }; + return part + } } // Merges settings object with this.settings Pattern.prototype.apply = function(settings) { - if (typeof settings !== "object") return this; + if (typeof settings !== 'object') return this for (let key of Object.keys(settings)) { if (Array.isArray(settings[key])) { if (Array.isArray(this.settings[key])) { - for (let entry of settings[key]) this.settings[key].push(entry); - } else this.settings[key] = settings[key]; - } else if (typeof settings[key] === "object") { + for (let entry of settings[key]) this.settings[key].push(entry) + } else this.settings[key] = settings[key] + } else if (typeof settings[key] === 'object') { this.settings[key] = { ...this.settings[key], ...settings[key] - }; - } else this.settings[key] = settings[key]; + } + } else this.settings[key] = settings[key] } - return this; -}; + return this +} Pattern.prototype.runHooks = function(hookName, data = false) { - if (data === false) data = this; - let hooks = this.hooks[hookName]; + if (data === false) data = this + let hooks = this.hooks[hookName] if (hooks.length > 0) { for (let hook of hooks) { - hook.method(data, hook.data); + hook.method(data, hook.data) } } -}; +} /** * The default draft method with pre- and postDraft hooks */ Pattern.prototype.draft = function() { - if (this.is !== "sample") this.is = "draft"; - this.runHooks("preDraft"); + if (this.is !== 'sample') this.is = 'draft' + this.runHooks('preDraft') for (let partName of this.config.draftOrder) { - this.parts[partName] = new this.Part(); - if (typeof this.config.inject[partName] === "string") { - this.parts[partName].inject(this.parts[this.config.inject[partName]]); + this.parts[partName] = new this.Part() + if (typeof this.config.inject[partName] === 'string') { + this.parts[partName].inject(this.parts[this.config.inject[partName]]) } if (this.needs(partName)) { - let method = "draft" + capitalize(partName); - if (typeof this[method] !== "function") + let method = 'draft' + capitalize(partName) + if (typeof this[method] !== 'function') + throw new Error('Method "' + method + '" on pattern object is not callable') + this.parts[partName] = this[method](this.parts[partName]) + if (typeof this.parts[partName] === 'undefined') throw new Error( - 'Method "' + method + '" on pattern object is not callable' - ); - this.parts[partName] = this[method](this.parts[partName]); - if (typeof this.parts[partName] === "undefined") - throw new Error( - "Result of " + - method + - "() was undefined. Did you forget to return the Part object?" - ); + 'Result of ' + method + '() was undefined. Did you forget to return the Part object?' + ) this.parts[partName].render = - this.parts[partName].render === false ? false : this.wants(partName); + this.parts[partName].render === false ? false : this.wants(partName) } else { - this.parts[partName].render = false; + this.parts[partName].render = false } } - this.runHooks("postDraft"); + this.runHooks('postDraft') - return this; -}; + return this +} /** * Handles pattern sampling */ Pattern.prototype.sample = function() { - if (this.settings.sample.type === "option") { - return this.sampleOption(this.settings.sample.option); - } else if (this.settings.sample.type === "measurement") { - return this.sampleMeasurement(this.settings.sample.measurement); - } else if (this.settings.sample.type === "models") { - return this.sampleModels( - this.settings.sample.models, - this.settings.sample.focus || false - ); + if (this.settings.sample.type === 'option') { + return this.sampleOption(this.settings.sample.option) + } else if (this.settings.sample.type === 'measurement') { + return this.sampleMeasurement(this.settings.sample.measurement) + } else if (this.settings.sample.type === 'models') { + return this.sampleModels(this.settings.sample.models, this.settings.sample.focus || false) } -}; +} Pattern.prototype.sampleParts = function() { - let parts = {}; - this.settings.complete = false; - this.settings.paperless = false; - this.draft(); + let parts = {} + this.settings.complete = false + this.settings.paperless = false + this.draft() for (let i in this.parts) { - parts[i] = new this.Part(); - parts[i].render = this.parts[i].render; + parts[i] = new this.Part() + parts[i].render = this.parts[i].render } - return parts; -}; + return parts +} -Pattern.prototype.sampleRun = function( - parts, - anchors, - run, - runs, - extraClass = false -) { - this.draft(); +Pattern.prototype.sampleRun = function(parts, anchors, run, runs, extraClass = false) { + this.draft() for (let i in this.parts) { - let anchor = false; - let dx = 0; - let dy = 0; + let anchor = false + let dx = 0 + let dy = 0 if (this.parts[i].points.anchor) { - if (typeof anchors[i] === "undefined") - anchors[i] = this.parts[i].points.anchor; + if (typeof anchors[i] === 'undefined') anchors[i] = this.parts[i].points.anchor else { if (!anchors[i].sitsOn(this.parts[i].points.anchor)) { - dx = this.parts[i].points.anchor.dx(anchors[i]); - dy = this.parts[i].points.anchor.dy(anchors[i]); + dx = this.parts[i].points.anchor.dx(anchors[i]) + dy = this.parts[i].points.anchor.dy(anchors[i]) } } } for (let j in this.parts[i].paths) { - parts[i].paths[j + "_" + run] = this.parts[i].paths[j] + parts[i].paths[j + '_' + run] = this.parts[i].paths[j] .clone() - .attr("style", sampleStyle(run, runs)); + .attr('style', sampleStyle(run, runs)) if (this.parts[i].points.anchor) - parts[i].paths[j + "_" + run] = parts[i].paths[j + "_" + run].translate( - dx, - dy - ); - if (extraClass !== false) - parts[i].paths[j + "_" + run].attributes.add("class", extraClass); + parts[i].paths[j + '_' + run] = parts[i].paths[j + '_' + run].translate(dx, dy) + if (extraClass !== false) parts[i].paths[j + '_' + run].attributes.add('class', extraClass) } } -}; +} /** * Handles option sampling */ Pattern.prototype.sampleOption = function(optionName) { - this.is = "sample"; - this.runHooks("preSample"); - let step, val; - let factor = 1; - let anchors = {}; - let parts = this.sampleParts(); - let option = this.config.options[optionName]; - if (typeof option.list === "object") { - return this.sampleListOption(optionName); + this.is = 'sample' + this.runHooks('preSample') + let step, val + let factor = 1 + let anchors = {} + let parts = this.sampleParts() + let option = this.config.options[optionName] + if (typeof option.list === 'object') { + return this.sampleListOption(optionName) } - if (typeof option.min === "undefined" || typeof option.max === "undefined") { - let min = option * 0.9; - let max = option * 1.1; - option = { min, max }; + if (typeof option.min === 'undefined' || typeof option.max === 'undefined') { + let min = option * 0.9 + let max = option * 1.1 + option = { min, max } } - if (typeof option.pct !== "undefined") factor = 100; - val = option.min / factor; - step = (option.max / factor - val) / 9; + if (typeof option.pct !== 'undefined') factor = 100 + val = option.min / factor + step = (option.max / factor - val) / 9 for (let run = 1; run < 11; run++) { - this.settings.options[optionName] = val; + this.settings.options[optionName] = val this.debug({ - type: "info", - label: "🏃🏿‍♀️ Sample run", + type: 'info', + label: '🏃🏿‍♀️ Sample run', msg: `Sampling option ${optionName} with value ${round(val)}` - }); - this.sampleRun(parts, anchors, run, 10); - val += step; + }) + this.sampleRun(parts, anchors, run, 10) + val += step } - this.parts = parts; - this.runHooks("postSample"); + this.parts = parts + this.runHooks('postSample') - return this; -}; + return this +} Pattern.prototype.sampleListOption = function(optionName) { - let parts = this.sampleParts(); - let option = this.config.options[optionName]; - let anchors = {}; - let run = 1; - let runs = option.list.length; + let parts = this.sampleParts() + let option = this.config.options[optionName] + let anchors = {} + let run = 1 + let runs = option.list.length for (let val of option.list) { - this.settings.options[optionName] = val; + this.settings.options[optionName] = val this.debug({ - type: "info", - label: "🏃🏿‍♀️ Sample run", + type: 'info', + label: '🏃🏿‍♀️ Sample run', msg: `Sampling option ${optionName} with value ${round(val)}` - }); - this.sampleRun(parts, anchors, run, runs); - run++; + }) + this.sampleRun(parts, anchors, run, runs) + run++ } - this.parts = parts; + this.parts = parts - return this; -}; + return this +} /** * Handles measurement sampling */ Pattern.prototype.sampleMeasurement = function(measurementName) { - this.is = "sample"; - this.runHooks("preSample"); - let anchors = {}; - let parts = this.sampleParts(); - let val = this.settings.measurements[measurementName]; + this.is = 'sample' + this.runHooks('preSample') + let anchors = {} + let parts = this.sampleParts() + let val = this.settings.measurements[measurementName] if (val === undefined) - throw new Error( - "Cannot sample a measurement that is undefined: " + measurementName - ); - let step = val / 50; - val = val * 0.9; + throw new Error('Cannot sample a measurement that is undefined: ' + measurementName) + let step = val / 50 + val = val * 0.9 for (let run = 1; run < 11; run++) { - this.settings.measurements[measurementName] = val; + this.settings.measurements[measurementName] = val this.debug({ - type: "info", - label: "🏃🏿‍♀️ Sample run", + type: 'info', + label: '🏃🏿‍♀️ Sample run', msg: `Sampling option ${measurementName} with value ${round(val)}` - }); - this.sampleRun(parts, anchors, run, 10); - val += step; + }) + this.sampleRun(parts, anchors, run, 10) + val += step } - this.parts = parts; - this.runHooks("postSample"); + this.parts = parts + this.runHooks('postSample') - return this; -}; + return this +} /** * Handles models sampling */ Pattern.prototype.sampleModels = function(models, focus = false) { - this.is = "sample"; - this.runHooks("preSample"); - let anchors = {}; - let parts = this.sampleParts(); - let run = 0; - let runs = Object.keys(models).length; + this.is = 'sample' + this.runHooks('preSample') + let anchors = {} + let parts = this.sampleParts() + let run = 0 + let runs = Object.keys(models).length for (let l in models) { - run++; - this.settings.measurements = models[l]; + run++ + this.settings.measurements = models[l] this.debug({ - type: "info", - label: "🏃🏿‍♀️ Sample run", + type: 'info', + label: '🏃🏿‍♀️ Sample run', msg: `Sampling model ${l}` - }); - let className = l === focus ? "sample-focus" : ""; - this.sampleRun(parts, anchors, run, runs, className); + }) + let className = l === focus ? 'sample-focus' : '' + this.sampleRun(parts, anchors, run, runs, className) } - this.parts = parts; - this.runHooks("postSample"); + this.parts = parts + this.runHooks('postSample') - return this; -}; + return this +} /** Debug method, exposes debug hook */ Pattern.prototype.debug = function(data) { - this.runHooks("debug", data); -}; + this.runHooks('debug', data) +} Pattern.prototype.render = function() { - this.svg = new Svg(this); - this.svg.hooks = this.hooks; + this.svg = new Svg(this) + this.svg.hooks = this.hooks - return this.pack().svg.render(this); -}; + return this.pack().svg.render(this) +} Pattern.prototype.on = function(hook, method, data) { - this.hooks[hook].push({ method, data }); -}; + this.hooks[hook].push({ method, data }) +} Pattern.prototype.use = function(plugin, data = false) { this.debug({ - type: "success", - label: "🔌 Plugin loaded", + type: 'success', + label: '🔌 Plugin loaded', msg: `${plugin.name} v${plugin.version}` - }); - if (plugin.hooks) this.loadPluginHooks(plugin, data); - if (plugin.macros) this.loadPluginMacros(plugin); + }) + if (plugin.hooks) this.loadPluginHooks(plugin, data) + if (plugin.macros) this.loadPluginMacros(plugin) - return this; -}; + return this +} Pattern.prototype.loadPluginHooks = function(plugin, data) { for (let hook of Object.keys(this.hooks)) { - if (typeof plugin.hooks[hook] === "function") { - this.on(hook, plugin.hooks[hook], data); + if (typeof plugin.hooks[hook] === 'function') { + this.on(hook, plugin.hooks[hook], data) } else if (Array.isArray(plugin.hooks[hook])) { for (let method of plugin.hooks[hook]) { - this.on(hook, method, data); + this.on(hook, method, data) } } } -}; +} Pattern.prototype.loadPluginMacros = function(plugin) { for (let macro in plugin.macros) { - if (typeof plugin.macros[macro] === "function") { - this.macro(macro, plugin.macros[macro]); + if (typeof plugin.macros[macro] === 'function') { + this.macro(macro, plugin.macros[macro]) } } -}; +} Pattern.prototype.macro = function(key, method) { - this.macros[key] = method; -}; + this.macros[key] = method +} /** Packs parts in a 2D space and sets pattern size */ Pattern.prototype.pack = function() { - let bins = []; + let bins = [] for (let key in this.parts) { - let part = this.parts[key]; + let part = this.parts[key] // Avoid multiple render calls to cause stacking of transforms - part.attributes.remove("transform"); + part.attributes.remove('transform') if (part.render) { - part.stack(); - let width = part.bottomRight.x - part.topLeft.x; - let height = part.bottomRight.y - part.topLeft.y; - if (this.settings.layout === true) bins.push({ id: key, width, height }); + part.stack() + let width = part.bottomRight.x - part.topLeft.x + let height = part.bottomRight.y - part.topLeft.y + if (this.settings.layout === true) bins.push({ id: key, width, height }) else { - if (this.width < width) this.width = width; - if (this.height < height) this.height = height; + if (this.width < width) this.width = width + if (this.height < height) this.height = height } } } if (this.settings.layout === true) { - let size = pack(bins, { inPlace: true }); + let size = pack(bins, { inPlace: true }) for (let bin of bins) { - let part = this.parts[bin.id]; - if (bin.x !== 0 || bin.y !== 0) - part.attr("transform", `translate (${bin.x}, ${bin.y})`); + let part = this.parts[bin.id] + if (bin.x !== 0 || bin.y !== 0) part.attr('transform', `translate (${bin.x}, ${bin.y})`) } - this.width = size.width; - this.height = size.height; - } else if (typeof this.settings.layout === "object") { - this.width = this.settings.layout.width; - this.height = this.settings.layout.height; + this.width = size.width + this.height = size.height + } else if (typeof this.settings.layout === 'object') { + this.width = this.settings.layout.width + this.height = this.settings.layout.height for (let partId of Object.keys(this.settings.layout.parts)) { - let transforms = this.settings.layout.parts[partId]; + let transforms = this.settings.layout.parts[partId] // Moving - if (typeof transforms.move === "object") { + if (typeof transforms.move === 'object') { this.parts[partId].attributes.set( - "transform", - "translate(" + transforms.move.x + ", " + transforms.move.y + ")" - ); + 'transform', + 'translate(' + transforms.move.x + ', ' + transforms.move.y + ')' + ) } // Mirrorring let center = this.parts[partId].topLeft.shiftFractionTowards( this.parts[partId].bottomRight, 0.5 - ); - let anchor = { x: 0, y: 0 }; + ) + let anchor = { x: 0, y: 0 } if (transforms.flipX) { - let dx = anchor.x - center.x; - let transform = `translate(${center.x * -1}, ${center.y * -1})`; - transform += " scale(-1, 1)"; - transform += ` translate(${center.x * -1 + 2 * dx}, ${center.y})`; - this.parts[partId].attributes.add("transform", transform); + let dx = anchor.x - center.x + let transform = `translate(${center.x * -1}, ${center.y * -1})` + transform += ' scale(-1, 1)' + transform += ` translate(${center.x * -1 + 2 * dx}, ${center.y})` + this.parts[partId].attributes.add('transform', transform) } if (transforms.flipY) { - let dy = anchor.y - center.y; - let transform = `translate(${center.x * -1}, ${center.y * -1})`; - transform += " scale(1, -1)"; - transform += ` translate(${center.x}, ${center.y * -1 + 2 * dy})`; - this.parts[partId].attributes.add("transform", transform); + let dy = anchor.y - center.y + let transform = `translate(${center.x * -1}, ${center.y * -1})` + transform += ' scale(1, -1)' + transform += ` translate(${center.x}, ${center.y * -1 + 2 * dy})` + this.parts[partId].attributes.add('transform', transform) } if (transforms.rotate) { - let transform = `rotate(${transforms.rotate}, ${center.x - - anchor.x}, ${center.y - anchor.y})`; - this.parts[partId].attributes.add("transform", transform); + let transform = `rotate(${transforms.rotate}, ${center.x - anchor.x}, ${center.y - + anchor.y})` + this.parts[partId].attributes.add('transform', transform) } } } - return this; -}; + return this +} /** Determines the order to draft parts in, based on dependencies */ Pattern.prototype.draftOrder = function(graph = this.resolveDependencies()) { - let sorted = []; - let visited = {}; + let sorted = [] + let visited = {} Object.keys(graph).forEach(function visit(name, ancestors) { - if (!Array.isArray(ancestors)) ancestors = []; - ancestors.push(name); - visited[name] = true; - if (typeof graph[name] !== "undefined") { + if (!Array.isArray(ancestors)) ancestors = [] + ancestors.push(name) + visited[name] = true + if (typeof graph[name] !== 'undefined') { graph[name].forEach(function(dep) { - if (visited[dep]) return; - visit(dep, ancestors.slice(0)); - }); + if (visited[dep]) return + visit(dep, ancestors.slice(0)) + }) } - if (sorted.indexOf(name) < 0) sorted.push(name); - }); + if (sorted.indexOf(name) < 0) sorted.push(name) + }) - return sorted; -}; + return sorted +} /** Recursively solves part dependencies for a part */ Pattern.prototype.resolveDependency = function( @@ -483,135 +453,119 @@ Pattern.prototype.resolveDependency = function( graph = this.config.dependencies, deps = [] ) { - if (typeof seen[part] === "undefined") seen[part] = true; - if (typeof graph[part] === "string") { - if (deps.indexOf(graph[part]) === -1) deps.push(graph[part]); - return this.resolveDependency(seen, graph[part], graph, deps); + if (typeof seen[part] === 'undefined') seen[part] = true + if (typeof graph[part] === 'string') { + if (deps.indexOf(graph[part]) === -1) deps.push(graph[part]) + return this.resolveDependency(seen, graph[part], graph, deps) } else if (Array.isArray(graph[part])) { - if (graph[part].length === 0) return []; + if (graph[part].length === 0) return [] else { - if (deps.length === 0) deps = graph[part]; - for (let apart of graph[part]) - deps.concat(this.resolveDependency(seen, apart, graph, deps)); + if (deps.length === 0) deps = graph[part] + for (let apart of graph[part]) deps.concat(this.resolveDependency(seen, apart, graph, deps)) } } - return deps; -}; + return deps +} /** Resolves part dependencies into a flat array */ -Pattern.prototype.resolveDependencies = function( - graph = this.config.dependencies -) { +Pattern.prototype.resolveDependencies = function(graph = this.config.dependencies) { for (let i in this.config.inject) { - let dependency = this.config.inject[i]; - if (typeof this.config.dependencies[i] === "undefined") - this.config.dependencies[i] = dependency; + let dependency = this.config.inject[i] + if (typeof this.config.dependencies[i] === 'undefined') this.config.dependencies[i] = dependency else if (this.config.dependencies[i] !== dependency) { - if (typeof this.config.dependencies[i] === "string") - this.config.dependencies[i] = [this.config.dependencies[i], dependency]; + if (typeof this.config.dependencies[i] === 'string') + this.config.dependencies[i] = [this.config.dependencies[i], dependency] else if (Array.isArray(this.config.dependencies[i])) { if (this.config.dependencies[i].indexOf(dependency) === -1) - this.config.dependencies[i].push(dependency); - } else - throw new Error( - "Part dependencies should be a string or an array of strings" - ); + this.config.dependencies[i].push(dependency) + } else throw new Error('Part dependencies should be a string or an array of strings') } // Parts both in the parts and dependencies array trip up the dependency resolver if (Array.isArray(this.config.parts)) { - let pos = this.config.parts.indexOf(this.config.inject[i]); - if (pos !== -1) this.config.parts.splice(pos, 1); + let pos = this.config.parts.indexOf(this.config.inject[i]) + if (pos !== -1) this.config.parts.splice(pos, 1) } } // Include parts outside the dependency graph if (Array.isArray(this.config.parts)) { for (let part of this.config.parts) { - if (typeof this.config.dependencies[part] === "undefined") - this.config.dependencies[part] = []; + if (typeof this.config.dependencies[part] === 'undefined') this.config.dependencies[part] = [] } } - let resolved = {}; - let seen = {}; - for (let part in graph) - resolved[part] = this.resolveDependency(seen, part, graph); - for (let part in seen) - if (typeof resolved[part] === "undefined") resolved[part] = []; + let resolved = {} + let seen = {} + for (let part in graph) resolved[part] = this.resolveDependency(seen, part, graph) + for (let part in seen) if (typeof resolved[part] === 'undefined') resolved[part] = [] - return resolved; -}; + return resolved +} /** Determines whether a part is needed * This depends on the 'only' setting and the * configured dependencies. */ Pattern.prototype.needs = function(partName) { - if (typeof this.settings.only === "undefined" || this.settings.only === false) - return true; - else if (typeof this.settings.only === "string") { - if (this.settings.only === partName) return true; + if (typeof this.settings.only === 'undefined' || this.settings.only === false) return true + else if (typeof this.settings.only === 'string') { + if (this.settings.only === partName) return true if (Array.isArray(this.config.resolvedDependencies[this.settings.only])) { - for (let dependency of this.config.resolvedDependencies[ - this.settings.only - ]) { - if (dependency === partName) return true; + for (let dependency of this.config.resolvedDependencies[this.settings.only]) { + if (dependency === partName) return true } } } else if (Array.isArray(this.settings.only)) { for (let part of this.settings.only) { - if (part === partName) return true; + if (part === partName) return true for (let dependency of this.config.resolvedDependencies[part]) { - if (dependency === partName) return true; + if (dependency === partName) return true } } } - return false; -}; + return false +} /* Checks whether a part is hidden in the config */ Pattern.prototype.isHidden = function(partName) { if (Array.isArray(this.config.hide)) { - if (this.config.hide.indexOf(partName) !== -1) return true; + if (this.config.hide.indexOf(partName) !== -1) return true } - return false; -}; + return false +} /** Determines whether a part is wanted by the user * This depends on the 'only' setting */ Pattern.prototype.wants = function(partName) { - if ( - typeof this.settings.only === "undefined" || - this.settings.only === false - ) { - if (this.isHidden(partName)) return false; - } else if (typeof this.settings.only === "string") { - if (this.settings.only === partName) return true; - return false; + if (typeof this.settings.only === 'undefined' || this.settings.only === false) { + if (this.isHidden(partName)) return false + } else if (typeof this.settings.only === 'string') { + if (this.settings.only === partName) return true + return false } else if (Array.isArray(this.settings.only)) { for (let part of this.settings.only) { - if (part === partName) return true; + if (part === partName) return true } - return false; + return false } - return true; -}; + return true +} /** Returns props required to render this pattern through * an external renderer (eg. a React component) */ Pattern.prototype.getRenderProps = function() { - this.pack(); - let props = {}; - props.width = this.width; - props.height = this.height; - props.settings = this.settings; - props.parts = {}; + this.pack() + let props = {} + props.width = this.width + props.height = this.height + props.settings = this.settings + props.parts = {} for (let p in this.parts) { if (this.parts[p].render) { props.parts[p] = { @@ -623,9 +577,9 @@ Pattern.prototype.getRenderProps = function() { width: this.parts[p].width, bottomRight: this.parts[p].bottomRight, topLeft: this.parts[p].topLeft - }; + } } } - return props; -}; + return props +} diff --git a/packages/core/src/point.js b/packages/core/src/point.js index 93e2c2ef595..6f7ca3107f3 100644 --- a/packages/core/src/point.js +++ b/packages/core/src/point.js @@ -1,142 +1,139 @@ -import Attributes from "./attributes"; -import { round } from "./utils"; +import Attributes from './attributes' +import { round } from './utils' function Point(x, y) { - this.x = round(x); - this.y = round(y); - this.attributes = new Attributes(); + this.x = round(x) + this.y = round(y) + this.attributes = new Attributes() } /** Radians to degrees */ Point.prototype.rad2deg = function(radians) { - return radians * 57.29577951308232; -}; + return radians * 57.29577951308232 +} /** Degrees to radians */ Point.prototype.deg2rad = function(degrees) { - return degrees / 57.29577951308232; -}; + return degrees / 57.29577951308232 +} /** Adds an attribute. This is here to make this call chainable in assignment */ Point.prototype.attr = function(name, value, overwrite = false) { - if (overwrite) this.attributes.set(name, value); - else this.attributes.add(name, value); + if (overwrite) this.attributes.set(name, value) + else this.attributes.add(name, value) - return this; -}; + return this +} /** Returns the distance between this point and that point */ Point.prototype.dist = function(that) { - let dx = this.x - that.x; - let dy = this.y - that.y; + let dx = this.x - that.x + let dy = this.y - that.y - return round(Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2))); -}; + return round(Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2))) +} /** Returns slope of a line made by this point and that point */ Point.prototype.slope = function(that) { - return (that.y - this.y) / (that.x - this.x); -}; + return (that.y - this.y) / (that.x - this.x) +} /** Returns the x-delta between this point and that point */ Point.prototype.dx = function(that) { - return that.x - this.x; -}; + return that.x - this.x +} /** Returns the y-delta between this point and that point */ Point.prototype.dy = function(that) { - return that.y - this.y; -}; + return that.y - this.y +} /** Returns the angle between this point and that point */ Point.prototype.angle = function(that) { - let rad = Math.atan2(-1 * this.dy(that), this.dx(that)); - while (rad < 0) rad += 2 * Math.PI; + let rad = Math.atan2(-1 * this.dy(that), this.dx(that)) + while (rad < 0) rad += 2 * Math.PI - return this.rad2deg(rad); -}; + return this.rad2deg(rad) +} /** Rotate this point deg around that point */ Point.prototype.rotate = function(deg, that) { - let radius = this.dist(that); - let angle = this.angle(that); - let x = that.x + radius * Math.cos(this.deg2rad(angle + deg)) * -1; - let y = that.y + radius * Math.sin(this.deg2rad(angle + deg)); + let radius = this.dist(that) + let angle = this.angle(that) + let x = that.x + radius * Math.cos(this.deg2rad(angle + deg)) * -1 + let y = that.y + radius * Math.sin(this.deg2rad(angle + deg)) - return new Point(x, y); -}; + return new Point(x, y) +} /** returns an identical copy of this point */ Point.prototype.copy = function() { - return new Point(this.x, this.y); -}; + return new Point(this.x, this.y) +} /** Mirrors this point around X value of that point */ Point.prototype.flipX = function(that = false) { - if (that === false || that.x === 0) return new Point(this.x * -1, this.y); - else return new Point(that.x + this.dx(that), this.y); -}; + if (that === false || that.x === 0) return new Point(this.x * -1, this.y) + else return new Point(that.x + this.dx(that), this.y) +} /** Mirrors this point around Y value of that point */ Point.prototype.flipY = function(that = false) { - if (that === false || that.y === 0) return new Point(this.x, this.y * -1); - else return new Point(this.x, that.y + this.dy(that)); -}; + if (that === false || that.y === 0) return new Point(this.x, this.y * -1) + else return new Point(this.x, that.y + this.dy(that)) +} /** Shifts this point distance in the deg direction */ Point.prototype.shift = function(deg, distance) { - let p = this.copy(); - p.x += distance; + let p = this.copy() + p.x += distance - return p.rotate(deg, this); -}; + return p.rotate(deg, this) +} /** Shifts this point distance in the direction of that point */ Point.prototype.shiftTowards = function(that, distance) { - return this.shift(this.angle(that), distance); -}; + return this.shift(this.angle(that), distance) +} /** Checks whether this has the same coordinates as that */ Point.prototype.sitsOn = function(that) { - if (this.x === that.x && this.y === that.y) return true; - else return false; -}; + if (this.x === that.x && this.y === that.y) return true + else return false +} /** Checks whether this has roughly the same coordinates as that */ Point.prototype.sitsRoughlyOn = function(that) { - if ( - Math.round(this.x) === Math.round(that.x) && - Math.round(this.y) === Math.round(that.y) - ) - return true; - else return false; -}; + if (Math.round(this.x) === Math.round(that.x) && Math.round(this.y) === Math.round(that.y)) + return true + else return false +} /** Shifts this point fraction of the distance towards that point */ Point.prototype.shiftFractionTowards = function(that, fraction) { - return this.shiftTowards(that, this.dist(that) * fraction); -}; + return this.shiftTowards(that, this.dist(that) * fraction) +} /** Shifts this point distance beyond that point */ Point.prototype.shiftOutwards = function(that, distance) { - return this.shiftTowards(that, this.dist(that) + distance); -}; + return this.shiftTowards(that, this.dist(that) + distance) +} /** Returns a deep copy of this */ Point.prototype.clone = function() { - let clone = new Point(this.x, this.y); - clone.attributes = this.attributes.clone(); + let clone = new Point(this.x, this.y) + clone.attributes = this.attributes.clone() - return clone; -}; + return clone +} /** Applies a translate transform */ Point.prototype.translate = function(x, y) { - let p = this.copy(); - p.x += x; - p.y += y; + let p = this.copy() + p.x += x + p.y += y - return p; -}; + return p +} -export default Point; +export default Point diff --git a/packages/core/src/snippet.js b/packages/core/src/snippet.js index bd6173757c9..40cfd93d665 100644 --- a/packages/core/src/snippet.js +++ b/packages/core/src/snippet.js @@ -1,27 +1,27 @@ -import Attributes from "./attributes"; +import Attributes from './attributes' function Snippet(def, anchor) { - this.def = def; - this.anchor = anchor; - this.attributes = new Attributes(); + this.def = def + this.anchor = anchor + this.attributes = new Attributes() - return this; + return this } /** Adds an attribute. This is here to make this call chainable in assignment */ Snippet.prototype.attr = function(name, value, overwrite = false) { - if (overwrite) this.attributes.set(name, value); - else this.attributes.add(name, value); + if (overwrite) this.attributes.set(name, value) + else this.attributes.add(name, value) - return this; -}; + return this +} /** Returns a deep copy of this */ Snippet.prototype.clone = function() { - let clone = new Snippet(this.def, this.anchor.clone()); - clone.attributes = this.attributes.clone(); + let clone = new Snippet(this.def, this.anchor.clone()) + clone.attributes = this.attributes.clone() - return clone; -}; + return clone +} -export default Snippet; +export default Snippet diff --git a/packages/core/src/store.js b/packages/core/src/store.js index a75f7fe22ec..f63a6cd5cf2 100644 --- a/packages/core/src/store.js +++ b/packages/core/src/store.js @@ -1,20 +1,20 @@ function Store() { - this.data = new Map(); + this.data = new Map() } /** Sets a value under index key */ Store.prototype.set = function(key, value) { - this.data.set(key, value); -}; + this.data.set(key, value) +} /** Sets a value under index key */ Store.prototype.setIfUnset = function(key, value) { - if (!this.data.has(key)) this.data.set(key, value); -}; + if (!this.data.has(key)) this.data.set(key, value) +} /** Gets a value under index key */ Store.prototype.get = function(key) { - return this.data.get(key); -}; + return this.data.get(key) +} -export default Store; +export default Store diff --git a/packages/core/src/svg.js b/packages/core/src/svg.js index 2bc0a132adf..c945b6e9448 100644 --- a/packages/core/src/svg.js +++ b/packages/core/src/svg.js @@ -1,319 +1,306 @@ -import Attributes from "./attributes"; +import Attributes from './attributes' -import { version } from "../package.json"; +import { version } from '../package.json' function Svg(pattern) { - this.openGroups = []; - this.layout = {}; - this.freeId = 0; - this.body = ""; - this.style = ""; - this.script = ""; - this.defs = ""; - this.pattern = pattern; // Needed to expose pattern to hooks - this.prefix = ''; - this.attributes = new Attributes(); - this.attributes.add("xmlns", "http://www.w3.org/2000/svg"); - this.attributes.add("xmlns:svg", "http://www.w3.org/2000/svg"); - this.attributes.add("xmlns:xlink", "http://www.w3.org/1999/xlink"); - this.attributes.add("xml:lang", pattern.settings.locale); - this.attributes.add( - "xmlns:freesewing", - "http://freesewing.org/namespaces/freesewing" - ); - this.attributes.add("freesewing", version); + this.openGroups = [] + this.layout = {} + this.freeId = 0 + this.body = '' + this.style = '' + this.script = '' + this.defs = '' + this.pattern = pattern // Needed to expose pattern to hooks + this.prefix = '' + this.attributes = new Attributes() + this.attributes.add('xmlns', 'http://www.w3.org/2000/svg') + this.attributes.add('xmlns:svg', 'http://www.w3.org/2000/svg') + this.attributes.add('xmlns:xlink', 'http://www.w3.org/1999/xlink') + this.attributes.add('xml:lang', pattern.settings.locale) + this.attributes.add('xmlns:freesewing', 'http://freesewing.org/namespaces/freesewing') + this.attributes.add('freesewing', version) } Svg.prototype.runHooks = function(hookName, data = false) { - if (data === false) data = this; - let hooks = this.hooks[hookName]; + if (data === false) data = this + let hooks = this.hooks[hookName] if (hooks.length > 0) { for (let hook of hooks) { - hook.method(data, hook.data); + hook.method(data, hook.data) } } -}; +} /** Runs insertText hooks */ Svg.prototype.insertText = function(text) { if (this.hooks.insertText.length > 0) { for (let hook of this.hooks.insertText) - text = hook.method(this.pattern.settings.locale, text, hook.data); + text = hook.method(this.pattern.settings.locale, text, hook.data) } - return text; -}; + return text +} /** Debug method, exposes debug hook */ -Svg.prototype.debug = function() {}; +Svg.prototype.debug = function() {} /** Renders a draft object as SVG */ Svg.prototype.render = function(pattern) { - this.idPrefix = pattern.settings.idPrefix; - this.runHooks("preRender"); + this.idPrefix = pattern.settings.idPrefix + this.runHooks('preRender') if (!pattern.settings.embed) { - this.attributes.add("width", pattern.width + "mm"); - this.attributes.add("height", pattern.height + "mm"); + this.attributes.add('width', pattern.width + 'mm') + this.attributes.add('height', pattern.height + 'mm') } - this.attributes.add("viewBox", `0 0 ${pattern.width} ${pattern.height}`); - this.head = this.renderHead(); - this.tail = this.renderTail(); - this.svg = ""; - this.layout = {}; // Reset layout + this.attributes.add('viewBox', `0 0 ${pattern.width} ${pattern.height}`) + this.head = this.renderHead() + this.tail = this.renderTail() + this.svg = '' + this.layout = {} // Reset layout for (let partId in pattern.parts) { - let part = pattern.parts[partId]; + let part = pattern.parts[partId] if (part.render) { - let partSvg = this.renderPart(part); + let partSvg = this.renderPart(part) this.layout[partId] = { svg: partSvg, - transform: part.attributes.getAsArray("transform") - }; - this.svg += this.openGroup( - `${this.idPrefix}part-${partId}`, - part.attributes - ); - this.svg += partSvg; - this.svg += this.closeGroup(); + transform: part.attributes.getAsArray('transform') + } + this.svg += this.openGroup(`${this.idPrefix}part-${partId}`, part.attributes) + this.svg += partSvg + this.svg += this.closeGroup() } } - this.svg = - this.prefix + this.renderSvgTag() + this.head + this.svg + this.tail; - this.runHooks("postRender"); + this.svg = this.prefix + this.renderSvgTag() + this.head + this.svg + this.tail + this.runHooks('postRender') - return this.svg; -}; + return this.svg +} /** Renders SVG head section */ Svg.prototype.renderHead = function() { - let svg = this.renderStyle(); - svg += this.renderScript(); - svg += this.renderDefs(); - svg += this.openGroup(this.idPrefix + "container"); + let svg = this.renderStyle() + svg += this.renderScript() + svg += this.renderDefs() + svg += this.openGroup(this.idPrefix + 'container') - return svg; -}; + return svg +} /** Renders SVG closing section */ Svg.prototype.renderTail = function() { - let svg = ""; - svg += this.closeGroup(); - svg += this.nl() + ""; + let svg = '' + svg += this.closeGroup() + svg += this.nl() + '' - return svg; -}; + return svg +} /** Returns SVG code for the opening SVG tag */ Svg.prototype.renderSvgTag = function() { - let svg = "" + this.nl(); + let svg = '' + this.nl() - return svg; -}; + return svg +} /** Returns SVG code for the style block */ Svg.prototype.renderStyle = function() { - let svg = '" + this.nl(); - return svg; -}; + let svg = '' + this.nl() + return svg +} /** Returns SVG code for the script block */ Svg.prototype.renderScript = function() { - let svg = '" + this.nl(); + let svg = '' + this.nl() - return svg; -}; + return svg +} /** Returns SVG code for the defs block */ Svg.prototype.renderDefs = function() { - let svg = ""; - this.indent(); - svg += this.nl() + this.defs; - this.outdent(); - svg += this.nl() + "" + this.nl(); + let svg = '' + this.indent() + svg += this.nl() + this.defs + this.outdent() + svg += this.nl() + '' + this.nl() - return svg; -}; + return svg +} /** Returns SVG code for a Part object */ Svg.prototype.renderPart = function(part) { - let svg = ""; + let svg = '' for (let key in part.paths) { - let path = part.paths[key]; - if (path.render) svg += this.renderPath(path); + let path = part.paths[key] + if (path.render) svg += this.renderPath(path) } for (let key in part.points) { - if (part.points[key].attributes.get("data-text")) { - svg += this.renderText(part.points[key]); + if (part.points[key].attributes.get('data-text')) { + svg += this.renderText(part.points[key]) } - if (part.points[key].attributes.get("data-circle")) { - svg += this.renderCircle(part.points[key]); + if (part.points[key].attributes.get('data-circle')) { + svg += this.renderCircle(part.points[key]) } } for (let key in part.snippets) { - let snippet = part.snippets[key]; - svg += this.renderSnippet(snippet, part); + let snippet = part.snippets[key] + svg += this.renderSnippet(snippet, part) } - return svg; -}; + return svg +} /** Returns SVG code for a Path object */ Svg.prototype.renderPath = function(path) { - if (!path.attributes.get("id")) - path.attributes.add("id", this.idPrefix + this.getId()); - path.attributes.set("d", path.asPathstring()); + if (!path.attributes.get('id')) path.attributes.add('id', this.idPrefix + this.getId()) + path.attributes.set('d', path.asPathstring()) - return `${this.nl()}${this.renderPathText( - path - )}`; -}; + return `${this.nl()}${this.renderPathText(path)}` +} Svg.prototype.renderPathText = function(path) { - let text = path.attributes.get("data-text"); - if (!text) return ""; - else this.text = this.insertText(text); - let attributes = path.attributes.renderIfPrefixIs("data-text-"); + let text = path.attributes.get('data-text') + if (!text) return '' + else this.text = this.insertText(text) + let attributes = path.attributes.renderIfPrefixIs('data-text-') // Sadly aligning text along a patch can't be done in CSS only - let offset = ""; - let align = path.attributes.get("data-text-class"); - if (align && align.indexOf("center") > -1) offset = ' startOffset="50%" '; - else if (align && align.indexOf("right") > -1) - offset = ' startOffset="100%" '; - let svg = this.nl() + ""; - this.indent(); - svg += `${this.text}`; - this.outdent(); - svg += this.nl() + ""; + let offset = '' + let align = path.attributes.get('data-text-class') + if (align && align.indexOf('center') > -1) offset = ' startOffset="50%" ' + else if (align && align.indexOf('right') > -1) offset = ' startOffset="100%" ' + let svg = this.nl() + '' + this.indent() + svg += `${ + this.text + }` + this.outdent() + svg += this.nl() + '' - return svg; -}; + return svg +} Svg.prototype.renderText = function(point) { - let text = point.attributes.getAsArray("data-text"); + let text = point.attributes.getAsArray('data-text') if (text !== false) { - let joint = ""; + let joint = '' for (let string of text) { - this.text = this.insertText(string); - joint += this.text + " "; + this.text = this.insertText(string) + joint += this.text + ' ' } - this.text = this.insertText(joint); + this.text = this.insertText(joint) } - point.attributes.set("data-text-x", point.x); - point.attributes.set("data-text-y", point.y); - let lineHeight = point.attributes.get("data-text-lineheight") || 12; - point.attributes.remove("data-text-lineheight"); - let svg = `${this.nl()}`; - this.indent(); + point.attributes.set('data-text-x', point.x) + point.attributes.set('data-text-y', point.y) + let lineHeight = point.attributes.get('data-text-lineheight') || 12 + point.attributes.remove('data-text-lineheight') + let svg = `${this.nl()}` + this.indent() // Multi-line text? - if (this.text.indexOf("\n") !== -1) { - let lines = this.text.split("\n"); - svg += `${lines.shift()}`; + if (this.text.indexOf('\n') !== -1) { + let lines = this.text.split('\n') + svg += `${lines.shift()}` for (let line of lines) { - svg += `${line}`; + svg += `${line}` } } else { - svg += `${this.text}`; + svg += `${this.text}` } - this.outdent(); - svg += this.nl() + ""; + this.outdent() + svg += this.nl() + '' - return svg; -}; + return svg +} Svg.prototype.renderCircle = function(point) { return ``; -}; + 'data-circle' + )}" ${point.attributes.renderIfPrefixIs('data-circle-')}>` +} /** Returns SVG code for a snippet */ Svg.prototype.renderSnippet = function(snippet, part) { - let x = snippet.anchor.x; - let y = snippet.anchor.y; - let scale = snippet.attributes.get("data-scale"); + let x = snippet.anchor.x + let y = snippet.anchor.y + let scale = snippet.attributes.get('data-scale') if (scale) { - snippet.attributes.add("transform", `translate(${x}, ${y})`); - snippet.attributes.add("transform", `scale(${scale})`); - snippet.attributes.add("transform", `translate(${x * -1}, ${y * -1})`); + snippet.attributes.add('transform', `translate(${x}, ${y})`) + snippet.attributes.add('transform', `scale(${scale})`) + snippet.attributes.add('transform', `translate(${x * -1}, ${y * -1})`) } - let rotate = snippet.attributes.get("data-rotate"); + let rotate = snippet.attributes.get('data-rotate') if (rotate) { - snippet.attributes.add("transform", `rotate(${rotate}, ${x}, ${y})`); + snippet.attributes.add('transform', `rotate(${rotate}, ${x}, ${y})`) } - let svg = this.nl(); - svg += ``; - svg += ""; + let svg = this.nl() + svg += `` + svg += '' - return svg; -}; + return svg +} /** Returns SVG code to open a group */ Svg.prototype.openGroup = function(id, attributes = false) { - let svg = this.nl() + this.nl(); - svg += ``; - svg += this.nl(); - svg += `` + svg += this.nl() + svg += `${this.nl()}`; -}; + return `${this.nl()}${this.nl()}` +} /** Returns a linebreak + identation */ Svg.prototype.nl = function() { - return "\n" + this.tab(); -}; + return '\n' + this.tab() +} /** Returns indentation */ Svg.prototype.tab = function() { - let space = ""; + let space = '' for (let i = 0; i < this.tabs; i++) { - space += " "; + space += ' ' } - return space; -}; + return space +} /** Increases indentation by 1 */ Svg.prototype.indent = function() { - this.tabs += 1; -}; + this.tabs += 1 +} /** Decreases indentation by 1 */ Svg.prototype.outdent = function() { - this.tabs -= 1; -}; + this.tabs -= 1 +} /** Returns an unused ID */ Svg.prototype.getId = function() { - this.freeId += 1; + this.freeId += 1 - return "" + this.freeId; -}; + return '' + this.freeId +} -export default Svg; +export default Svg diff --git a/packages/core/src/utils.js b/packages/core/src/utils.js index 17477178424..a3c5b8346cf 100644 --- a/packages/core/src/utils.js +++ b/packages/core/src/utils.js @@ -1,95 +1,89 @@ -import Path from "./path"; -import Point from "./point"; -import Bezier from "bezier-js"; +import Path from './path' +import Point from './point' +import Bezier from 'bezier-js' export function capitalize(string) { - return string.charAt(0).toUpperCase() + string.slice(1); + return string.charAt(0).toUpperCase() + string.slice(1) } /** Returns internal hook name for a macro */ export function macroName(name) { - return `_macro_${name}`; + return `_macro_${name}` } /** Find intersection of two (endless) lines */ export function beamsIntersect(a1, a2, b1, b2) { - let slopeA = a1.slope(a2); - let slopeB = b1.slope(b2); - if (slopeA === slopeB) return false; // Parallel lines + let slopeA = a1.slope(a2) + let slopeB = b1.slope(b2) + if (slopeA === slopeB) return false // Parallel lines - if (a1.x === a2.x) - return new Point(a1.x, slopeB * a1.x + (b1.y - slopeB * b1.x)); + if (a1.x === a2.x) return new Point(a1.x, slopeB * a1.x + (b1.y - slopeB * b1.x)) // Vertical line A - else if (b1.x === b2.x) - return new Point(b1.x, slopeA * b1.x + (a1.y - slopeA * a1.x)); + else if (b1.x === b2.x) return new Point(b1.x, slopeA * b1.x + (a1.y - slopeA * a1.x)) // Vertical line B else { // Swap points if line A or B goes from right to left - if (a1.x > a2.x) a1 = a2.copy(); - if (b1.x > b2.x) b1 = b2.copy(); + if (a1.x > a2.x) a1 = a2.copy() + if (b1.x > b2.x) b1 = b2.copy() // Find y intercept - let iA = a1.y - slopeA * a1.x; - let iB = b1.y - slopeB * b1.x; + let iA = a1.y - slopeA * a1.x + let iB = b1.y - slopeB * b1.x // Find intersection - let x = (iB - iA) / (slopeA - slopeB); - let y = slopeA * x + iA; + let x = (iB - iA) / (slopeA - slopeB) + let y = slopeA * x + iA - return new Point(x, y); + return new Point(x, y) } } /** Find intersection of two line segments */ export function linesIntersect(a1, a2, b1, b2) { - let p = beamsIntersect(a1, a2, b1, b2); - if (!p) return false; - let lenA = a1.dist(a2); - let lenB = b1.dist(b2); - let lenC = a1.dist(p) + p.dist(a2); - let lenD = b1.dist(p) + p.dist(b2); - if ( - Math.round(lenA) == Math.round(lenC) && - Math.round(lenB) == Math.round(lenD) - ) - return p; - else return false; + let p = beamsIntersect(a1, a2, b1, b2) + if (!p) return false + let lenA = a1.dist(a2) + let lenB = b1.dist(b2) + let lenC = a1.dist(p) + p.dist(a2) + let lenD = b1.dist(p) + p.dist(b2) + if (Math.round(lenA) == Math.round(lenC) && Math.round(lenB) == Math.round(lenD)) return p + else return false } /** Finds out whether a point lies on an endless line */ export function pointOnBeam(from, to, check, precision = 1e6) { - if (from.sitsOn(check)) return true; - if (to.sitsOn(check)) return true; - let cross = check.dx(from) * to.dy(from) - check.dy(from) * to.dx(from); + if (from.sitsOn(check)) return true + if (to.sitsOn(check)) return true + let cross = check.dx(from) * to.dy(from) - check.dy(from) * to.dx(from) - if (Math.abs(Math.round(cross * precision) / precision) === 0) return true; - else return false; + if (Math.abs(Math.round(cross * precision) / precision) === 0) return true + else return false } /** Finds out whether a point lies on a line segment */ export function pointOnLine(from, to, check, precision = 1e6) { - if (!pointOnBeam(from, to, check, precision)) return false; - let lenA = from.dist(to); - let lenB = from.dist(check) + check.dist(to); - if (Math.round(lenA) == Math.round(lenB)) return true; - else return false; + if (!pointOnBeam(from, to, check, precision)) return false + let lenA = from.dist(to) + let lenB = from.dist(check) + check.dist(to) + if (Math.round(lenA) == Math.round(lenB)) return true + else return false } /** Finds out whether a point lies on a curve */ export function pointOnCurve(start, cp1, cp2, end, check) { - if (start.sitsOn(check)) return true; - if (end.sitsOn(check)) return true; + if (start.sitsOn(check)) return true + if (end.sitsOn(check)) return true let curve = new Bezier( { x: start.x, y: start.y }, { x: cp1.x, y: cp1.y }, { x: cp2.x, y: cp2.y }, { x: end.x, y: end.y } - ); + ) let intersections = curve.intersects({ p1: { x: check.x - 1, y: check.y }, p2: { x: check.x + 1, y: check.y } - }); - if (intersections.length > 0) return intersections.shift(); - else return false; + }) + if (intersections.length > 0) return intersections.shift() + else return false } /** Splits a curve on a point */ @@ -97,7 +91,7 @@ export function splitCurve(start, cp1, cp2, end, split) { let [c1, c2] = new Path() .move(start) .curve(cp1, cp2, end) - .split(split); + .split(split) return [ { @@ -112,215 +106,201 @@ export function splitCurve(start, cp1, cp2, end, split) { cp2: c2.ops[1].cp2, end: c2.ops[1].to } - ]; + ] } /** Find where an (endless) line intersects with a certain X-value */ export function beamIntersectsX(from, to, x) { - if (from.x === to.x) return false; // Vertical line - let top = new Point(x, -10); - let bottom = new Point(x, 10); + if (from.x === to.x) return false // Vertical line + let top = new Point(x, -10) + let bottom = new Point(x, 10) - return beamsIntersect(from, to, top, bottom); + return beamsIntersect(from, to, top, bottom) } /** Find where an (endless) line intersects with a certain Y-value */ export function beamIntersectsY(from, to, y) { - if (from.y === to.y) return false; // Horizontal line - let left = new Point(-10, y); - let right = new Point(10, y); + if (from.y === to.y) return false // Horizontal line + let left = new Point(-10, y) + let right = new Point(10, y) - return beamsIntersect(from, to, left, right); + return beamsIntersect(from, to, left, right) } /** Convert value in mm to cm or imperial units */ -export function units(value, to = "metric") { - if (to === "imperial") return round(value / 25.4) + '"'; - else return round(value / 10) + "cm"; +export function units(value, to = 'metric') { + if (to === 'imperial') return round(value / 25.4) + '"' + else return round(value / 10) + 'cm' } /** Find where a curve intersects with line */ export function lineIntersectsCurve(start, end, from, cp1, cp2, to) { - let intersections = []; + let intersections = [] let bz = new Bezier( { x: from.x, y: from.y }, { x: cp1.x, y: cp1.y }, { x: cp2.x, y: cp2.y }, { x: to.x, y: to.y } - ); + ) let line = { p1: { x: start.x, y: start.y }, p2: { x: end.x, y: end.y } - }; + } for (let t of bz.intersects(line)) { - let isect = bz.get(t); - intersections.push(new Point(isect.x, isect.y)); + let isect = bz.get(t) + intersections.push(new Point(isect.x, isect.y)) } - if (intersections.length === 0) return false; - else if (intersections.length === 1) return intersections[0]; - else return intersections; + if (intersections.length === 0) return false + else if (intersections.length === 1) return intersections[0] + else return intersections } /** Find where a curve intersects with a given X-value */ export function curveIntersectsX(from, cp1, cp2, to, x) { - let start = new Point(x, -10000); - let end = new Point(x, 10000); - return lineIntersectsCurve(start, end, from, cp1, cp2, to); + let start = new Point(x, -10000) + let end = new Point(x, 10000) + return lineIntersectsCurve(start, end, from, cp1, cp2, to) } /** Find where a curve intersects with a given Y-value */ export function curveIntersectsY(from, cp1, cp2, to, y) { - let start = new Point(-10000, y); - let end = new Point(10000, y); - return lineIntersectsCurve(start, end, from, cp1, cp2, to); + let start = new Point(-10000, y) + let end = new Point(10000, y) + return lineIntersectsCurve(start, end, from, cp1, cp2, to) } /** Find where a curve intersects with another curve */ -export function curvesIntersect( - fromA, - cp1A, - cp2A, - toA, - fromB, - cp1B, - cp2B, - toB -) { - let precision = 0.005; // See https://github.com/Pomax/bezierjs/issues/99 - let intersections = []; +export function curvesIntersect(fromA, cp1A, cp2A, toA, fromB, cp1B, cp2B, toB) { + let precision = 0.005 // See https://github.com/Pomax/bezierjs/issues/99 + let intersections = [] let curveA = new Bezier( { x: fromA.x, y: fromA.y }, { x: cp1A.x, y: cp1A.y }, { x: cp2A.x, y: cp2A.y }, { x: toA.x, y: toA.y } - ); + ) let curveB = new Bezier( { x: fromB.x, y: fromB.y }, { x: cp1B.x, y: cp1B.y }, { x: cp2B.x, y: cp2B.y }, { x: toB.x, y: toB.y } - ); + ) for (let tvalues of curveA.intersects(curveB, precision)) { - let intersection = curveA.get(tvalues.substr(0, tvalues.indexOf("/"))); - intersections.push(new Point(intersection.x, intersection.y)); + let intersection = curveA.get(tvalues.substr(0, tvalues.indexOf('/'))) + intersections.push(new Point(intersection.x, intersection.y)) } - if (intersections.length === 0) return false; - else if (intersections.length === 1) return intersections.shift(); + if (intersections.length === 0) return false + else if (intersections.length === 1) return intersections.shift() else { - let unique = []; + let unique = [] for (let i of intersections) { - let dupe = false; + let dupe = false for (let u of unique) { - if (i.sitsRoughlyOn(u)) dupe = true; + if (i.sitsRoughlyOn(u)) dupe = true } - if (!dupe) unique.push(i); + if (!dupe) unique.push(i) } - return unique; + return unique } } /** Find the intersections between two circles */ -export function circlesIntersect(c1, r1, c2, r2, sort = "x") { - let dx = c1.dx(c2); - let dy = c1.dy(c2); - let dist = c1.dist(c2); +export function circlesIntersect(c1, r1, c2, r2, sort = 'x') { + let dx = c1.dx(c2) + let dy = c1.dy(c2) + let dist = c1.dist(c2) // Check for edge cases - if (dist > parseFloat(r1) + parseFloat(r2)) return false; // Circles do not intersect - if (dist < parseFloat(r2) - parseFloat(r1)) return false; // One circle is contained in the other - if (dist === 0 && r1 === r2) return false; // Two circles are identical - let chorddistance = - (Math.pow(r1, 2) - Math.pow(r2, 2) + Math.pow(dist, 2)) / (2 * dist); - let halfchordlength = Math.sqrt(Math.pow(r1, 2) - Math.pow(chorddistance, 2)); - let chordmidpointx = c1.x + (chorddistance * dx) / dist; - let chordmidpointy = c1.y + (chorddistance * dy) / dist; + if (dist > parseFloat(r1) + parseFloat(r2)) return false // Circles do not intersect + if (dist < parseFloat(r2) - parseFloat(r1)) return false // One circle is contained in the other + if (dist === 0 && r1 === r2) return false // Two circles are identical + let chorddistance = (Math.pow(r1, 2) - Math.pow(r2, 2) + Math.pow(dist, 2)) / (2 * dist) + let halfchordlength = Math.sqrt(Math.pow(r1, 2) - Math.pow(chorddistance, 2)) + let chordmidpointx = c1.x + (chorddistance * dx) / dist + let chordmidpointy = c1.y + (chorddistance * dy) / dist let i1 = new Point( chordmidpointx + (halfchordlength * dy) / dist, chordmidpointy - (halfchordlength * dx) / dist - ); + ) let i2 = new Point( chordmidpointx - (halfchordlength * dy) / dist, chordmidpointy + (halfchordlength * dx) / dist - ); + ) - if ((sort === "x" && i1.x <= i2.x) || (sort === "y" && i1.y <= i2.y)) - return [i1, i2]; - else return [i2, i1]; + if ((sort === 'x' && i1.x <= i2.x) || (sort === 'y' && i1.y <= i2.y)) return [i1, i2] + else return [i2, i1] } /** Find the intersections between a beam and a circle */ -export function beamIntersectsCircle(c, r, p1, p2, sort = "x") { - let dx = p2.x - p1.x; - let dy = p2.y - p1.y; - let A = Math.pow(dx, 2) + Math.pow(dy, 2); - let B = 2 * (dx * (p1.x - c.x) + dy * (p1.y - c.y)); - let C = Math.pow(p1.x - c.x, 2) + Math.pow(p1.y - c.y, 2) - Math.pow(r, 2); +export function beamIntersectsCircle(c, r, p1, p2, sort = 'x') { + let dx = p2.x - p1.x + let dy = p2.y - p1.y + let A = Math.pow(dx, 2) + Math.pow(dy, 2) + let B = 2 * (dx * (p1.x - c.x) + dy * (p1.y - c.y)) + let C = Math.pow(p1.x - c.x, 2) + Math.pow(p1.y - c.y, 2) - Math.pow(r, 2) - let det = Math.pow(B, 2) - 4 * A * C; + let det = Math.pow(B, 2) - 4 * A * C - if (A <= 0.0000001 || det < 0) return false; + if (A <= 0.0000001 || det < 0) return false // No real solutions else if (det === 0) { // One solution - let t = (-1 * B) / (2 * A); - let i1 = new Point(p1.x + t * dx, p1.y + t * dy); - return [i1]; + let t = (-1 * B) / (2 * A) + let i1 = new Point(p1.x + t * dx, p1.y + t * dy) + return [i1] } else { // Two solutions - let t = (-1 * B + Math.sqrt(det)) / (2 * A); - let i1 = new Point(p1.x + t * dx, p1.y + t * dy); - t = (-1 * B - Math.sqrt(det)) / (2 * A); - let i2 = new Point(p1.x + t * dx, p1.y + t * dy); - if ((sort === "x" && i1.x <= i2.x) || (sort === "y" && i1.y <= i2.y)) - return [i1, i2]; - else return [i2, i1]; + let t = (-1 * B + Math.sqrt(det)) / (2 * A) + let i1 = new Point(p1.x + t * dx, p1.y + t * dy) + t = (-1 * B - Math.sqrt(det)) / (2 * A) + let i2 = new Point(p1.x + t * dx, p1.y + t * dy) + if ((sort === 'x' && i1.x <= i2.x) || (sort === 'y' && i1.y <= i2.y)) return [i1, i2] + else return [i2, i1] } } /** Find the intersections between a line and a circle */ -export function lineIntersectsCircle(c, r, p1, p2, sort = "x") { - let intersections = beamIntersectsCircle(c, r, p1, p2, sort); - if (intersections === false) return false; +export function lineIntersectsCircle(c, r, p1, p2, sort = 'x') { + let intersections = beamIntersectsCircle(c, r, p1, p2, sort) + if (intersections === false) return false else { if (intersections.length === 1) { - if (pointOnLine(p1, p2, intersections[0])) return intersections; - else return false; + if (pointOnLine(p1, p2, intersections[0])) return intersections + else return false } else { - let i1 = intersections[0]; - let i2 = intersections[1]; - if (!pointOnLine(p1, p2, i1, 5) && !pointOnLine(p1, p2, i2, 5)) - return false; + let i1 = intersections[0] + let i2 = intersections[1] + if (!pointOnLine(p1, p2, i1, 5) && !pointOnLine(p1, p2, i2, 5)) return false else if (pointOnLine(p1, p2, i1, 5) && pointOnLine(p1, p2, i2, 5)) { - if ((sort === "x" && i1.x <= i2.x) || (sort === "y" && i1.y <= i2.y)) - return [i1, i2]; - else return [i2, i1]; - } else if (pointOnLine(p1, p2, i1, 5)) return [i1]; - else if (pointOnLine(p1, p2, i2, 5)) return [i2]; + if ((sort === 'x' && i1.x <= i2.x) || (sort === 'y' && i1.y <= i2.y)) return [i1, i2] + else return [i2, i1] + } else if (pointOnLine(p1, p2, i1, 5)) return [i1] + else if (pointOnLine(p1, p2, i2, 5)) return [i2] } } } export function curveEdge(curve, edge, steps = 500) { - let x = Infinity; - let y = Infinity; - let p; - if (edge === "bottom") y = -Infinity; - if (edge === "right") x = -Infinity; + let x = Infinity + let y = Infinity + let p + if (edge === 'bottom') y = -Infinity + if (edge === 'right') x = -Infinity for (let i = 0; i < steps; i++) { - p = curve.get(i / steps); + p = curve.get(i / steps) if ( - (edge === "top" && p.y < y) || - (edge === "bottom" && p.y > y) || - (edge === "right" && p.x > x) || - (edge === "left" && p.x < x) + (edge === 'top' && p.y < y) || + (edge === 'bottom' && p.y > y) || + (edge === 'right' && p.x > x) || + (edge === 'left' && p.x < x) ) { - x = p.x; - y = p.y; + x = p.x + y = p.y } } - return new Point(x, y); + return new Point(x, y) } /** @@ -335,23 +315,23 @@ export function curveEdge(curve, edge, steps = 500) { * This method does that calculation. */ export function stretchToScale(stretch) { - return 1 / (1 + parseFloat(stretch)); + return 1 / (1 + parseFloat(stretch)) } export function round(value) { - return Math.round(value * 1e2) / 1e2; + return Math.round(value * 1e2) / 1e2 } export function sampleStyle(run, runs) { - let hue = (run - 1) * (330 / runs); + let hue = (run - 1) * (330 / runs) - return `stroke: hsl(${hue}, 100%, 35%);`; + return `stroke: hsl(${hue}, 100%, 35%);` } export function deg2rad(degrees) { - return degrees * (Math.PI / 180); + return degrees * (Math.PI / 180) } export function rad2deg(radians) { - return (radians / Math.PI) * 180; + return (radians / Math.PI) * 180 } diff --git a/packages/create-freesewing-pattern/template/default/example/src/App.js b/packages/create-freesewing-pattern/template/default/example/src/App.js index bbc3f63ac46..42ba25f6974 100644 --- a/packages/create-freesewing-pattern/template/default/example/src/App.js +++ b/packages/create-freesewing-pattern/template/default/example/src/App.js @@ -1,14 +1,14 @@ -import React from "react"; -import freesewing from "@freesewing/core"; -import Workbench from "@freesewing/components/Workbench"; -import "typeface-roboto-condensed"; -import "@freesewing/css-theme"; +import React from 'react' +import freesewing from '@freesewing/core' +import Workbench from '@freesewing/components/Workbench' +import 'typeface-roboto-condensed' +import '@freesewing/css-theme' -import Pattern from "pattern"; +import Pattern from 'pattern' const App = props => { - let instance = new Pattern(); - let config = instance.config; + let instance = new Pattern() + let config = instance.config return ( { config={config} userLanguage="{{language}}" /> - ); -}; + ) +} -export default App; +export default App diff --git a/packages/create-freesewing-pattern/template/default/example/src/App.test.js b/packages/create-freesewing-pattern/template/default/example/src/App.test.js index 23c181f0276..4bf19359ea4 100644 --- a/packages/create-freesewing-pattern/template/default/example/src/App.test.js +++ b/packages/create-freesewing-pattern/template/default/example/src/App.test.js @@ -1,9 +1,9 @@ -import React from "react"; -import ReactDOM from "react-dom"; -import App from "./App"; +import React from 'react' +import ReactDOM from 'react-dom' +import App from './App' -it("renders without crashing", () => { - const div = document.createElement("div"); - ReactDOM.render(, div); - ReactDOM.unmountComponentAtNode(div); -}); +it('renders without crashing', () => { + const div = document.createElement('div') + ReactDOM.render(, div) + ReactDOM.unmountComponentAtNode(div) +}) diff --git a/packages/create-freesewing-pattern/template/default/example/src/index.js b/packages/create-freesewing-pattern/template/default/example/src/index.js index 7900787a4d2..9dd7ba788d4 100644 --- a/packages/create-freesewing-pattern/template/default/example/src/index.js +++ b/packages/create-freesewing-pattern/template/default/example/src/index.js @@ -1,11 +1,11 @@ -import React from "react"; -import ReactDOM from "react-dom"; -import App from "./App"; -import * as serviceWorker from "./serviceWorker"; +import React from 'react' +import ReactDOM from 'react-dom' +import App from './App' +import * as serviceWorker from './serviceWorker' -ReactDOM.render(, document.getElementById("root")); +ReactDOM.render(, document.getElementById('root')) // If you want your app to work offline and load faster, you can change // unregister() to register() below. Note this comes with some pitfalls. // Learn more about service workers: http://bit.ly/CRA-PWA -serviceWorker.unregister(); +serviceWorker.unregister() diff --git a/packages/create-freesewing-pattern/template/default/example/src/serviceWorker.js b/packages/create-freesewing-pattern/template/default/example/src/serviceWorker.js index 68fda5a0eb6..44e1b1b2f8c 100644 --- a/packages/create-freesewing-pattern/template/default/example/src/serviceWorker.js +++ b/packages/create-freesewing-pattern/template/default/example/src/serviceWorker.js @@ -9,46 +9,44 @@ // This link also includes instructions on opting out of this behavior. const isLocalhost = Boolean( - window.location.hostname === "localhost" || + window.location.hostname === 'localhost' || // [::1] is the IPv6 localhost address. - window.location.hostname === "[::1]" || + window.location.hostname === '[::1]' || // 127.0.0.1/8 is considered localhost for IPv4. - window.location.hostname.match( - /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ - ) -); + window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/) +) export function register(config) { - if (process.env.NODE_ENV === "production" && "serviceWorker" in navigator) { + if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) { // The URL constructor is available in all browsers that support SW. - const publicUrl = new URL(process.env.PUBLIC_URL, window.location); + const publicUrl = new URL(process.env.PUBLIC_URL, window.location) if (publicUrl.origin !== window.location.origin) { // Our service worker won't work if PUBLIC_URL is on a different origin // from what our page is served on. This might happen if a CDN is used to // serve assets; see https://github.com/facebook/create-react-app/issues/2374 - return; + return } - window.addEventListener("load", () => { - const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; + window.addEventListener('load', () => { + const swUrl = `${process.env.PUBLIC_URL}/service-worker.js` if (isLocalhost) { // This is running on localhost. Let's check if a service worker still exists or not. - checkValidServiceWorker(swUrl, config); + checkValidServiceWorker(swUrl, config) // Add some additional logging to localhost, pointing developers to the // service worker/PWA documentation. navigator.serviceWorker.ready.then(() => { console.log( - "This web app is being served cache-first by a service " + - "worker. To learn more, visit https://goo.gl/SC7cgQ" - ); - }); + 'This web app is being served cache-first by a service ' + + 'worker. To learn more, visit https://goo.gl/SC7cgQ' + ) + }) } else { // Is not local host. Just register service worker - registerValidSW(swUrl, config); + registerValidSW(swUrl, config) } - }); + }) } } @@ -57,38 +55,38 @@ function registerValidSW(swUrl, config) { .register(swUrl) .then(registration => { registration.onupdatefound = () => { - const installingWorker = registration.installing; + const installingWorker = registration.installing installingWorker.onstatechange = () => { - if (installingWorker.state === "installed") { + if (installingWorker.state === 'installed') { if (navigator.serviceWorker.controller) { // At this point, the old content will have been purged and // the fresh content will have been added to the cache. // It's the perfect time to display a "New content is // available; please refresh." message in your web app. - console.log("New content is available; please refresh."); + console.log('New content is available; please refresh.') // Execute callback if (config.onUpdate) { - config.onUpdate(registration); + config.onUpdate(registration) } } else { // At this point, everything has been precached. // It's the perfect time to display a // "Content is cached for offline use." message. - console.log("Content is cached for offline use."); + console.log('Content is cached for offline use.') // Execute callback if (config.onSuccess) { - config.onSuccess(registration); + config.onSuccess(registration) } } } - }; - }; + } + } }) .catch(error => { - console.error("Error during service worker registration:", error); - }); + console.error('Error during service worker registration:', error) + }) } function checkValidServiceWorker(swUrl, config) { @@ -98,30 +96,28 @@ function checkValidServiceWorker(swUrl, config) { // Ensure service worker exists, and that we really are getting a JS file. if ( response.status === 404 || - response.headers.get("content-type").indexOf("javascript") === -1 + response.headers.get('content-type').indexOf('javascript') === -1 ) { // No service worker found. Probably a different app. Reload the page. navigator.serviceWorker.ready.then(registration => { registration.unregister().then(() => { - window.location.reload(); - }); - }); + window.location.reload() + }) + }) } else { // Service worker found. Proceed as normal. - registerValidSW(swUrl, config); + registerValidSW(swUrl, config) } }) .catch(() => { - console.log( - "No internet connection found. App is running in offline mode." - ); - }); + console.log('No internet connection found. App is running in offline mode.') + }) } export function unregister() { - if ("serviceWorker" in navigator) { + if ('serviceWorker' in navigator) { navigator.serviceWorker.ready.then(registration => { - registration.unregister(); - }); + registration.unregister() + }) } } diff --git a/packages/create-freesewing-pattern/template/default/src/box.js b/packages/create-freesewing-pattern/template/default/src/box.js index c94c7fc6633..b22cbb1053f 100644 --- a/packages/create-freesewing-pattern/template/default/src/box.js +++ b/packages/create-freesewing-pattern/template/default/src/box.js @@ -11,13 +11,13 @@ export default function(part) { sa, paperless, macro - } = part.shorthand(); + } = part.shorthand() - let w = 500 * options.size; - points.topLeft = new Point(0, 0); - points.topRight = new Point(w, 0); - points.bottomLeft = new Point(0, w / 2); - points.bottomRight = new Point(w, w / 2); + let w = 500 * options.size + points.topLeft = new Point(0, 0) + points.topRight = new Point(w, 0) + points.bottomLeft = new Point(0, w / 2) + points.bottomRight = new Point(w, w / 2) paths.seam = new Path() .move(points.topLeft) @@ -26,35 +26,35 @@ export default function(part) { .line(points.topRight) .line(points.topLeft) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') // Complete? if (complete) { - points.logo = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5); - snippets.logo = new Snippet("logo", points.logo); + points.logo = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5) + snippets.logo = new Snippet('logo', points.logo) points.text = points.logo .shift(-90, w / 8) - .attr("data-text", "hello") - .attr("data-text-class", "center"); + .attr('data-text', 'hello') + .attr('data-text-class', 'center') if (sa) { - paths.sa = paths.seam.offset(sa).attr("class", "fabric sa"); + paths.sa = paths.seam.offset(sa).attr('class', 'fabric sa') } } // Paperless? if (paperless) { - macro("hd", { + macro('hd', { from: points.bottomLeft, to: points.bottomRight, y: points.bottomLeft.y + sa + 15 - }); - macro("vd", { + }) + macro('vd', { from: points.bottomRight, to: points.topRight, x: points.topRight.x + sa + 15 - }); + }) } - return part; + return part } diff --git a/packages/create-freesewing-pattern/template/default/src/index.js b/packages/create-freesewing-pattern/template/default/src/index.js index 1e1f8bfd067..79f79fffeb3 100644 --- a/packages/create-freesewing-pattern/template/default/src/index.js +++ b/packages/create-freesewing-pattern/template/default/src/index.js @@ -1,12 +1,12 @@ -import freesewing from "@freesewing/core"; -import plugins from "@freesewing/plugin-bundle"; -import config from "../config"; -import draftBox from "./box"; +import freesewing from '@freesewing/core' +import plugins from '@freesewing/plugin-bundle' +import config from '../config' +import draftBox from './box' // Create new design -const Pattern = new freesewing.Design(config, plugins); +const Pattern = new freesewing.Design(config, plugins) // Attach the draft methods to the prototype -Pattern.prototype.draftBox = draftBox; +Pattern.prototype.draftBox = draftBox -export default Pattern; +export default Pattern diff --git a/packages/examples/example/src/App.js b/packages/examples/example/src/App.js index e7936330e5d..115cdf683af 100644 --- a/packages/examples/example/src/App.js +++ b/packages/examples/example/src/App.js @@ -1,22 +1,15 @@ -import React from "react"; -import freesewing from "@freesewing/core"; -import Workbench from "@freesewing/components/Workbench"; -import "typeface-roboto-condensed"; -import "@freesewing/css-theme"; +import React from 'react' +import freesewing from '@freesewing/core' +import Workbench from '@freesewing/components/Workbench' +import 'typeface-roboto-condensed' +import '@freesewing/css-theme' -import Pattern from "pattern"; +import Pattern from 'pattern' const App = props => { - let instance = new Pattern(); - let config = instance.config; - return ( - - ); -}; + let instance = new Pattern() + let config = instance.config + return +} -export default App; +export default App diff --git a/packages/examples/example/src/index.js b/packages/examples/example/src/index.js index 7900787a4d2..9dd7ba788d4 100644 --- a/packages/examples/example/src/index.js +++ b/packages/examples/example/src/index.js @@ -1,11 +1,11 @@ -import React from "react"; -import ReactDOM from "react-dom"; -import App from "./App"; -import * as serviceWorker from "./serviceWorker"; +import React from 'react' +import ReactDOM from 'react-dom' +import App from './App' +import * as serviceWorker from './serviceWorker' -ReactDOM.render(, document.getElementById("root")); +ReactDOM.render(, document.getElementById('root')) // If you want your app to work offline and load faster, you can change // unregister() to register() below. Note this comes with some pitfalls. // Learn more about service workers: http://bit.ly/CRA-PWA -serviceWorker.unregister(); +serviceWorker.unregister() diff --git a/packages/examples/example/src/serviceWorker.js b/packages/examples/example/src/serviceWorker.js index 68fda5a0eb6..44e1b1b2f8c 100644 --- a/packages/examples/example/src/serviceWorker.js +++ b/packages/examples/example/src/serviceWorker.js @@ -9,46 +9,44 @@ // This link also includes instructions on opting out of this behavior. const isLocalhost = Boolean( - window.location.hostname === "localhost" || + window.location.hostname === 'localhost' || // [::1] is the IPv6 localhost address. - window.location.hostname === "[::1]" || + window.location.hostname === '[::1]' || // 127.0.0.1/8 is considered localhost for IPv4. - window.location.hostname.match( - /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ - ) -); + window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/) +) export function register(config) { - if (process.env.NODE_ENV === "production" && "serviceWorker" in navigator) { + if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) { // The URL constructor is available in all browsers that support SW. - const publicUrl = new URL(process.env.PUBLIC_URL, window.location); + const publicUrl = new URL(process.env.PUBLIC_URL, window.location) if (publicUrl.origin !== window.location.origin) { // Our service worker won't work if PUBLIC_URL is on a different origin // from what our page is served on. This might happen if a CDN is used to // serve assets; see https://github.com/facebook/create-react-app/issues/2374 - return; + return } - window.addEventListener("load", () => { - const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; + window.addEventListener('load', () => { + const swUrl = `${process.env.PUBLIC_URL}/service-worker.js` if (isLocalhost) { // This is running on localhost. Let's check if a service worker still exists or not. - checkValidServiceWorker(swUrl, config); + checkValidServiceWorker(swUrl, config) // Add some additional logging to localhost, pointing developers to the // service worker/PWA documentation. navigator.serviceWorker.ready.then(() => { console.log( - "This web app is being served cache-first by a service " + - "worker. To learn more, visit https://goo.gl/SC7cgQ" - ); - }); + 'This web app is being served cache-first by a service ' + + 'worker. To learn more, visit https://goo.gl/SC7cgQ' + ) + }) } else { // Is not local host. Just register service worker - registerValidSW(swUrl, config); + registerValidSW(swUrl, config) } - }); + }) } } @@ -57,38 +55,38 @@ function registerValidSW(swUrl, config) { .register(swUrl) .then(registration => { registration.onupdatefound = () => { - const installingWorker = registration.installing; + const installingWorker = registration.installing installingWorker.onstatechange = () => { - if (installingWorker.state === "installed") { + if (installingWorker.state === 'installed') { if (navigator.serviceWorker.controller) { // At this point, the old content will have been purged and // the fresh content will have been added to the cache. // It's the perfect time to display a "New content is // available; please refresh." message in your web app. - console.log("New content is available; please refresh."); + console.log('New content is available; please refresh.') // Execute callback if (config.onUpdate) { - config.onUpdate(registration); + config.onUpdate(registration) } } else { // At this point, everything has been precached. // It's the perfect time to display a // "Content is cached for offline use." message. - console.log("Content is cached for offline use."); + console.log('Content is cached for offline use.') // Execute callback if (config.onSuccess) { - config.onSuccess(registration); + config.onSuccess(registration) } } } - }; - }; + } + } }) .catch(error => { - console.error("Error during service worker registration:", error); - }); + console.error('Error during service worker registration:', error) + }) } function checkValidServiceWorker(swUrl, config) { @@ -98,30 +96,28 @@ function checkValidServiceWorker(swUrl, config) { // Ensure service worker exists, and that we really are getting a JS file. if ( response.status === 404 || - response.headers.get("content-type").indexOf("javascript") === -1 + response.headers.get('content-type').indexOf('javascript') === -1 ) { // No service worker found. Probably a different app. Reload the page. navigator.serviceWorker.ready.then(registration => { registration.unregister().then(() => { - window.location.reload(); - }); - }); + window.location.reload() + }) + }) } else { // Service worker found. Proceed as normal. - registerValidSW(swUrl, config); + registerValidSW(swUrl, config) } }) .catch(() => { - console.log( - "No internet connection found. App is running in offline mode." - ); - }); + console.log('No internet connection found. App is running in offline mode.') + }) } export function unregister() { - if ("serviceWorker" in navigator) { + if ('serviceWorker' in navigator) { navigator.serviceWorker.ready.then(registration => { - registration.unregister(); - }); + registration.unregister() + }) } } diff --git a/packages/examples/src/docs_coords.js b/packages/examples/src/docs_coords.js index b910312cc8c..73faa106795 100644 --- a/packages/examples/src/docs_coords.js +++ b/packages/examples/src/docs_coords.js @@ -1,20 +1,20 @@ -import { box } from "./shared"; +import { box } from './shared' export default part => { - let { Point, points, paths, Path } = part.shorthand(); + let { Point, points, paths, Path } = part.shorthand() - points.origin = new Point(10, 10); - points.x = new Point(100, 10); - points.y = new Point(10, 50); - points.textX = points.x.shift(135, 2).attr("data-text", "X"); - points.textY = points.y.shift(180, 5).attr("data-text", "Y"); + points.origin = new Point(10, 10) + points.x = new Point(100, 10) + points.y = new Point(10, 50) + points.textX = points.x.shift(135, 2).attr('data-text', 'X') + points.textY = points.y.shift(180, 5).attr('data-text', 'Y') paths.coords = new Path() .move(points.y) .line(points.origin) .line(points.x) - .attr("class", "mark") - .attr("marker-start", "url(#dimensionFrom)") - .attr("marker-end", "url(#dimensionTo)"); + .attr('class', 'mark') + .attr('marker-start', 'url(#dimensionFrom)') + .attr('marker-end', 'url(#dimensionTo)') - return box(part, 100, 50); -}; + return box(part, 100, 50) +} diff --git a/packages/examples/src/docs_overview.js b/packages/examples/src/docs_overview.js index 45567199941..2d7cf254fde 100644 --- a/packages/examples/src/docs_overview.js +++ b/packages/examples/src/docs_overview.js @@ -1,24 +1,24 @@ export default part => { - let { Point, points, Path, paths, options } = part.shorthand(); + let { Point, points, Path, paths, options } = part.shorthand() /** * Returs the value passed to it randomized with a given tolerance */ const about = (value, tolerance = 5) => { - let randomized = (tolerance / 100) * Math.random() * value; - let fixed = (1 - tolerance / 100) * value; + let randomized = (tolerance / 100) * Math.random() * value + let fixed = (1 - tolerance / 100) * value - return fixed + randomized; - }; + return fixed + randomized + } /** * like about, but also randomly makes value negative * This is for degrees */ const nabout = (value, tolerance = 5) => { - if (Math.random() > 0.5) return about(value, tolerance); - else return -1 * about(value, tolerance); - }; + if (Math.random() > 0.5) return about(value, tolerance) + else return -1 * about(value, tolerance) + } /** * Draws a w*h box that's randomized by tolerance to give it @@ -27,180 +27,156 @@ export default part => { * Returns a Path object */ const box = (name, origin, width, height, tolerance = 10) => { - let base = height; - if (width < height) base = width; - let t = base * (tolerance / 100); - points[name + "TopLeft"] = new Point( - about(origin.x, t), - about(origin.y, t) - ); - points[name + "BottomLeft"] = new Point( - about(origin.x, t), - about(origin.y + height, t) - ); - points[name + "BottomRight"] = new Point( + let base = height + if (width < height) base = width + let t = base * (tolerance / 100) + points[name + 'TopLeft'] = new Point(about(origin.x, t), about(origin.y, t)) + points[name + 'BottomLeft'] = new Point(about(origin.x, t), about(origin.y + height, t)) + points[name + 'BottomRight'] = new Point( about(origin.x + width, t), about(origin.y + height, t) - ); - points[name + "TopRight"] = new Point( - about(origin.x + width, t), - about(origin.y, t) - ); - points[name + "Mid"] = points[name + "TopLeft"].shiftFractionTowards( - points[name + "BottomRight"], + ) + points[name + 'TopRight'] = new Point(about(origin.x + width, t), about(origin.y, t)) + points[name + 'Mid'] = points[name + 'TopLeft'].shiftFractionTowards( + points[name + 'BottomRight'], 0.5 - ); - points[name + "Mid"].y += 3; + ) + points[name + 'Mid'].y += 3 - let f = 0.3; - let r = tolerance / 2; - points[name + "TopLeftCp1"] = points[name + "TopLeft"] - .shiftFractionTowards(points[name + "BottomLeft"], about(f)) - .rotate(nabout(r), points[name + "TopLeft"]); - points[name + "TopLeftCp2"] = points[name + "TopLeft"] - .shiftFractionTowards(points[name + "TopRight"], about(f)) - .rotate(nabout(r), points[name + "TopLeft"]); - points[name + "BottomLeftCp1"] = points[name + "BottomLeft"] - .shiftFractionTowards(points[name + "TopLeft"], about(f)) - .rotate(nabout(r), points[name + "BottomLeft"]); - points[name + "BottomLeftCp2"] = points[name + "BottomLeft"] - .shiftFractionTowards(points[name + "BottomRight"], about(f)) - .rotate(nabout(r), points[name + "BottomLeft"]); - points[name + "BottomRightCp1"] = points[name + "BottomRight"] - .shiftFractionTowards(points[name + "BottomLeft"], about(f)) - .rotate(nabout(r), points[name + "BottomRight"]); - points[name + "BottomRightCp2"] = points[name + "BottomRight"] - .shiftFractionTowards(points[name + "TopRight"], about(f)) - .rotate(nabout(r), points[name + "BottomRight"]); - points[name + "TopRightCp1"] = points[name + "TopRight"] - .shiftFractionTowards(points[name + "BottomRight"], about(f)) - .rotate(nabout(r), points[name + "TopRight"]); - points[name + "TopRightCp2"] = points[name + "TopRight"] - .shiftFractionTowards(points[name + "TopLeft"], about(f)) - .rotate(nabout(r), points[name + "TopRight"]); + let f = 0.3 + let r = tolerance / 2 + points[name + 'TopLeftCp1'] = points[name + 'TopLeft'] + .shiftFractionTowards(points[name + 'BottomLeft'], about(f)) + .rotate(nabout(r), points[name + 'TopLeft']) + points[name + 'TopLeftCp2'] = points[name + 'TopLeft'] + .shiftFractionTowards(points[name + 'TopRight'], about(f)) + .rotate(nabout(r), points[name + 'TopLeft']) + points[name + 'BottomLeftCp1'] = points[name + 'BottomLeft'] + .shiftFractionTowards(points[name + 'TopLeft'], about(f)) + .rotate(nabout(r), points[name + 'BottomLeft']) + points[name + 'BottomLeftCp2'] = points[name + 'BottomLeft'] + .shiftFractionTowards(points[name + 'BottomRight'], about(f)) + .rotate(nabout(r), points[name + 'BottomLeft']) + points[name + 'BottomRightCp1'] = points[name + 'BottomRight'] + .shiftFractionTowards(points[name + 'BottomLeft'], about(f)) + .rotate(nabout(r), points[name + 'BottomRight']) + points[name + 'BottomRightCp2'] = points[name + 'BottomRight'] + .shiftFractionTowards(points[name + 'TopRight'], about(f)) + .rotate(nabout(r), points[name + 'BottomRight']) + points[name + 'TopRightCp1'] = points[name + 'TopRight'] + .shiftFractionTowards(points[name + 'BottomRight'], about(f)) + .rotate(nabout(r), points[name + 'TopRight']) + points[name + 'TopRightCp2'] = points[name + 'TopRight'] + .shiftFractionTowards(points[name + 'TopLeft'], about(f)) + .rotate(nabout(r), points[name + 'TopRight']) return new Path() - .move(points[name + "TopLeft"]) + .move(points[name + 'TopLeft']) .curve( - points[name + "TopLeftCp1"], - points[name + "BottomLeftCp1"], - points[name + "BottomLeft"] + points[name + 'TopLeftCp1'], + points[name + 'BottomLeftCp1'], + points[name + 'BottomLeft'] ) .curve( - points[name + "BottomLeftCp2"], - points[name + "BottomRightCp1"], - points[name + "BottomRight"] + points[name + 'BottomLeftCp2'], + points[name + 'BottomRightCp1'], + points[name + 'BottomRight'] ) .curve( - points[name + "BottomRightCp2"], - points[name + "TopRightCp1"], - points[name + "TopRight"] - ) - .curve( - points[name + "TopRightCp2"], - points[name + "TopLeftCp2"], - points[name + "TopLeft"] + points[name + 'BottomRightCp2'], + points[name + 'TopRightCp1'], + points[name + 'TopRight'] ) + .curve(points[name + 'TopRightCp2'], points[name + 'TopLeftCp2'], points[name + 'TopLeft']) .close() - .attr("class", options.focus === name ? "note" : "fabric"); - }; + .attr('class', options.focus === name ? 'note' : 'fabric') + } /** * Draws an arrow from to * Returns a Path object */ - const arrow = (name, text = "", tolerance = 10) => { - let from = points[name + "From"]; - let to = points[name + "To"]; - from = from.shiftTowards(to, 3); - to = to.shiftTowards(from, 3); - let base = from.dist(to); - let t = base * (tolerance / 100); - from.x = about(from.x, t); - from.x = about(from.x, t); - to.x = about(to.x, t); - to.x = about(to.x, t); - let f = 0.3; - let r = tolerance / 2; - points[name + "FromCp"] = from - .shiftFractionTowards(to, about(f)) - .rotate(nabout(r), from); - points[name + "ToCp"] = to - .shiftFractionTowards(from, about(f)) - .rotate(nabout(r), to); - points[name + "Tip1"] = to - .shiftTowards(from, about(3.8)) - .rotate(about(15), to); - points[name + "Tip2"] = to - .shiftTowards(from, about(3.5)) - .rotate(about(-15), to); + const arrow = (name, text = '', tolerance = 10) => { + let from = points[name + 'From'] + let to = points[name + 'To'] + from = from.shiftTowards(to, 3) + to = to.shiftTowards(from, 3) + let base = from.dist(to) + let t = base * (tolerance / 100) + from.x = about(from.x, t) + from.x = about(from.x, t) + to.x = about(to.x, t) + to.x = about(to.x, t) + let f = 0.3 + let r = tolerance / 2 + points[name + 'FromCp'] = from.shiftFractionTowards(to, about(f)).rotate(nabout(r), from) + points[name + 'ToCp'] = to.shiftFractionTowards(from, about(f)).rotate(nabout(r), to) + points[name + 'Tip1'] = to.shiftTowards(from, about(3.8)).rotate(about(15), to) + points[name + 'Tip2'] = to.shiftTowards(from, about(3.5)).rotate(about(-15), to) let path = new Path() .move(from) - .curve(points[name + "FromCp"], points[name + "ToCp"], to) - .move(points[name + "Tip1"]) + .curve(points[name + 'FromCp'], points[name + 'ToCp'], to) + .move(points[name + 'Tip1']) .line(to) - .line(points[name + "Tip2"]) - .attr("class", "fabric"); - if (options.focus === name) path = path.attr("class", "note"); + .line(points[name + 'Tip2']) + .attr('class', 'fabric') + if (options.focus === name) path = path.attr('class', 'note') if (text) return path - .attr("data-text", " " + text) - .attr("data-text-class", "scribble") - .attr("data-text-class", options.focus === name ? "fill-note" : ""); - else return path; - }; + .attr('data-text', ' ' + text) + .attr('data-text-class', 'scribble') + .attr('data-text-class', options.focus === name ? 'fill-note' : '') + else return path + } const drawBox = (name, x, y, width, height, tolerance = 5, text = true) => { - points[name + "Origin"] = new Point(x, y); - paths[name] = box(name, points[name + "Origin"], width, height, tolerance); + points[name + 'Origin'] = new Point(x, y) + paths[name] = box(name, points[name + 'Origin'], width, height, tolerance) if (text) { - points[name + "Mid"] - .attr("data-text", name) - .attr("data-text-class", "center scribble"); - if (options.focus === name) - points[name + "Mid"].attr("data-text-class", "fill-note"); + points[name + 'Mid'].attr('data-text', name).attr('data-text-class', 'center scribble') + if (options.focus === name) points[name + 'Mid'].attr('data-text-class', 'fill-note') } - }; + } const svgLogo = (anchor, size = 1) => { points.svg15 = anchor .shift(45, 4 * size) - .attr("data-circle", 1.2 * size) - .attr("data-circle-class", "fill-fabric"); + .attr('data-circle', 1.2 * size) + .attr('data-circle-class', 'fill-fabric') points.svg3 = anchor .shift(0, 4 * size) - .attr("data-circle", 1.2 * size) - .attr("data-circle-class", "fill-fabric"); + .attr('data-circle', 1.2 * size) + .attr('data-circle-class', 'fill-fabric') points.svg45 = anchor .shift(-45, 4 * size) - .attr("data-circle", 1.2 * size) - .attr("data-circle-class", "fill-fabric"); + .attr('data-circle', 1.2 * size) + .attr('data-circle-class', 'fill-fabric') points.svg6 = anchor .shift(-90, 4 * size) - .attr("data-circle", 1.2 * size) - .attr("data-circle-class", "fill-fabric"); + .attr('data-circle', 1.2 * size) + .attr('data-circle-class', 'fill-fabric') points.svg75 = anchor .shift(-135, 4 * size) - .attr("data-circle", 1.2 * size) - .attr("data-circle-class", "fill-fabric"); + .attr('data-circle', 1.2 * size) + .attr('data-circle-class', 'fill-fabric') points.svg9 = anchor .shift(180, 4 * size) - .attr("data-circle", 1.2 * size) - .attr("data-circle-class", "fill-fabric"); + .attr('data-circle', 1.2 * size) + .attr('data-circle-class', 'fill-fabric') points.svg105 = anchor .shift(135, 4 * size) - .attr("data-circle", 1.2 * size) - .attr("data-circle-class", "fill-fabric"); + .attr('data-circle', 1.2 * size) + .attr('data-circle-class', 'fill-fabric') points.svg12 = anchor .shift(90, 4 * size) - .attr("data-circle", 1.2 * size) - .attr("data-circle-class", "fill-fabric"); + .attr('data-circle', 1.2 * size) + .attr('data-circle-class', 'fill-fabric') points.svgText = anchor .clone() - .attr("data-text", "SVG") - .attr("data-text-class", "text-xl scribble"); - points.svgText.x += size * 7; - points.svgText.y += 6; + .attr('data-text', 'SVG') + .attr('data-text-class', 'text-xl scribble') + points.svgText.x += size * 7 + points.svgText.y += 6 paths.svgLogo = new Path() .move(points.svg15) .line(points.svg75) @@ -210,39 +186,39 @@ export default part => { .line(points.svg105) .move(points.svg6) .line(points.svg12) - .attr("class", "stroke-l"); - }; + .attr('class', 'stroke-l') + } const reactLogo = (anchor, size = 1) => { - h = 3 * size; - w = 6 * size; - points.reactTop1 = anchor.shift(45, w); - points.reactBottom1 = anchor.shift(-135, w); - points.reactTop1Cp1 = points.reactTop1.shift(135, h); - points.reactTop1Cp2 = points.reactTop1.shift(-45, h); - points.reactBottom1Cp1 = points.reactBottom1.shift(135, h); - points.reactBottom1Cp2 = points.reactBottom1.shift(-45, h); - points.reactTop2 = points.reactTop1.rotate(60, anchor); - points.reactBottom2 = points.reactBottom1.rotate(60, anchor); - points.reactTop2Cp1 = points.reactTop1Cp1.rotate(60, anchor); - points.reactTop2Cp2 = points.reactTop1Cp2.rotate(60, anchor); - points.reactBottom2Cp1 = points.reactBottom1Cp1.rotate(60, anchor); - points.reactBottom2Cp2 = points.reactBottom1Cp2.rotate(60, anchor); - points.reactTop3 = points.reactTop1.rotate(-60, anchor); - points.reactBottom3 = points.reactBottom1.rotate(-60, anchor); - points.reactTop3Cp1 = points.reactTop1Cp1.rotate(-60, anchor); - points.reactTop3Cp2 = points.reactTop1Cp2.rotate(-60, anchor); - points.reactBottom3Cp1 = points.reactBottom1Cp1.rotate(-60, anchor); - points.reactBottom3Cp2 = points.reactBottom1Cp2.rotate(-60, anchor); + h = 3 * size + w = 6 * size + points.reactTop1 = anchor.shift(45, w) + points.reactBottom1 = anchor.shift(-135, w) + points.reactTop1Cp1 = points.reactTop1.shift(135, h) + points.reactTop1Cp2 = points.reactTop1.shift(-45, h) + points.reactBottom1Cp1 = points.reactBottom1.shift(135, h) + points.reactBottom1Cp2 = points.reactBottom1.shift(-45, h) + points.reactTop2 = points.reactTop1.rotate(60, anchor) + points.reactBottom2 = points.reactBottom1.rotate(60, anchor) + points.reactTop2Cp1 = points.reactTop1Cp1.rotate(60, anchor) + points.reactTop2Cp2 = points.reactTop1Cp2.rotate(60, anchor) + points.reactBottom2Cp1 = points.reactBottom1Cp1.rotate(60, anchor) + points.reactBottom2Cp2 = points.reactBottom1Cp2.rotate(60, anchor) + points.reactTop3 = points.reactTop1.rotate(-60, anchor) + points.reactBottom3 = points.reactBottom1.rotate(-60, anchor) + points.reactTop3Cp1 = points.reactTop1Cp1.rotate(-60, anchor) + points.reactTop3Cp2 = points.reactTop1Cp2.rotate(-60, anchor) + points.reactBottom3Cp1 = points.reactBottom1Cp1.rotate(-60, anchor) + points.reactBottom3Cp2 = points.reactBottom1Cp2.rotate(-60, anchor) points.svgLogo = anchor .clone() - .attr("data-circle", 1 * size) - .attr("data-circle-class", "fill-fabric"); + .attr('data-circle', 1 * size) + .attr('data-circle-class', 'fill-fabric') points.reactText = anchor .clone() - .attr("data-text", "React") - .attr("data-text-class", "text-xl scribble"); - points.reactText.x += size * 7; - points.reactText.y += 6; + .attr('data-text', 'React') + .attr('data-text-class', 'text-xl scribble') + points.reactText.x += size * 7 + points.reactText.y += 6 paths.reactLogo = new Path() .move(points.reactTop1) @@ -256,82 +232,64 @@ export default part => { .move(points.reactTop3) .curve(points.reactTop3Cp1, points.reactBottom3Cp1, points.reactBottom3) .curve(points.reactBottom3Cp2, points.reactTop3Cp2, points.reactTop3) - .close(); - }; + .close() + } // Other parts first so they're behind - drawBox("Part4", 4, -19, 40, 65, 5, false); - drawBox("Part3", 1, -16, 40, 65, 5, false); - drawBox("Part2", -2, -13, 40, 65, 5, false); - drawBox("Part", -5, -10, 40, 65, 5); - paths.Part4.attr("class", "fill-bg"); - paths.Part3.attr("class", "fill-bg"); - paths.Part2.attr("class", "fill-bg"); - paths.Part.attr("class", "fill-bg"); - points.PartMid.y = points.PartTopLeft.y + 9; - let x = 0; - let y = 0; - let w = 30; - let h = 15; - drawBox("Points", x, y, w, h); - y += 18; - drawBox("Paths", x, y, w, h); - y += 18; - drawBox("Snippets", x, y, w, h); - x = -35; - y = -3; - w = 25; - h = 20; - drawBox("config", x, y, w, h); - y += 23; - drawBox("Store", x, y, w, h); - x = -40; - y = -30; - drawBox("Pattern", x, y, 90, 90); - points.PatternMid.y = points.PatternTopLeft.y + 9; + drawBox('Part4', 4, -19, 40, 65, 5, false) + drawBox('Part3', 1, -16, 40, 65, 5, false) + drawBox('Part2', -2, -13, 40, 65, 5, false) + drawBox('Part', -5, -10, 40, 65, 5) + paths.Part4.attr('class', 'fill-bg') + paths.Part3.attr('class', 'fill-bg') + paths.Part2.attr('class', 'fill-bg') + paths.Part.attr('class', 'fill-bg') + points.PartMid.y = points.PartTopLeft.y + 9 + let x = 0 + let y = 0 + let w = 30 + let h = 15 + drawBox('Points', x, y, w, h) + y += 18 + drawBox('Paths', x, y, w, h) + y += 18 + drawBox('Snippets', x, y, w, h) + x = -35 + y = -3 + w = 25 + h = 20 + drawBox('config', x, y, w, h) + y += 23 + drawBox('Store', x, y, w, h) + x = -40 + y = -30 + drawBox('Pattern', x, y, 90, 90) + points.PatternMid.y = points.PatternTopLeft.y + 9 - drawBox("settings", -100, 6, 40, 20); - drawBox("draft", 80, 3, 20, 25); + drawBox('settings', -100, 6, 40, 20) + drawBox('draft', 80, 3, 20, 25) - points.arrow1From = points.settingsTopRight.shiftFractionTowards( - points.settingsBottomRight, - 0.5 - ); - points.arrow1To = points.PatternTopLeft.shiftFractionTowards( - points.PatternBottomLeft, - 0.5 - ); - paths.arrow1 = arrow("arrow1"); - points.arrow2From = points.PatternTopRight.shiftFractionTowards( - points.PatternBottomRight, - 0.5 - ); - points.arrow2To = points.draftTopLeft.shiftFractionTowards( - points.draftBottomLeft, - 0.5 - ); - paths.arrow2 = arrow("arrow2", "draft()"); + points.arrow1From = points.settingsTopRight.shiftFractionTowards(points.settingsBottomRight, 0.5) + points.arrow1To = points.PatternTopLeft.shiftFractionTowards(points.PatternBottomLeft, 0.5) + paths.arrow1 = arrow('arrow1') + points.arrow2From = points.PatternTopRight.shiftFractionTowards(points.PatternBottomRight, 0.5) + points.arrow2To = points.draftTopLeft.shiftFractionTowards(points.draftBottomLeft, 0.5) + paths.arrow2 = arrow('arrow2', 'draft()') - svgLogo(points.draftMid.shift(70, 50)); - reactLogo(points.draftMid.shift(-80, 36)); + svgLogo(points.draftMid.shift(70, 50)) + reactLogo(points.draftMid.shift(-80, 36)) - points.arrow3From = points.draftTopLeft.shiftFractionTowards( - points.draftTopRight, - 0.5 - ); - points.arrow3To = points.svgText.clone(); - paths.arrow3 = arrow("arrow3", "render()"); - points.arrow4From = points.draftBottomLeft.shiftFractionTowards( - points.draftBottomRight, - 0.5 - ); - points.arrow4To = points.reactText.clone().shift(40, 15); - paths.arrow4 = arrow("arrow4"); + points.arrow3From = points.draftTopLeft.shiftFractionTowards(points.draftTopRight, 0.5) + points.arrow3To = points.svgText.clone() + paths.arrow3 = arrow('arrow3', 'render()') + points.arrow4From = points.draftBottomLeft.shiftFractionTowards(points.draftBottomRight, 0.5) + points.arrow4To = points.reactText.clone().shift(40, 15) + paths.arrow4 = arrow('arrow4') paths.extend = new Path() .move(points.draftTopRight) .line(points.draftTopRight.shift(0, 40)) - .attr("class", "hidden"); + .attr('class', 'hidden') - return part; -}; + return part +} diff --git a/packages/examples/src/index.js b/packages/examples/src/index.js index 12bccadd1cf..ae376e27f7c 100644 --- a/packages/examples/src/index.js +++ b/packages/examples/src/index.js @@ -1,87 +1,87 @@ -import freesewing from "@freesewing/core"; -import plugins from "@freesewing/plugin-bundle"; -import config from "../config/"; +import freesewing from '@freesewing/core' +import plugins from '@freesewing/plugin-bundle' +import config from '../config/' // Path API -import draftPath_move from "./path_move"; -import draftPath_line from "./path_line"; -import draftPath_curve from "./path_curve"; -import draftPath__curve from "./path__curve"; -import draftPath_curve_ from "./path_curve_"; -import draftPath_close from "./path_close"; -import draftPath_ops from "./path_ops"; -import draftPath_attr from "./path_attr"; -import draftPath_clone from "./path_clone"; -import draftPath_divide from "./path_divide"; -import draftPath_edge from "./path_edge"; -import draftPath_end from "./path_end"; -import draftPath_intersects from "./path_intersects"; -import draftPath_intersectsx from "./path_intersectsx"; -import draftPath_intersectsy from "./path_intersectsy"; -import draftPath_join from "./path_join"; -import draftPath_length from "./path_length"; -import draftPath_offset from "./path_offset"; -import draftPath_reverse from "./path_reverse"; -import draftPath_shiftalong from "./path_shiftalong"; -import draftPath_shiftfractionalong from "./path_shiftfractionalong"; -import draftPath_split from "./path_split"; -import draftPath_start from "./path_start"; -import draftPath_translate from "./path_translate"; -import draftPath_trim from "./path_trim"; +import draftPath_move from './path_move' +import draftPath_line from './path_line' +import draftPath_curve from './path_curve' +import draftPath__curve from './path__curve' +import draftPath_curve_ from './path_curve_' +import draftPath_close from './path_close' +import draftPath_ops from './path_ops' +import draftPath_attr from './path_attr' +import draftPath_clone from './path_clone' +import draftPath_divide from './path_divide' +import draftPath_edge from './path_edge' +import draftPath_end from './path_end' +import draftPath_intersects from './path_intersects' +import draftPath_intersectsx from './path_intersectsx' +import draftPath_intersectsy from './path_intersectsy' +import draftPath_join from './path_join' +import draftPath_length from './path_length' +import draftPath_offset from './path_offset' +import draftPath_reverse from './path_reverse' +import draftPath_shiftalong from './path_shiftalong' +import draftPath_shiftfractionalong from './path_shiftfractionalong' +import draftPath_split from './path_split' +import draftPath_start from './path_start' +import draftPath_translate from './path_translate' +import draftPath_trim from './path_trim' // Plugins -import draftPlugin_cutonfold from "./plugin_cutonfold"; -import draftPlugin_buttons from "./plugin_buttons"; -import draftPlugin_dimension from "./plugin_dimension"; -import draftPlugin_grainline from "./plugin_grainline"; -import draftPlugin_logo from "./plugin_logo"; -import draftPlugin_round from "./plugin_round"; -import draftPlugin_sprinkle from "./plugin_sprinkle"; -import draftPlugin_scalebox from "./plugin_scalebox"; -import draftPlugin_title from "./plugin_title"; +import draftPlugin_cutonfold from './plugin_cutonfold' +import draftPlugin_buttons from './plugin_buttons' +import draftPlugin_dimension from './plugin_dimension' +import draftPlugin_grainline from './plugin_grainline' +import draftPlugin_logo from './plugin_logo' +import draftPlugin_round from './plugin_round' +import draftPlugin_sprinkle from './plugin_sprinkle' +import draftPlugin_scalebox from './plugin_scalebox' +import draftPlugin_title from './plugin_title' // Point API -import draftPoint_angle from "./point_angle"; -import draftPoint_attr from "./point_attr"; -import draftPoint_clone from "./point_clone"; -import draftPoint_copy from "./point_copy"; -import draftPoint_dist from "./point_dist"; -import draftPoint_dx from "./point_dx"; -import draftPoint_dy from "./point_dy"; -import draftPoint_flipx from "./point_flipx"; -import draftPoint_flipy from "./point_flipy"; -import draftPoint_shift from "./point_shift"; -import draftPoint_shiftfractiontowards from "./point_shiftfractiontowards"; -import draftPoint_shifttowards from "./point_shifttowards"; -import draftPoint_shiftoutwards from "./point_shiftoutwards"; -import draftPoint_sitson from "./point_sitson"; -import draftPoint_sitsroughlyon from "./point_sitsroughlyon"; -import draftPoint_rotate from "./point_rotate"; -import draftPoint_translate from "./point_translate"; +import draftPoint_angle from './point_angle' +import draftPoint_attr from './point_attr' +import draftPoint_clone from './point_clone' +import draftPoint_copy from './point_copy' +import draftPoint_dist from './point_dist' +import draftPoint_dx from './point_dx' +import draftPoint_dy from './point_dy' +import draftPoint_flipx from './point_flipx' +import draftPoint_flipy from './point_flipy' +import draftPoint_shift from './point_shift' +import draftPoint_shiftfractiontowards from './point_shiftfractiontowards' +import draftPoint_shifttowards from './point_shifttowards' +import draftPoint_shiftoutwards from './point_shiftoutwards' +import draftPoint_sitson from './point_sitson' +import draftPoint_sitsroughlyon from './point_sitsroughlyon' +import draftPoint_rotate from './point_rotate' +import draftPoint_translate from './point_translate' // Utils API -import draftUtils_linesintersect from "./utils_linesintersect"; -import draftUtils_beamsintersect from "./utils_beamsintersect"; -import draftUtils_beamintersectsx from "./utils_beamintersectsx"; -import draftUtils_beamintersectsy from "./utils_beamintersectsy"; -import draftUtils_lineintersectscurve from "./utils_lineintersectscurve"; -import draftUtils_curvesintersect from "./utils_curvesintersect"; -import draftUtils_pointonbeam from "./utils_pointonbeam"; -import draftUtils_pointonline from "./utils_pointonline"; -import draftUtils_pointoncurve from "./utils_pointoncurve"; -import draftUtils_circlesintersect from "./utils_circlesintersect"; -import draftUtils_beamintersectscircle from "./utils_beamintersectscircle"; -import draftUtils_lineintersectscircle from "./utils_lineintersectscircle"; -import draftUtils_curveintersectsx from "./utils_curveintersectsx"; -import draftUtils_curveintersectsy from "./utils_curveintersectsy"; -import draftUtils_splitcurve from "./utils_splitcurve"; +import draftUtils_linesintersect from './utils_linesintersect' +import draftUtils_beamsintersect from './utils_beamsintersect' +import draftUtils_beamintersectsx from './utils_beamintersectsx' +import draftUtils_beamintersectsy from './utils_beamintersectsy' +import draftUtils_lineintersectscurve from './utils_lineintersectscurve' +import draftUtils_curvesintersect from './utils_curvesintersect' +import draftUtils_pointonbeam from './utils_pointonbeam' +import draftUtils_pointonline from './utils_pointonline' +import draftUtils_pointoncurve from './utils_pointoncurve' +import draftUtils_circlesintersect from './utils_circlesintersect' +import draftUtils_beamintersectscircle from './utils_beamintersectscircle' +import draftUtils_lineintersectscircle from './utils_lineintersectscircle' +import draftUtils_curveintersectsx from './utils_curveintersectsx' +import draftUtils_curveintersectsy from './utils_curveintersectsy' +import draftUtils_splitcurve from './utils_splitcurve' // Various -import draftSettings_sa from "./settings_sa"; -import draftSnippet from "./snippet"; -import draftSnippet_attr from "./snippet_attr"; -import draftSnippet_clone from "./snippet_clone"; +import draftSettings_sa from './settings_sa' +import draftSnippet from './snippet' +import draftSnippet_attr from './snippet_attr' +import draftSnippet_clone from './snippet_clone' // Docs illustrations -import draftDocs_overview from "./docs_overview"; -import draftDocs_coords from "./docs_coords"; +import draftDocs_overview from './docs_overview' +import draftDocs_coords from './docs_coords' // Create design -const Pattern = new freesewing.Design(config, plugins); +const Pattern = new freesewing.Design(config, plugins) // Attach draft methods to prototype let methods = { @@ -157,8 +157,8 @@ let methods = { draftUtils_splitcurve, draftDocs_overview, draftDocs_coords -}; +} -for (let m of Object.keys(methods)) Pattern.prototype[m] = methods[m]; +for (let m of Object.keys(methods)) Pattern.prototype[m] = methods[m] -export default Pattern; +export default Pattern diff --git a/packages/examples/src/path__curve.js b/packages/examples/src/path__curve.js index d88edd5e603..35326aa49ed 100644 --- a/packages/examples/src/path__curve.js +++ b/packages/examples/src/path__curve.js @@ -1,17 +1,17 @@ -import { box } from "./shared"; +import { box } from './shared' export default part => { - let { Point, points, Path, paths } = part.shorthand(); + let { Point, points, Path, paths } = part.shorthand() - points.from = new Point(5, 20); - points.cp2 = new Point(60, 30); - points.to = new Point(90, 20); + points.from = new Point(5, 20) + points.cp2 = new Point(60, 30) + points.to = new Point(90, 20) paths.line = new Path() .move(points.from) ._curve(points.cp2, points.to) - .attr("data-text", "Path._curve()") - .attr("data-text-class", "text-sm center fill-note"); + .attr('data-text', 'Path._curve()') + .attr('data-text-class', 'text-sm center fill-note') - return box(part, 100, 25); -}; + return box(part, 100, 25) +} diff --git a/packages/examples/src/path_attr.js b/packages/examples/src/path_attr.js index 0c68130ca72..28f97e79c4f 100644 --- a/packages/examples/src/path_attr.js +++ b/packages/examples/src/path_attr.js @@ -1,17 +1,17 @@ export default part => { - let { Point, points, Path, paths } = part.shorthand(); + let { Point, points, Path, paths } = part.shorthand() - points.B = new Point(10, 50); - points.BCp2 = new Point(40, 10); - points.C = new Point(90, 30); - points.CCp1 = new Point(50, 90); + points.B = new Point(10, 50) + points.BCp2 = new Point(40, 10) + points.C = new Point(90, 30) + points.CCp1 = new Point(50, 90) paths.example = new Path() .move(points.B) .curve(points.BCp2, points.CCp1, points.C) - .attr("class", "canvas") - .attr("data-text", "freesewingIsMadeByJoostDeCockAndContributors") - .attr("data-text-class", "text-xs center"); + .attr('class', 'canvas') + .attr('data-text', 'freesewingIsMadeByJoostDeCockAndContributors') + .attr('data-text-class', 'text-xs center') - return part; -}; + return part +} diff --git a/packages/examples/src/path_clone.js b/packages/examples/src/path_clone.js index c6407b2cfdc..dcf3d72af1c 100644 --- a/packages/examples/src/path_clone.js +++ b/packages/examples/src/path_clone.js @@ -1,21 +1,21 @@ export default part => { - let { Point, points, Path, paths } = part.shorthand(); + let { Point, points, Path, paths } = part.shorthand() - points.A = new Point(45, 60); - points.B = new Point(10, 30); - points.BCp2 = new Point(40, 20); - points.C = new Point(90, 30); - points.CCp1 = new Point(50, -30); + points.A = new Point(45, 60) + points.B = new Point(10, 30) + points.BCp2 = new Point(40, 20) + points.C = new Point(90, 30) + points.CCp1 = new Point(50, -30) paths.example = new Path() .move(points.A) .line(points.B) - .curve(points.BCp2, points.CCp1, points.C); + .curve(points.BCp2, points.CCp1, points.C) paths.clone = paths.example .clone() - .attr("class", "note lashed stroke-l") - .attr("style", "stroke-opacity: 0.5"); + .attr('class', 'note lashed stroke-l') + .attr('style', 'stroke-opacity: 0.5') - return part; -}; + return part +} diff --git a/packages/examples/src/path_close.js b/packages/examples/src/path_close.js index a555d68b4f7..d4297ff21d8 100644 --- a/packages/examples/src/path_close.js +++ b/packages/examples/src/path_close.js @@ -1,19 +1,19 @@ -import { box } from "./shared"; +import { box } from './shared' export default part => { - let { Point, points, Path, paths } = part.shorthand(); + let { Point, points, Path, paths } = part.shorthand() - points.from = new Point(10, 20); - points.cp2 = new Point(60, 30); - points.to = new Point(90, 20); + points.from = new Point(10, 20) + points.cp2 = new Point(60, 30) + points.to = new Point(90, 20) paths.line = new Path() .move(points.from) ._curve(points.cp2, points.to) .close() .reverse() // To keep text from being upside-down - .attr("data-text", "Path._close()") - .attr("data-text-class", "text-sm right fill-note"); + .attr('data-text', 'Path._close()') + .attr('data-text-class', 'text-sm right fill-note') - return box(part, 100, 25); -}; + return box(part, 100, 25) +} diff --git a/packages/examples/src/path_curve.js b/packages/examples/src/path_curve.js index a068a69ab76..5cc1663e0b3 100644 --- a/packages/examples/src/path_curve.js +++ b/packages/examples/src/path_curve.js @@ -1,18 +1,18 @@ -import { box } from "./shared"; +import { box } from './shared' export default part => { - let { Point, points, Path, paths } = part.shorthand(); + let { Point, points, Path, paths } = part.shorthand() - points.from = new Point(10, 20); - points.cp1 = new Point(40, 0); - points.cp2 = new Point(60, 30); - points.to = new Point(90, 20); + points.from = new Point(10, 20) + points.cp1 = new Point(40, 0) + points.cp2 = new Point(60, 30) + points.to = new Point(90, 20) paths.line = new Path() .move(points.from) .curve(points.cp1, points.cp2, points.to) - .attr("data-text", "Path.curve()") - .attr("data-text-class", "text-sm center fill-note"); + .attr('data-text', 'Path.curve()') + .attr('data-text-class', 'text-sm center fill-note') - return box(part, 100, 25); -}; + return box(part, 100, 25) +} diff --git a/packages/examples/src/path_curve_.js b/packages/examples/src/path_curve_.js index 68f9d61d685..0b20cc2eb0c 100644 --- a/packages/examples/src/path_curve_.js +++ b/packages/examples/src/path_curve_.js @@ -1,17 +1,17 @@ -import { box } from "./shared"; +import { box } from './shared' export default part => { - let { Point, points, Path, paths } = part.shorthand(); + let { Point, points, Path, paths } = part.shorthand() - points.from = new Point(10, 20); - points.cp1 = new Point(40, 0); - points.to = new Point(90, 20); + points.from = new Point(10, 20) + points.cp1 = new Point(40, 0) + points.to = new Point(90, 20) paths.line = new Path() .move(points.from) .curve_(points.cp1, points.to) - .attr("data-text", "Path.curve_()") - .attr("data-text-class", "text-sm center fill-note"); + .attr('data-text', 'Path.curve_()') + .attr('data-text-class', 'text-sm center fill-note') - return box(part, 100, 25); -}; + return box(part, 100, 25) +} diff --git a/packages/examples/src/path_divide.js b/packages/examples/src/path_divide.js index c69c9ddcba3..cbdbed41fd7 100644 --- a/packages/examples/src/path_divide.js +++ b/packages/examples/src/path_divide.js @@ -1,29 +1,27 @@ export default part => { - let { Point, points, Path, paths } = part.shorthand(); + let { Point, points, Path, paths } = part.shorthand() - points.A = new Point(55, 40); - points.B = new Point(10, 70); - points.BCp2 = new Point(40, 20); - points.C = new Point(90, 60); - points.CCp1 = new Point(50, -30); - points.D = new Point(50, 80); - points.DCp1 = new Point(140, 50); + points.A = new Point(55, 40) + points.B = new Point(10, 70) + points.BCp2 = new Point(40, 20) + points.C = new Point(90, 60) + points.CCp1 = new Point(50, -30) + points.D = new Point(50, 80) + points.DCp1 = new Point(140, 50) paths.example = new Path() .move(points.A) .line(points.B) .curve(points.BCp2, points.CCp1, points.C) .curve(points.DCp1, points.DCp1, points.D) - .close(); + .close() - let style = "stroke-width: 4; stroke-opacity: 0.5;"; - let i = 0; + let style = 'stroke-width: 4; stroke-opacity: 0.5;' + let i = 0 for (let p of paths.example.divide()) { - i++; - paths[i] = p - .attr("style", style) - .attr("style", `stroke: hsl(${i * 70}, 100%, 50%)`); + i++ + paths[i] = p.attr('style', style).attr('style', `stroke: hsl(${i * 70}, 100%, 50%)`) } - return part; -}; + return part +} diff --git a/packages/examples/src/path_edge.js b/packages/examples/src/path_edge.js index 7ce3741bac8..660c60d290e 100644 --- a/packages/examples/src/path_edge.js +++ b/packages/examples/src/path_edge.js @@ -1,32 +1,32 @@ export default part => { - let { Point, points, Path, paths, Snippet, snippets } = part.shorthand(); + let { Point, points, Path, paths, Snippet, snippets } = part.shorthand() - points.A = new Point(45, 60); - points.B = new Point(10, 30); - points.BCp2 = new Point(40, 20); - points.C = new Point(90, 30); - points.CCp1 = new Point(50, -30); - points.D = new Point(-60, 90); - points.E = new Point(90, 190); + points.A = new Point(45, 60) + points.B = new Point(10, 30) + points.BCp2 = new Point(40, 20) + points.C = new Point(90, 30) + points.CCp1 = new Point(50, -30) + points.D = new Point(-60, 90) + points.E = new Point(90, 190) paths.demo = new Path() .move(points.A) .line(points.B) .curve(points.BCp2, points.CCp1, points.C) .curve(points.E, points.D, points.A) - .close(); + .close() for (let i of [ - "topLeft", - "topRight", - "bottomLeft", - "bottomRight", - "top", - "left", - "bottom", - "right" + 'topLeft', + 'topRight', + 'bottomLeft', + 'bottomRight', + 'top', + 'left', + 'bottom', + 'right' ]) - snippets[i] = new Snippet("notch", paths.demo.edge(i)); + snippets[i] = new Snippet('notch', paths.demo.edge(i)) - return part; -}; + return part +} diff --git a/packages/examples/src/path_end.js b/packages/examples/src/path_end.js index 22c779f7d7e..bbf861689b5 100644 --- a/packages/examples/src/path_end.js +++ b/packages/examples/src/path_end.js @@ -1,18 +1,18 @@ export default part => { - let { Point, points, Path, paths, Snippet, snippets } = part.shorthand(); + let { Point, points, Path, paths, Snippet, snippets } = part.shorthand() - points.A = new Point(45, 60); - points.B = new Point(10, 30); - points.BCp2 = new Point(40, 20); - points.C = new Point(90, 30); - points.CCp1 = new Point(50, -30); + points.A = new Point(45, 60) + points.B = new Point(10, 30) + points.BCp2 = new Point(40, 20) + points.C = new Point(90, 30) + points.CCp1 = new Point(50, -30) paths.demo = new Path() .move(points.A) .line(points.B) - .curve(points.BCp2, points.CCp1, points.C); + .curve(points.BCp2, points.CCp1, points.C) - snippets.end = new Snippet("notch", paths.demo.end()); + snippets.end = new Snippet('notch', paths.demo.end()) - return part; -}; + return part +} diff --git a/packages/examples/src/path_intersects.js b/packages/examples/src/path_intersects.js index a9ec204d1ea..2b7fbe07bba 100644 --- a/packages/examples/src/path_intersects.js +++ b/packages/examples/src/path_intersects.js @@ -1,36 +1,36 @@ export default part => { - let { Point, points, Path, paths, Snippet, snippets } = part.shorthand(); + let { Point, points, Path, paths, Snippet, snippets } = part.shorthand() - points.A = new Point(45, 60); - points.B = new Point(10, 30); - points.BCp2 = new Point(40, 20); - points.C = new Point(90, 30); - points.CCp1 = new Point(50, -30); - points.D = new Point(50, 130); - points.DCp1 = new Point(150, 30); + points.A = new Point(45, 60) + points.B = new Point(10, 30) + points.BCp2 = new Point(40, 20) + points.C = new Point(90, 30) + points.CCp1 = new Point(50, -30) + points.D = new Point(50, 130) + points.DCp1 = new Point(150, 30) - points._A = new Point(55, 40); - points._B = new Point(0, 55); - points._BCp2 = new Point(40, -20); - points._C = new Point(90, 40); - points._CCp1 = new Point(50, -30); - points._D = new Point(40, 120); - points._DCp1 = new Point(180, 40); + points._A = new Point(55, 40) + points._B = new Point(0, 55) + points._BCp2 = new Point(40, -20) + points._C = new Point(90, 40) + points._CCp1 = new Point(50, -30) + points._D = new Point(40, 120) + points._DCp1 = new Point(180, 40) paths.demo1 = new Path() .move(points.A) .line(points.B) .curve(points.BCp2, points.CCp1, points.C) - .curve(points.DCp1, points.DCp1, points.D); + .curve(points.DCp1, points.DCp1, points.D) paths.demo2 = new Path() .move(points._A) .line(points._B) .curve(points._BCp2, points._CCp1, points._C) - .curve(points._DCp1, points._DCp1, points._D); + .curve(points._DCp1, points._DCp1, points._D) for (let p of paths.demo1.intersects(paths.demo2)) { - snippets[part.getId()] = new Snippet("notch", p); + snippets[part.getId()] = new Snippet('notch', p) } - return part; -}; + return part +} diff --git a/packages/examples/src/path_intersectsx.js b/packages/examples/src/path_intersectsx.js index b25244a177b..a1ab8671a03 100644 --- a/packages/examples/src/path_intersectsx.js +++ b/packages/examples/src/path_intersectsx.js @@ -1,31 +1,31 @@ export default part => { - let { Point, points, Path, paths, Snippet, snippets } = part.shorthand(); + let { Point, points, Path, paths, Snippet, snippets } = part.shorthand() - points.A = new Point(95, 50); - points.B = new Point(10, 30); - points.BCp2 = new Point(40, 20); - points.C = new Point(90, 30); - points.CCp1 = new Point(50, -30); - points.D = new Point(50, 130); - points.DCp1 = new Point(150, 30); + points.A = new Point(95, 50) + points.B = new Point(10, 30) + points.BCp2 = new Point(40, 20) + points.C = new Point(90, 30) + points.CCp1 = new Point(50, -30) + points.D = new Point(50, 130) + points.DCp1 = new Point(150, 30) - points.top = new Point(60, -10); - points.bot = new Point(60, 140); + points.top = new Point(60, -10) + points.bot = new Point(60, 140) paths.line = new Path() .move(points.top) .line(points.bot) - .attr("class", "lining dashed"); + .attr('class', 'lining dashed') paths.demo = new Path() .move(points.A) .line(points.B) .curve(points.BCp2, points.CCp1, points.C) - .curve(points.DCp1, points.DCp1, points.D); + .curve(points.DCp1, points.DCp1, points.D) for (let p of paths.demo.intersectsX(60)) { - snippets[part.getId()] = new Snippet("notch", p); + snippets[part.getId()] = new Snippet('notch', p) } - return part; -}; + return part +} diff --git a/packages/examples/src/path_intersectsy.js b/packages/examples/src/path_intersectsy.js index f5179e10157..213b51df42a 100644 --- a/packages/examples/src/path_intersectsy.js +++ b/packages/examples/src/path_intersectsy.js @@ -1,30 +1,30 @@ export default part => { - let { Point, points, Path, paths, Snippet, snippets } = part.shorthand(); + let { Point, points, Path, paths, Snippet, snippets } = part.shorthand() - points.A = new Point(55, 40); - points.B = new Point(10, 70); - points.BCp2 = new Point(40, 20); - points.C = new Point(90, 60); - points.CCp1 = new Point(50, -30); - points.D = new Point(50, 80); - points.DCp1 = new Point(140, 50); + points.A = new Point(55, 40) + points.B = new Point(10, 70) + points.BCp2 = new Point(40, 20) + points.C = new Point(90, 60) + points.CCp1 = new Point(50, -30) + points.D = new Point(50, 80) + points.DCp1 = new Point(140, 50) - points.top = new Point(10, 58); - points.bot = new Point(130, 58); + points.top = new Point(10, 58) + points.bot = new Point(130, 58) paths.line = new Path() .move(points.top) .line(points.bot) - .attr("class", "lining dashed"); + .attr('class', 'lining dashed') paths.demo = new Path() .move(points.A) .line(points.B) .curve(points.BCp2, points.CCp1, points.C) - .curve(points.DCp1, points.DCp1, points.D); + .curve(points.DCp1, points.DCp1, points.D) for (let p of paths.demo.intersectsY(58)) { - snippets[part.getId()] = new Snippet("notch", p); + snippets[part.getId()] = new Snippet('notch', p) } - return part; -}; + return part +} diff --git a/packages/examples/src/path_join.js b/packages/examples/src/path_join.js index 148b980ff99..54f760139e2 100644 --- a/packages/examples/src/path_join.js +++ b/packages/examples/src/path_join.js @@ -1,26 +1,26 @@ export default part => { - let { Point, points, Path, paths } = part.shorthand(); + let { Point, points, Path, paths } = part.shorthand() - points.A = new Point(45, 60); - points.B = new Point(10, 30); - points.BCp2 = new Point(40, 20); - points.C = new Point(90, 30); - points.CCp1 = new Point(50, -30); + points.A = new Point(45, 60) + points.B = new Point(10, 30) + points.BCp2 = new Point(40, 20) + points.C = new Point(90, 30) + points.CCp1 = new Point(50, -30) paths.path1 = new Path() .move(points.A) .line(points.B) - .attr("class", "various"); + .attr('class', 'various') paths.path2 = new Path() .move(points.B) .curve(points.BCp2, points.CCp1, points.C) - .attr("class", "canvas"); + .attr('class', 'canvas') paths.joint = paths.path1 .join(paths.path2) - .attr("class", "note lashed stroke-l") - .attr("style", "stroke-opacity: 0.5"); + .attr('class', 'note lashed stroke-l') + .attr('style', 'stroke-opacity: 0.5') - return part; -}; + return part +} diff --git a/packages/examples/src/path_length.js b/packages/examples/src/path_length.js index 429a20b3866..eba3eabd059 100644 --- a/packages/examples/src/path_length.js +++ b/packages/examples/src/path_length.js @@ -1,31 +1,31 @@ export default part => { - let { Point, points, Path, paths, macro } = part.shorthand(); + let { Point, points, Path, paths, macro } = part.shorthand() - points.A = new Point(45, 60); - points.B = new Point(10, 30); - points.BCp2 = new Point(40, 20); - points.C = new Point(90, 30); - points.CCp1 = new Point(50, -30); + points.A = new Point(45, 60) + points.B = new Point(10, 30) + points.BCp2 = new Point(40, 20) + points.C = new Point(90, 30) + points.CCp1 = new Point(50, -30) paths.example = new Path() .move(points.A) .line(points.B) - .curve(points.BCp2, points.CCp1, points.C); + .curve(points.BCp2, points.CCp1, points.C) - macro("pd", { + macro('pd', { path: paths.example, d: -20 - }); + }) - macro("pd", { + macro('pd', { path: new Path().move(points.B).line(points.A), d: 10 - }); + }) - macro("pd", { + macro('pd', { path: new Path().move(points.B).curve(points.BCp2, points.CCp1, points.C), d: -10 - }); + }) - return part; -}; + return part +} diff --git a/packages/examples/src/path_line.js b/packages/examples/src/path_line.js index 4423e8aaced..5072c8b5aab 100644 --- a/packages/examples/src/path_line.js +++ b/packages/examples/src/path_line.js @@ -1,16 +1,16 @@ -import { box } from "./shared"; +import { box } from './shared' export default part => { - let { Point, points, Path, paths } = part.shorthand(); + let { Point, points, Path, paths } = part.shorthand() - points.from = new Point(10, 10); - points.to = new Point(90, 10); + points.from = new Point(10, 10) + points.to = new Point(90, 10) paths.line = new Path() .move(points.from) .line(points.to) - .attr("data-text", "Path.line()") - .attr("data-text-class", "text-sm center fill-note"); + .attr('data-text', 'Path.line()') + .attr('data-text-class', 'text-sm center fill-note') - return box(part, 100, 15); -}; + return box(part, 100, 15) +} diff --git a/packages/examples/src/path_move.js b/packages/examples/src/path_move.js index 35a752998e0..bf2b315a801 100644 --- a/packages/examples/src/path_move.js +++ b/packages/examples/src/path_move.js @@ -1,13 +1,13 @@ -import { box } from "./shared"; +import { box } from './shared' export default part => { - let { Point, points, Path, paths } = part.shorthand(); + let { Point, points, Path, paths } = part.shorthand() points.to = new Point(50, 10) - .attr("data-text", "Path.move()") - .attr("data-text-class", "fill-note center"); + .attr('data-text', 'Path.move()') + .attr('data-text-class', 'fill-note center') - paths.noline = new Path().move(points.to); + paths.noline = new Path().move(points.to) - return box(part, 100, 15); -}; + return box(part, 100, 15) +} diff --git a/packages/examples/src/path_offset.js b/packages/examples/src/path_offset.js index c4e2b64a4e7..cc67a07bd76 100644 --- a/packages/examples/src/path_offset.js +++ b/packages/examples/src/path_offset.js @@ -1,32 +1,32 @@ export default part => { - let { Point, points, Path, paths } = part.shorthand(); + let { Point, points, Path, paths } = part.shorthand() - points.A = new Point(45, 60); - points.B = new Point(10, 30); - points.BCp2 = new Point(40, 20); - points.C = new Point(90, 30); - points.CCp1 = new Point(50, -30); + points.A = new Point(45, 60) + points.B = new Point(10, 30) + points.BCp2 = new Point(40, 20) + points.C = new Point(90, 30) + points.CCp1 = new Point(50, -30) paths.example = new Path() .move(points.A) .line(points.B) .curve(points.BCp2, points.CCp1, points.C) .line(points.A) - .close(); + .close() - paths.offset = paths.example.offset(-10).attr("class", "interfacing"); + paths.offset = paths.example.offset(-10).attr('class', 'interfacing') paths.lineOffset = new Path() .move(points.A) .line(points.B) .offset(-5) - .attr("class", "various"); + .attr('class', 'various') paths.curveOffset = new Path() .move(points.B) .curve(points.BCp2, points.CCp1, points.C) .offset(-5) - .attr("class", "canvas"); + .attr('class', 'canvas') - return part; -}; + return part +} diff --git a/packages/examples/src/path_ops.js b/packages/examples/src/path_ops.js index e9cc61c48df..5d087377172 100644 --- a/packages/examples/src/path_ops.js +++ b/packages/examples/src/path_ops.js @@ -1,56 +1,56 @@ export default part => { - let { Point, points, Path, paths, options } = part.shorthand(); + let { Point, points, Path, paths, options } = part.shorthand() const textClasses = label => - options.focus === label ? "center text-xs fill-note" : "center text-xs"; + options.focus === label ? 'center text-xs fill-note' : 'center text-xs' points.A = new Point(10, 10) - .attr("data-text", "Path.move()") - .attr("data-text-class", textClasses("move")); - points.B = new Point(70, 30); - points.BCp2 = new Point(40, 10); - points.C = new Point(90, -50); - points.CCp1 = new Point(125, -30); - points.D = new Point(20, -50); - points.DCp = new Point(40, 0); - points.E = new Point(-20, -20); - points.ECp = new Point(-20, -50); + .attr('data-text', 'Path.move()') + .attr('data-text-class', textClasses('move')) + points.B = new Point(70, 30) + points.BCp2 = new Point(40, 10) + points.C = new Point(90, -50) + points.CCp1 = new Point(125, -30) + points.D = new Point(20, -50) + points.DCp = new Point(40, 0) + points.E = new Point(-20, -20) + points.ECp = new Point(-20, -50) paths.line = new Path() .move(points.A) .line(points.B) - .attr("data-text", "Path.line()") - .attr("data-text-class", textClasses("line")); + .attr('data-text', 'Path.line()') + .attr('data-text-class', textClasses('line')) paths.curve = new Path() .move(points.B) .curve(points.BCp2, points.CCp1, points.C) - .attr("data-text", "Path.curve()") - .attr("data-text-class", textClasses("curve")); + .attr('data-text', 'Path.curve()') + .attr('data-text-class', textClasses('curve')) paths._curve = new Path() .move(points.C) ._curve(points.DCp, points.D) - .attr("data-text", "Path._curve()") - .attr("data-text-class", textClasses("_curve")); + .attr('data-text', 'Path._curve()') + .attr('data-text-class', textClasses('_curve')) paths.curve_ = new Path() .move(points.D) .curve_(points.ECp, points.E) - .attr("data-text", "Path.curve_()") - .attr("data-text-class", textClasses("curve_")); + .attr('data-text', 'Path.curve_()') + .attr('data-text-class', textClasses('curve_')) paths.close = new Path() .move(points.E) .line(points.A) - .attr("data-text", "Path.close()") - .attr("data-text-class", textClasses("close")); + .attr('data-text', 'Path.close()') + .attr('data-text-class', textClasses('close')) paths.example = paths.line .join(paths.curve) .join(paths._curve) .join(paths.curve_) - .close(); + .close() - return part; -}; + return part +} diff --git a/packages/examples/src/path_reverse.js b/packages/examples/src/path_reverse.js index 152420930f7..8213a5ff75e 100644 --- a/packages/examples/src/path_reverse.js +++ b/packages/examples/src/path_reverse.js @@ -1,21 +1,21 @@ export default part => { - let { Point, points, Path, paths } = part.shorthand(); + let { Point, points, Path, paths } = part.shorthand() - points.B = new Point(10, 30); - points.BCp2 = new Point(40, 20); - points.C = new Point(90, 30); - points.CCp1 = new Point(50, -30); + points.B = new Point(10, 30) + points.BCp2 = new Point(40, 20) + points.C = new Point(90, 30) + points.CCp1 = new Point(50, -30) paths.example = new Path() .move(points.B) .curve(points.BCp2, points.CCp1, points.C) - .attr("data-text", "freesewingIsMadeByJoostDeCockAndContributors") - .attr("data-text-class", "text-xs fill-note"); + .attr('data-text', 'freesewingIsMadeByJoostDeCockAndContributors') + .attr('data-text-class', 'text-xs fill-note') paths.reverse = paths.example .reverse() - .attr("data-text", "freesewingIsMadeByJoostDeCockAndContributors") - .attr("data-text-class", "text-xs fill-lining"); + .attr('data-text', 'freesewingIsMadeByJoostDeCockAndContributors') + .attr('data-text-class', 'text-xs fill-lining') - return part; -}; + return part +} diff --git a/packages/examples/src/path_shiftalong.js b/packages/examples/src/path_shiftalong.js index bd8e7d1d26c..a752649c537 100644 --- a/packages/examples/src/path_shiftalong.js +++ b/packages/examples/src/path_shiftalong.js @@ -1,30 +1,30 @@ export default part => { - let { Point, points, Path, paths, Snippet, snippets } = part.shorthand(); + let { Point, points, Path, paths, Snippet, snippets } = part.shorthand() - points.A = new Point(45, 60); - points.B = new Point(10, 30); - points.BCp2 = new Point(40, 20); - points.C = new Point(90, 30); - points.CCp1 = new Point(50, -30); + points.A = new Point(45, 60) + points.B = new Point(10, 30) + points.BCp2 = new Point(40, 20) + points.C = new Point(90, 30) + points.CCp1 = new Point(50, -30) paths.example = new Path() .move(points.A) .line(points.B) - .curve(points.BCp2, points.CCp1, points.C); + .curve(points.BCp2, points.CCp1, points.C) points.x1 = paths.example .shiftAlong(20) - .attr("data-text", "2cm") - .attr("data-text-class", "center fill-note") - .attr("data-text-lineheight", 6); + .attr('data-text', '2cm') + .attr('data-text-class', 'center fill-note') + .attr('data-text-lineheight', 6) points.x2 = paths.example .shiftAlong(90) - .attr("data-text", "9cm") - .attr("data-text-class", "center fill-note") - .attr("data-text-lineheight", 6); + .attr('data-text', '9cm') + .attr('data-text-class', 'center fill-note') + .attr('data-text-lineheight', 6) - snippets.x1 = new Snippet("notch", points.x1); - snippets.x2 = new Snippet("notch", points.x2); + snippets.x1 = new Snippet('notch', points.x1) + snippets.x2 = new Snippet('notch', points.x2) - return part; -}; + return part +} diff --git a/packages/examples/src/path_shiftfractionalong.js b/packages/examples/src/path_shiftfractionalong.js index 4c8b43f2c65..7cd5f881306 100644 --- a/packages/examples/src/path_shiftfractionalong.js +++ b/packages/examples/src/path_shiftfractionalong.js @@ -1,30 +1,30 @@ export default part => { - let { Point, points, Path, paths, Snippet, snippets } = part.shorthand(); + let { Point, points, Path, paths, Snippet, snippets } = part.shorthand() - points.A = new Point(45, 60); - points.B = new Point(10, 30); - points.BCp2 = new Point(40, 20); - points.C = new Point(90, 30); - points.CCp1 = new Point(50, -30); + points.A = new Point(45, 60) + points.B = new Point(10, 30) + points.BCp2 = new Point(40, 20) + points.C = new Point(90, 30) + points.CCp1 = new Point(50, -30) paths.example = new Path() .move(points.A) .line(points.B) - .curve(points.BCp2, points.CCp1, points.C); + .curve(points.BCp2, points.CCp1, points.C) points.x1 = paths.example .shiftFractionAlong(0.2) - .attr("data-text", "20%") - .attr("data-text-class", "center fill-note") - .attr("data-text-lineheight", 6); + .attr('data-text', '20%') + .attr('data-text-class', 'center fill-note') + .attr('data-text-lineheight', 6) points.x2 = paths.example .shiftFractionAlong(0.9) - .attr("data-text", "90%") - .attr("data-text-class", "center fill-note") - .attr("data-text-lineheight", 6); + .attr('data-text', '90%') + .attr('data-text-class', 'center fill-note') + .attr('data-text-lineheight', 6) - snippets.xl = new Snippet("notch", points.x1); - snippets.x2 = new Snippet("notch", points.x2); + snippets.xl = new Snippet('notch', points.x1) + snippets.x2 = new Snippet('notch', points.x2) - return part; -}; + return part +} diff --git a/packages/examples/src/path_split.js b/packages/examples/src/path_split.js index b7143546658..fe09b6444c8 100644 --- a/packages/examples/src/path_split.js +++ b/packages/examples/src/path_split.js @@ -1,30 +1,28 @@ export default part => { - let { Point, points, Path, paths, Snippet, snippets } = part.shorthand(); + let { Point, points, Path, paths, Snippet, snippets } = part.shorthand() - points.A = new Point(45, 60); - points.B = new Point(10, 30); - points.BCp2 = new Point(40, 20); - points.C = new Point(90, 30); - points.CCp1 = new Point(50, -30); - points.D = new Point(50, 130); - points.DCp1 = new Point(150, 30); + points.A = new Point(45, 60) + points.B = new Point(10, 30) + points.BCp2 = new Point(40, 20) + points.C = new Point(90, 30) + points.CCp1 = new Point(50, -30) + points.D = new Point(50, 130) + points.DCp1 = new Point(150, 30) paths.demo = new Path() .move(points.D) .curve(points.DCp1, points.DCp1, points.C) .curve(points.CCp1, points.BCp2, points.B) - .line(points.A); + .line(points.A) - points.split = paths.demo.shiftFractionAlong(0.75); - snippets.x = new Snippet("x", points.split); + points.split = paths.demo.shiftFractionAlong(0.75) + snippets.x = new Snippet('x', points.split) - let style = "stroke-width: 3; stroke-opacity: 0.5;"; - let halves = paths.demo.split(points.split); + let style = 'stroke-width: 3; stroke-opacity: 0.5;' + let halves = paths.demo.split(points.split) for (let i in halves) { - paths[i] = halves[i] - .attr("style", style) - .attr("style", `stroke: hsl(${i * 70}, 100%, 50%)`); + paths[i] = halves[i].attr('style', style).attr('style', `stroke: hsl(${i * 70}, 100%, 50%)`) } - return part; -}; + return part +} diff --git a/packages/examples/src/path_start.js b/packages/examples/src/path_start.js index 37d1fb19c7b..e9776e801a9 100644 --- a/packages/examples/src/path_start.js +++ b/packages/examples/src/path_start.js @@ -1,17 +1,17 @@ export default part => { - let { Point, points, Path, paths, Snippet, snippets } = part.shorthand(); + let { Point, points, Path, paths, Snippet, snippets } = part.shorthand() - points.A = new Point(45, 60); - points.B = new Point(10, 30); - points.BCp2 = new Point(40, 20); - points.C = new Point(90, 30); - points.CCp1 = new Point(50, -30); + points.A = new Point(45, 60) + points.B = new Point(10, 30) + points.BCp2 = new Point(40, 20) + points.C = new Point(90, 30) + points.CCp1 = new Point(50, -30) paths.example = new Path() .move(points.A) .line(points.B) - .curve(points.BCp2, points.CCp1, points.C); + .curve(points.BCp2, points.CCp1, points.C) - snippets.start = new Snippet("notch", paths.example.start()); - return part; -}; + snippets.start = new Snippet('notch', paths.example.start()) + return part +} diff --git a/packages/examples/src/path_translate.js b/packages/examples/src/path_translate.js index 133aac0b27e..e8ce08ad50f 100644 --- a/packages/examples/src/path_translate.js +++ b/packages/examples/src/path_translate.js @@ -1,31 +1,31 @@ export default part => { - let { Point, points, Path, paths, macro } = part.shorthand(); + let { Point, points, Path, paths, macro } = part.shorthand() - points.A = new Point(45, 60); - points.B = new Point(10, 30); - points.BCp2 = new Point(40, 20); - points.C = new Point(90, 30); - points.CCp1 = new Point(50, -30); + points.A = new Point(45, 60) + points.B = new Point(10, 30) + points.BCp2 = new Point(40, 20) + points.C = new Point(90, 30) + points.CCp1 = new Point(50, -30) paths.A = new Path() .move(points.A) .line(points.B) - .curve(points.BCp2, points.CCp1, points.C); + .curve(points.BCp2, points.CCp1, points.C) - paths.B = paths.A.translate(60, 30); + paths.B = paths.A.translate(60, 30) - points.step1 = points.B.shift(0, 60); - points.step2 = points.step1.shift(-90, 30); - macro("ld", { + points.step1 = points.B.shift(0, 60) + points.step2 = points.step1.shift(-90, 30) + macro('ld', { from: points.B, to: points.step1, noStartMarker: true - }); - macro("ld", { + }) + macro('ld', { from: points.step1, to: points.step2, noStartMarker: true - }); + }) - return part; -}; + return part +} diff --git a/packages/examples/src/path_trim.js b/packages/examples/src/path_trim.js index 2cf88f6d610..92dc94a03ef 100644 --- a/packages/examples/src/path_trim.js +++ b/packages/examples/src/path_trim.js @@ -1,42 +1,36 @@ export default part => { - let { Point, points, Path, paths } = part.shorthand(); + let { Point, points, Path, paths } = part.shorthand() - points.center = new Point(0, 0); - points.base = new Point(0, 10); - points.tip = new Point(0, 50); - points.tipCpRight = new Point(30, 50); - points.tipCpLeft = new Point(-30, 50); - paths.example = new Path().move(points.base); + points.center = new Point(0, 0) + points.base = new Point(0, 10) + points.tip = new Point(0, 50) + points.tipCpRight = new Point(30, 50) + points.tipCpLeft = new Point(-30, 50) + paths.example = new Path().move(points.base) for (let i = 0; i < 4; i++) { - points["base" + i] = points.base.rotate(60 * i, points.center); - points["tip" + i] = points.tip.rotate(60 * i, points.center); - points["tipCpRight" + i] = points.tipCpRight.rotate(60 * i, points.center); - points["tipCpLeft" + i] = points.tipCpLeft.rotate(60 * i, points.center); + points['base' + i] = points.base.rotate(60 * i, points.center) + points['tip' + i] = points.tip.rotate(60 * i, points.center) + points['tipCpRight' + i] = points.tipCpRight.rotate(60 * i, points.center) + points['tipCpLeft' + i] = points.tipCpLeft.rotate(60 * i, points.center) if (i < 2) { paths.example - .line(points["base" + i]) - .curve(points["base" + i], points["tipCpLeft" + i], points["tip" + i]) - .curve( - points["tipCpRight" + i], - points["base" + i], - points["base" + i] - ); + .line(points['base' + i]) + .curve(points['base' + i], points['tipCpLeft' + i], points['tip' + i]) + .curve(points['tipCpRight' + i], points['base' + i], points['base' + i]) } else { paths.example - .line(points["base" + i]) - .line(points["tip" + i]) - .line(points["tipCpRight" + i]) - .line(points["base" + i]); + .line(points['base' + i]) + .line(points['tip' + i]) + .line(points['tipCpRight' + i]) + .line(points['base' + i]) } } - paths.offset = paths.example - .offset(10) - .attr("class", "lining dotted stroke-sm"); + paths.offset = paths.example.offset(10).attr('class', 'lining dotted stroke-sm') paths.trimmed = paths.offset .trim() - .attr("class", "various stroke-xl") - .attr("style", "stroke-opacity: 0.5;"); - return part; -}; + .attr('class', 'various stroke-xl') + .attr('style', 'stroke-opacity: 0.5;') + return part +} diff --git a/packages/examples/src/plugin_buttons.js b/packages/examples/src/plugin_buttons.js index db100080ead..b83e348bb9a 100644 --- a/packages/examples/src/plugin_buttons.js +++ b/packages/examples/src/plugin_buttons.js @@ -1,10 +1,10 @@ -import { box } from "./shared"; +import { box } from './shared' export default part => { - let { Point, snippets, Snippet } = part.shorthand(); + let { Point, snippets, Snippet } = part.shorthand() - snippets.button = new Snippet("button", new Point(30, 10)); - snippets.buttonhole = new Snippet("buttonhole", new Point(70, 10)); + snippets.button = new Snippet('button', new Point(30, 10)) + snippets.buttonhole = new Snippet('buttonhole', new Point(70, 10)) - return box(part, 100, 20); -}; + return box(part, 100, 20) +} diff --git a/packages/examples/src/plugin_cutonfold.js b/packages/examples/src/plugin_cutonfold.js index 984cf158fe3..cab6a78109b 100644 --- a/packages/examples/src/plugin_cutonfold.js +++ b/packages/examples/src/plugin_cutonfold.js @@ -1,23 +1,23 @@ export default part => { - let { Point, points, Path, paths, macro } = part.shorthand(); + let { Point, points, Path, paths, macro } = part.shorthand() - points.topLeft = new Point(0, 0); - points.topRight = new Point(150, 0); - points.bottomRight = new Point(150, 50); - points.bottomLeft = new Point(0, 50); + points.topLeft = new Point(0, 0) + points.topRight = new Point(150, 0) + points.bottomRight = new Point(150, 50) + points.bottomLeft = new Point(0, 50) paths.box = new Path() .move(points.topLeft) .line(points.topRight) .line(points.bottomRight) .line(points.bottomLeft) - .close(); + .close() - macro("cutonfold", { + macro('cutonfold', { from: points.topRight, to: points.topLeft, grainline: true - }); + }) - return part; -}; + return part +} diff --git a/packages/examples/src/plugin_dimension.js b/packages/examples/src/plugin_dimension.js index 48c6dd5c67c..33ad2d5ddbd 100644 --- a/packages/examples/src/plugin_dimension.js +++ b/packages/examples/src/plugin_dimension.js @@ -1,11 +1,11 @@ export default part => { - let { Point, points, Path, paths, macro } = part.shorthand(); + let { Point, points, Path, paths, macro } = part.shorthand() - points.A = new Point(0, 0); - points.B = new Point(0, 100); - points.C = new Point(50, 100); - points.D = new Point(100, 50); - points.DCp1 = new Point(100, 0); + points.A = new Point(0, 0) + points.B = new Point(0, 100) + points.C = new Point(50, 100) + points.D = new Point(100, 50) + points.DCp1 = new Point(100, 0) paths.box = new Path() .move(points.A) @@ -13,37 +13,37 @@ export default part => { .line(points.C) .line(points.D) .curve(points.DCp1, points.A, points.A) - .close(); + .close() - macro("vd", { + macro('vd', { from: points.A, to: points.B, x: points.A.x - 15 - }); + }) - macro("hd", { + macro('hd', { from: points.B, to: points.C, y: points.B.y + 15 - }); + }) - macro("ld", { + macro('ld', { from: points.C, to: points.D, d: -15 - }); + }) - macro("ld", { + macro('ld', { from: points.C, to: points.D, d: -30, - text: "Custom text" - }); + text: 'Custom text' + }) - macro("pd", { + macro('pd', { path: new Path().move(points.A).curve(points.A, points.DCp1, points.D), d: -15 - }); + }) - return part; -}; + return part +} diff --git a/packages/examples/src/plugin_grainline.js b/packages/examples/src/plugin_grainline.js index 56e18f6be9e..197dccefc43 100644 --- a/packages/examples/src/plugin_grainline.js +++ b/packages/examples/src/plugin_grainline.js @@ -1,13 +1,13 @@ export default part => { - let { Point, points, macro } = part.shorthand(); + let { Point, points, macro } = part.shorthand() - points.grainlineFrom = new Point(10, 10); - points.grainlineTo = new Point(100, 10); + points.grainlineFrom = new Point(10, 10) + points.grainlineTo = new Point(100, 10) - macro("grainline", { + macro('grainline', { from: points.grainlineFrom, to: points.grainlineTo - }); + }) - return part; -}; + return part +} diff --git a/packages/examples/src/plugin_logo.js b/packages/examples/src/plugin_logo.js index d6aa3e83e5f..74adefbc4ad 100644 --- a/packages/examples/src/plugin_logo.js +++ b/packages/examples/src/plugin_logo.js @@ -1,9 +1,9 @@ -import { box } from "./shared"; +import { box } from './shared' export default part => { - let { Point, snippets, Snippet } = part.shorthand(); + let { Point, snippets, Snippet } = part.shorthand() - snippets.logo = new Snippet("logo", new Point(50, 30)); + snippets.logo = new Snippet('logo', new Point(50, 30)) - return box(part, 100, 40); -}; + return box(part, 100, 40) +} diff --git a/packages/examples/src/plugin_round.js b/packages/examples/src/plugin_round.js index b27a2ec6477..ccb7bcc089a 100644 --- a/packages/examples/src/plugin_round.js +++ b/packages/examples/src/plugin_round.js @@ -1,10 +1,10 @@ export default part => { - let { Point, points, Path, paths, macro } = part.shorthand(); + let { Point, points, Path, paths, macro } = part.shorthand() - points.topLeft = new Point(0, 0); - points.bottomLeft = new Point(0, 30); - points.topRight = new Point(100, 0); - points.bottomRight = new Point(100, 30); + points.topLeft = new Point(0, 0) + points.bottomLeft = new Point(0, 30) + points.topRight = new Point(100, 0) + points.bottomRight = new Point(100, 30) paths.demo = new Path() .move(points.topLeft) @@ -12,24 +12,24 @@ export default part => { .line(points.bottomRight) .line(points.topRight) .close() - .attr("class", "note dashed"); + .attr('class', 'note dashed') - macro("round", { + macro('round', { from: points.topLeft, to: points.bottomRight, via: points.bottomLeft, radius: 10, - prefix: "bl", + prefix: 'bl', render: true - }); - macro("round", { + }) + macro('round', { from: points.bottomRight, to: points.topLeft, via: points.topRight, radius: 20, - prefix: "tr", + prefix: 'tr', render: true - }); + }) - return part; -}; + return part +} diff --git a/packages/examples/src/plugin_scalebox.js b/packages/examples/src/plugin_scalebox.js index c6e624a34c7..07476144d1e 100644 --- a/packages/examples/src/plugin_scalebox.js +++ b/packages/examples/src/plugin_scalebox.js @@ -1,11 +1,11 @@ export default part => { - let { Point, points, macro } = part.shorthand(); + let { Point, points, macro } = part.shorthand() - points.anchor = new Point(0, 0); + points.anchor = new Point(0, 0) - macro("scalebox", { + macro('scalebox', { at: points.anchor - }); + }) - return part; -}; + return part +} diff --git a/packages/examples/src/plugin_sprinkle.js b/packages/examples/src/plugin_sprinkle.js index 4e086f8b481..b59c1974e49 100644 --- a/packages/examples/src/plugin_sprinkle.js +++ b/packages/examples/src/plugin_sprinkle.js @@ -1,22 +1,22 @@ -import { box } from "./shared"; +import { box } from './shared' export default part => { - let { Point, points, macro } = part.shorthand(); + let { Point, points, macro } = part.shorthand() - points.a = new Point(10, 10); - points.b = new Point(20, 15); - points.c = new Point(30, 10); - points.d = new Point(40, 15); - points.e = new Point(50, 10); - points.f = new Point(60, 15); - points.g = new Point(70, 10); - points.h = new Point(80, 15); - points.i = new Point(90, 10); + points.a = new Point(10, 10) + points.b = new Point(20, 15) + points.c = new Point(30, 10) + points.d = new Point(40, 15) + points.e = new Point(50, 10) + points.f = new Point(60, 15) + points.g = new Point(70, 10) + points.h = new Point(80, 15) + points.i = new Point(90, 10) - macro("sprinkle", { - snippet: "button", - on: ["a", "b", "c", "d", "e", "f", "g", "h", "i"] - }); + macro('sprinkle', { + snippet: 'button', + on: ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i'] + }) - return box(part, 100, 25); -}; + return box(part, 100, 25) +} diff --git a/packages/examples/src/plugin_title.js b/packages/examples/src/plugin_title.js index be853ee3177..d9e33c565f3 100644 --- a/packages/examples/src/plugin_title.js +++ b/packages/examples/src/plugin_title.js @@ -1,16 +1,16 @@ -import { box } from "./shared"; +import { box } from './shared' export default part => { - let { Point, points, macro } = part.shorthand(); + let { Point, points, macro } = part.shorthand() - points.title = new Point(90, 45); + points.title = new Point(90, 45) - macro("title", { + macro('title', { at: points.title, nr: 4, - title: "sleeve", - prefix: "test" - }); + title: 'sleeve', + prefix: 'test' + }) - return box(part, 200, 70); -}; + return box(part, 200, 70) +} diff --git a/packages/examples/src/point_angle.js b/packages/examples/src/point_angle.js index 5cf17760d8b..a914b28f4b7 100644 --- a/packages/examples/src/point_angle.js +++ b/packages/examples/src/point_angle.js @@ -1,17 +1,17 @@ export default part => { - let { Point, points, Path, paths } = part.shorthand(); + let { Point, points, Path, paths } = part.shorthand() - points.sun = new Point(10, 5); - points.moon = points.sun.shift(-15, 70); + points.sun = new Point(10, 5) + points.moon = points.sun.shift(-15, 70) points.text = points.sun .shiftFractionTowards(points.moon, 0.8) - .attr("data-text", points.sun.angle(points.moon) + "°") - .attr("data-text-class", "text-sm fill-note center"); + .attr('data-text', points.sun.angle(points.moon) + '°') + .attr('data-text-class', 'text-sm fill-note center') paths.line = new Path() .move(points.sun) .line(points.moon) - .attr("class", "dashed"); + .attr('class', 'dashed') - return part; -}; + return part +} diff --git a/packages/examples/src/point_attr.js b/packages/examples/src/point_attr.js index 7578d6a60e1..d578a5f3975 100644 --- a/packages/examples/src/point_attr.js +++ b/packages/examples/src/point_attr.js @@ -1,11 +1,11 @@ -import { box } from "./shared"; +import { box } from './shared' export default part => { - let { Point, points } = part.shorthand(); + let { Point, points } = part.shorthand() points.anchor = new Point(100, 25) - .attr("data-text", "freesewingIsMadeByJoostDeCockAndContributors") - .attr("data-text-class", "center"); + .attr('data-text', 'freesewingIsMadeByJoostDeCockAndContributors') + .attr('data-text-class', 'center') - return box(part, 200, 50); -}; + return box(part, 200, 50) +} diff --git a/packages/examples/src/point_clone.js b/packages/examples/src/point_clone.js index 855430c5148..b582a02cfd7 100644 --- a/packages/examples/src/point_clone.js +++ b/packages/examples/src/point_clone.js @@ -1,15 +1,15 @@ -import { box } from "./shared"; +import { box } from './shared' export default part => { - let { Point, points, Snippet, snippets } = part.shorthand(); + let { Point, points, Snippet, snippets } = part.shorthand() points.A = new Point(25, 25) - .attr("data-text", "Point A") - .attr("data-text-class", "text-xl") - .attr("data-text-fill-opacity", "0.5"); - points.B = points.A.clone().attr("data-text", "Point B"); + .attr('data-text', 'Point A') + .attr('data-text-class', 'text-xl') + .attr('data-text-fill-opacity', '0.5') + points.B = points.A.clone().attr('data-text', 'Point B') - snippets.x = new Snippet("notch", points.A); + snippets.x = new Snippet('notch', points.A) - return box(part); -}; + return box(part) +} diff --git a/packages/examples/src/point_copy.js b/packages/examples/src/point_copy.js index 467b8a7ca3e..9b2f42354b6 100644 --- a/packages/examples/src/point_copy.js +++ b/packages/examples/src/point_copy.js @@ -1,14 +1,12 @@ -import { box } from "./shared"; +import { box } from './shared' export default part => { - let { Point, points, Snippet, snippets } = part.shorthand(); + let { Point, points, Snippet, snippets } = part.shorthand() - points.A = new Point(50, 25) - .attr("data-text", "Point A") - .attr("data-text-class", "text-xl"); - points.B = points.A.copy().attr("data-text", "Point B"); + points.A = new Point(50, 25).attr('data-text', 'Point A').attr('data-text-class', 'text-xl') + points.B = points.A.copy().attr('data-text', 'Point B') - snippets.x = new Snippet("notch", points.A); + snippets.x = new Snippet('notch', points.A) - return box(part); -}; + return box(part) +} diff --git a/packages/examples/src/point_dist.js b/packages/examples/src/point_dist.js index 3fd705a6357..ce7127348eb 100644 --- a/packages/examples/src/point_dist.js +++ b/packages/examples/src/point_dist.js @@ -1,13 +1,13 @@ export default part => { - let { Point, points, macro } = part.shorthand(); + let { Point, points, macro } = part.shorthand() - points.from = new Point(10, 10); - points.to = new Point(90, 40); + points.from = new Point(10, 10) + points.to = new Point(90, 40) - macro("ld", { + macro('ld', { from: points.from, to: points.to - }); + }) - return part; -}; + return part +} diff --git a/packages/examples/src/point_dx.js b/packages/examples/src/point_dx.js index 3e4c0326b5e..1dc68d73d54 100644 --- a/packages/examples/src/point_dx.js +++ b/packages/examples/src/point_dx.js @@ -1,14 +1,14 @@ export default part => { - let { Point, points, macro } = part.shorthand(); + let { Point, points, macro } = part.shorthand() - points.from = new Point(10, 10); - points.to = new Point(90, 40); + points.from = new Point(10, 10) + points.to = new Point(90, 40) - macro("hd", { + macro('hd', { from: points.from, to: points.to, y: 25 - }); + }) - return part; -}; + return part +} diff --git a/packages/examples/src/point_dy.js b/packages/examples/src/point_dy.js index 27b18d8a121..dd0b1d7c69b 100644 --- a/packages/examples/src/point_dy.js +++ b/packages/examples/src/point_dy.js @@ -1,14 +1,14 @@ export default part => { - let { Point, points, macro } = part.shorthand(); + let { Point, points, macro } = part.shorthand() - points.from = new Point(10, 10); - points.to = new Point(90, 40); + points.from = new Point(10, 10) + points.to = new Point(90, 40) - macro("vd", { + macro('vd', { from: points.to, to: points.from, x: 50 - }); + }) - return part; -}; + return part +} diff --git a/packages/examples/src/point_flipx.js b/packages/examples/src/point_flipx.js index e710422bf6e..6a5e4a407b0 100644 --- a/packages/examples/src/point_flipx.js +++ b/packages/examples/src/point_flipx.js @@ -1,25 +1,25 @@ export default part => { - let { Point, points, Path, paths } = part.shorthand(); + let { Point, points, Path, paths } = part.shorthand() - points.top = new Point(50, 10); - points.out1 = new Point(70, 30); - points.in1 = new Point(55, 35); - points.out2 = new Point(75, 50); - points.in2 = new Point(60, 55); - points.out3 = new Point(80, 70); - points.in3 = new Point(55, 70); - points.trunkOut = new Point(55, 80); - points.trunkIn = new Point(50, 80); + points.top = new Point(50, 10) + points.out1 = new Point(70, 30) + points.in1 = new Point(55, 35) + points.out2 = new Point(75, 50) + points.in2 = new Point(60, 55) + points.out3 = new Point(80, 70) + points.in3 = new Point(55, 70) + points.trunkOut = new Point(55, 80) + points.trunkIn = new Point(50, 80) - points._out1 = points.out1.flipX(points.top); - points._in1 = points.in1.flipX(points.top); - points._out2 = points.out2.flipX(points.top); - points._in2 = points.in2.flipX(points.top); - points._out3 = points.out3.flipX(points.top); - points._in3 = points.in3.flipX(points.top); - points._trunkOut = points.trunkOut.flipX(points.top); + points._out1 = points.out1.flipX(points.top) + points._in1 = points.in1.flipX(points.top) + points._out2 = points.out2.flipX(points.top) + points._in2 = points.in2.flipX(points.top) + points._out3 = points.out3.flipX(points.top) + points._in3 = points.in3.flipX(points.top) + points._trunkOut = points.trunkOut.flipX(points.top) - points.bottom = new Point(50, 80); + points.bottom = new Point(50, 80) paths.tree = new Path() .move(points.top) @@ -37,12 +37,12 @@ export default part => { .line(points._out2) .line(points._in1) .line(points._out1) - .close(); + .close() paths.mirror = new Path() .move(points.top) .line(points.bottom) - .attr("class", "note dashed"); + .attr('class', 'note dashed') - return part; -}; + return part +} diff --git a/packages/examples/src/point_flipy.js b/packages/examples/src/point_flipy.js index ea1673d7633..b7b88dc9269 100644 --- a/packages/examples/src/point_flipy.js +++ b/packages/examples/src/point_flipy.js @@ -1,38 +1,36 @@ export default part => { - let { Point, points, Path, paths } = part.shorthand(); + let { Point, points, Path, paths } = part.shorthand() - points.start = new Point(0, 50); - points.churchTowerWallLeft = new Point(10, 50); - points.churchTowerRoofLeft = new Point(10, 30); - points.churchTowerTop = new Point(15, 10); - points.churchTowerRoofRight = new Point(20, 30); - points.churchRoofRight = new Point(50, 30); - points.churchWallRight = new Point(50, 50); - points.houseWallLeft = new Point(65, 50); - points.houseRoofLeft = new Point(65, 35); - points.houseRoofTop = new Point(75, 25); - points.houseRoofRight = new Point(85, 35); - points.houseWallRight = new Point(85, 50); - points.end = new Point(95, 50); + points.start = new Point(0, 50) + points.churchTowerWallLeft = new Point(10, 50) + points.churchTowerRoofLeft = new Point(10, 30) + points.churchTowerTop = new Point(15, 10) + points.churchTowerRoofRight = new Point(20, 30) + points.churchRoofRight = new Point(50, 30) + points.churchWallRight = new Point(50, 50) + points.houseWallLeft = new Point(65, 50) + points.houseRoofLeft = new Point(65, 35) + points.houseRoofTop = new Point(75, 25) + points.houseRoofRight = new Point(85, 35) + points.houseWallRight = new Point(85, 50) + points.end = new Point(95, 50) - points.mirror = new Point(0, 60); - points.mirrorLineEnd = new Point(95, 60); + points.mirror = new Point(0, 60) + points.mirrorLineEnd = new Point(95, 60) - points._start = points.start.flipY(points.mirror); - points._churchTowerWallLeft = points.churchTowerWallLeft.flipY(points.mirror); - points._churchTowerRoofLeft = points.churchTowerRoofLeft.flipY(points.mirror); - points._churchTowerTop = points.churchTowerTop.flipY(points.mirror); - points._churchTowerRoofRight = points.churchTowerRoofRight.flipY( - points.mirror - ); - points._churchRoofRight = points.churchRoofRight.flipY(points.mirror); - points._churchWallRight = points.churchWallRight.flipY(points.mirror); - points._houseWallLeft = points.houseWallLeft.flipY(points.mirror); - points._houseRoofLeft = points.houseRoofLeft.flipY(points.mirror); - points._houseRoofTop = points.houseRoofTop.flipY(points.mirror); - points._houseRoofRight = points.houseRoofRight.flipY(points.mirror); - points._houseWallRight = points.houseWallRight.flipY(points.mirror); - points._end = points.end.flipY(points.mirror); + points._start = points.start.flipY(points.mirror) + points._churchTowerWallLeft = points.churchTowerWallLeft.flipY(points.mirror) + points._churchTowerRoofLeft = points.churchTowerRoofLeft.flipY(points.mirror) + points._churchTowerTop = points.churchTowerTop.flipY(points.mirror) + points._churchTowerRoofRight = points.churchTowerRoofRight.flipY(points.mirror) + points._churchRoofRight = points.churchRoofRight.flipY(points.mirror) + points._churchWallRight = points.churchWallRight.flipY(points.mirror) + points._houseWallLeft = points.houseWallLeft.flipY(points.mirror) + points._houseRoofLeft = points.houseRoofLeft.flipY(points.mirror) + points._houseRoofTop = points.houseRoofTop.flipY(points.mirror) + points._houseRoofRight = points.houseRoofRight.flipY(points.mirror) + points._houseWallRight = points.houseWallRight.flipY(points.mirror) + points._end = points.end.flipY(points.mirror) paths.skylineTop = new Path() .move(points.start) @@ -47,7 +45,7 @@ export default part => { .line(points.houseRoofTop) .line(points.houseRoofRight) .line(points.houseWallRight) - .line(points.end); + .line(points.end) paths.skylineBottom = new Path() .move(points._start) @@ -62,12 +60,12 @@ export default part => { .line(points._houseRoofTop) .line(points._houseRoofRight) .line(points._houseWallRight) - .line(points._end); + .line(points._end) paths.mirrorLine = new Path() .move(points.mirror) .line(points.mirrorLineEnd) - .attr("class", "note dashed"); + .attr('class', 'note dashed') - return part; -}; + return part +} diff --git a/packages/examples/src/point_rotate.js b/packages/examples/src/point_rotate.js index 9c6ccc62efb..cd22ac38fc1 100644 --- a/packages/examples/src/point_rotate.js +++ b/packages/examples/src/point_rotate.js @@ -1,14 +1,14 @@ export default part => { - let { Point, points, Path, paths } = part.shorthand(); + let { Point, points, Path, paths } = part.shorthand() - points.sun = new Point(40, 40); - points.moon = new Point(70, 40); - let step = 360 / 36; + points.sun = new Point(40, 40) + points.moon = new Point(70, 40) + let step = 360 / 36 for (let i = 1; i < 37; i++) { - let angle = step * i; - points[`moon${i}`] = points.moon.rotate(angle, points.sun); - paths[`moon${i}`] = new Path().move(points.sun).line(points[`moon${i}`]); + let angle = step * i + points[`moon${i}`] = points.moon.rotate(angle, points.sun) + paths[`moon${i}`] = new Path().move(points.sun).line(points[`moon${i}`]) } - return part; -}; + return part +} diff --git a/packages/examples/src/point_shift.js b/packages/examples/src/point_shift.js index 6f91255b63d..fdc29732b37 100644 --- a/packages/examples/src/point_shift.js +++ b/packages/examples/src/point_shift.js @@ -1,20 +1,18 @@ -import { box } from "./shared"; +import { box } from './shared' export default part => { - let { Point, points, macro } = part.shorthand(); + let { Point, points, macro } = part.shorthand() - points.A = new Point(90, 40) - .attr("data-text", "Point A") - .attr("data-text-class", "right"); + points.A = new Point(90, 40).attr('data-text', 'Point A').attr('data-text-class', 'right') points.B = points.A.shift(155, 70) - .attr("data-text", "Point B is point A shifted 7cm\nat a 155 degree angle") - .attr("data-text-lineheight", 6); + .attr('data-text', 'Point B is point A shifted 7cm\nat a 155 degree angle') + .attr('data-text-lineheight', 6) - macro("ld", { + macro('ld', { from: points.B, to: points.A, d: -10 - }); + }) - return box(part, 100, 45); -}; + return box(part, 100, 45) +} diff --git a/packages/examples/src/point_shiftfractiontowards.js b/packages/examples/src/point_shiftfractiontowards.js index faca8329351..4e4a608127d 100644 --- a/packages/examples/src/point_shiftfractiontowards.js +++ b/packages/examples/src/point_shiftfractiontowards.js @@ -1,32 +1,29 @@ export default part => { - let { Point, points, Path, paths, macro } = part.shorthand(); + let { Point, points, Path, paths, macro } = part.shorthand() - points.A = new Point(90, 70).attr("data-text", "Point A"); - points.B = new Point(10, 10).attr("data-text", "Point B"); + points.A = new Point(90, 70).attr('data-text', 'Point A') + points.B = new Point(10, 10).attr('data-text', 'Point B') points.C = points.A.shiftFractionTowards(points.B, 0.5) - .attr( - "data-text", - "Point C is point A shifted 50%\nin the direction of point B" - ) - .attr("data-text-class", "center") - .attr("data-text-lineheight", 6); + .attr('data-text', 'Point C is point A shifted 50%\nin the direction of point B') + .attr('data-text-class', 'center') + .attr('data-text-lineheight', 6) paths.direction = new Path() .move(points.A) .line(points.B) - .attr("class", "note dashed"); + .attr('class', 'note dashed') - macro("ld", { + macro('ld', { from: points.C, to: points.A, d: -10 - }); + }) - macro("ld", { + macro('ld', { from: points.B, to: points.A, d: 20 - }); + }) - return part; -}; + return part +} diff --git a/packages/examples/src/point_shiftoutwards.js b/packages/examples/src/point_shiftoutwards.js index 648c5f22789..7217461cc00 100644 --- a/packages/examples/src/point_shiftoutwards.js +++ b/packages/examples/src/point_shiftoutwards.js @@ -1,24 +1,24 @@ -import { box } from "./shared"; +import { box } from './shared' export default part => { - let { Point, points, Path, paths, macro } = part.shorthand(); + let { Point, points, Path, paths, macro } = part.shorthand() - points.A = new Point(90, 70).attr("data-text", "Point A"); - points.B = new Point(30, 30).attr("data-text", "Point B"); + points.A = new Point(90, 70).attr('data-text', 'Point A') + points.B = new Point(30, 30).attr('data-text', 'Point B') points.C = points.A.shiftOutwards(points.B, 30) - .attr("data-text", "Point C is point A shifted 3cm\nbeyond point B") - .attr("data-text-lineheight", 6); + .attr('data-text', 'Point C is point A shifted 3cm\nbeyond point B') + .attr('data-text-lineheight', 6) paths.direction = new Path() .move(points.A) .line(points.C) - .attr("class", "note dashed"); + .attr('class', 'note dashed') - macro("ld", { + macro('ld', { from: points.C, to: points.B, d: -10 - }); + }) - return box(part, 110, 75); -}; + return box(part, 110, 75) +} diff --git a/packages/examples/src/point_shifttowards.js b/packages/examples/src/point_shifttowards.js index e4ebed1ed63..2a642bdf7bf 100644 --- a/packages/examples/src/point_shifttowards.js +++ b/packages/examples/src/point_shifttowards.js @@ -1,28 +1,25 @@ -import { box } from "./shared"; +import { box } from './shared' export default part => { - let { Point, points, Path, paths, macro } = part.shorthand(); + let { Point, points, Path, paths, macro } = part.shorthand() - points.A = new Point(90, 70).attr("data-text", "Point A"); - points.B = new Point(10, 10).attr("data-text", "Point B"); + points.A = new Point(90, 70).attr('data-text', 'Point A') + points.B = new Point(10, 10).attr('data-text', 'Point B') points.C = points.A.shiftTowards(points.B, 35) - .attr( - "data-text", - "Point C is point A shifted 3.5cm\nin the direction of point B" - ) - .attr("data-text-class", "center") - .attr("data-text-lineheight", 6); + .attr('data-text', 'Point C is point A shifted 3.5cm\nin the direction of point B') + .attr('data-text-class', 'center') + .attr('data-text-lineheight', 6) paths.direction = new Path() .move(points.A) .line(points.B) - .attr("class", "note dashed"); + .attr('class', 'note dashed') - macro("ld", { + macro('ld', { from: points.C, to: points.A, d: -10 - }); + }) - return box(part, 110, 80); -}; + return box(part, 110, 80) +} diff --git a/packages/examples/src/point_sitson.js b/packages/examples/src/point_sitson.js index 2b1f919c4ad..081bdf27390 100644 --- a/packages/examples/src/point_sitson.js +++ b/packages/examples/src/point_sitson.js @@ -1,17 +1,17 @@ -import { box } from "./shared"; +import { box } from './shared' export default part => { - let { Point, points, Snippet, snippets } = part.shorthand(); + let { Point, points, Snippet, snippets } = part.shorthand() - let s; + let s for (let i = 0; i < 10; i++) { - points[`a${i}`] = new Point(i * 10, 40); - points[`b${i}`] = new Point(i * 10, i * 8); - if (points[`a${i}`].sitsOn(points[`b${i}`])) s = "notch"; - else s = "bnotch"; - snippets[`b${i}`] = new Snippet(s, points[`b${i}`]); - snippets[`a${i}`] = new Snippet(s, points[`a${i}`]); + points[`a${i}`] = new Point(i * 10, 40) + points[`b${i}`] = new Point(i * 10, i * 8) + if (points[`a${i}`].sitsOn(points[`b${i}`])) s = 'notch' + else s = 'bnotch' + snippets[`b${i}`] = new Snippet(s, points[`b${i}`]) + snippets[`a${i}`] = new Snippet(s, points[`a${i}`]) } - return box(part); -}; + return box(part) +} diff --git a/packages/examples/src/point_sitsroughlyon.js b/packages/examples/src/point_sitsroughlyon.js index a94e8239a43..84ccf042d9a 100644 --- a/packages/examples/src/point_sitsroughlyon.js +++ b/packages/examples/src/point_sitsroughlyon.js @@ -1,19 +1,19 @@ -import { box } from "./shared"; +import { box } from './shared' export default part => { - let { Point, points, Snippet, snippets } = part.shorthand(); + let { Point, points, Snippet, snippets } = part.shorthand() - box(part); + box(part) - let s; + let s for (let i = 0; i < 10; i++) { - points[`a${i}`] = new Point(i * 10, 40); - points[`b${i}`] = new Point(i * 10, i * 8); - if (points[`a${i}`].sitsRoughlyOn(points[`b${i}`])) s = "notch"; - else s = "bnotch"; - snippets[`b${i}`] = new Snippet(s, points[`b${i}`]); - snippets[`a${i}`] = new Snippet(s, points[`a${i}`]); + points[`a${i}`] = new Point(i * 10, 40) + points[`b${i}`] = new Point(i * 10, i * 8) + if (points[`a${i}`].sitsRoughlyOn(points[`b${i}`])) s = 'notch' + else s = 'bnotch' + snippets[`b${i}`] = new Snippet(s, points[`b${i}`]) + snippets[`a${i}`] = new Snippet(s, points[`a${i}`]) } - return part; -}; + return part +} diff --git a/packages/examples/src/point_translate.js b/packages/examples/src/point_translate.js index 7a774a7a905..878b943d992 100644 --- a/packages/examples/src/point_translate.js +++ b/packages/examples/src/point_translate.js @@ -1,24 +1,21 @@ -import { box } from "./shared"; +import { box } from './shared' export default part => { - let { Point, points, macro } = part.shorthand(); + let { Point, points, macro } = part.shorthand() - points.A = new Point(20, 20).attr("data-text", "Point A"); + points.A = new Point(20, 20).attr('data-text', 'Point A') points.B = points.A.translate(120, 60) - .attr( - "data-text", - "Point B is point A with a\ntranslate(120, 60)\ntransform applied" - ) - .attr("data-text-class", "right") - .attr("data-text-dy", -6) - .attr("data-text-lineheight", 6); + .attr('data-text', 'Point B is point A with a\ntranslate(120, 60)\ntransform applied') + .attr('data-text-class', 'right') + .attr('data-text-dy', -6) + .attr('data-text-lineheight', 6) - macro("ld", { + macro('ld', { from: points.A, to: points.B, - text: "translate(120,60)", + text: 'translate(120,60)', noStartMarker: true - }); + }) - return box(part, 150, 85); -}; + return box(part, 150, 85) +} diff --git a/packages/examples/src/settings_sa.js b/packages/examples/src/settings_sa.js index b38004e982c..99f62e0f7cf 100644 --- a/packages/examples/src/settings_sa.js +++ b/packages/examples/src/settings_sa.js @@ -1,11 +1,11 @@ export default part => { - let { Point, points, Path, paths } = part.shorthand(); + let { Point, points, Path, paths } = part.shorthand() - points.A = new Point(45, 60); - points.B = new Point(10, 30); - points.BCp2 = new Point(40, 20); - points.C = new Point(90, 30); - points.CCp1 = new Point(50, -30); + points.A = new Point(45, 60) + points.B = new Point(10, 30) + points.BCp2 = new Point(40, 20) + points.C = new Point(90, 30) + points.CCp1 = new Point(50, -30) paths.example = new Path() .move(points.A) @@ -13,9 +13,9 @@ export default part => { .curve(points.BCp2, points.CCp1, points.C) .line(points.A) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') - paths.offset = paths.example.offset(-10).attr("class", "fabric sa"); + paths.offset = paths.example.offset(-10).attr('class', 'fabric sa') - return part; -}; + return part +} diff --git a/packages/examples/src/shared.js b/packages/examples/src/shared.js index 4b427d72d66..5cfce74186d 100644 --- a/packages/examples/src/shared.js +++ b/packages/examples/src/shared.js @@ -7,7 +7,7 @@ export function box(part, w = 100, h = 50) { part.paths.box = new part.Path() .move(new part.Point(0, 0)) .line(new part.Point(w, h)) - .attr("class", "hidden"); + .attr('class', 'hidden') - return part; + return part } diff --git a/packages/examples/src/snippet.js b/packages/examples/src/snippet.js index 41cfa09f8d5..ab6e42c499c 100644 --- a/packages/examples/src/snippet.js +++ b/packages/examples/src/snippet.js @@ -1,14 +1,14 @@ -import { box } from "./shared"; +import { box } from './shared' export default part => { - let { Point, points, Snippet, snippets } = part.shorthand(); + let { Point, points, Snippet, snippets } = part.shorthand() - points.anchor1 = new Point(20, 15); - points.anchor2 = new Point(50, 15); - points.anchor3 = new Point(80, 15); - snippets.demo1 = new Snippet("button", points.anchor1); - snippets.demo2 = new Snippet("buttonhole", points.anchor2); - snippets.demo3 = new Snippet("logo", points.anchor3).attr("data-scale", 0.5); + points.anchor1 = new Point(20, 15) + points.anchor2 = new Point(50, 15) + points.anchor3 = new Point(80, 15) + snippets.demo1 = new Snippet('button', points.anchor1) + snippets.demo2 = new Snippet('buttonhole', points.anchor2) + snippets.demo3 = new Snippet('logo', points.anchor3).attr('data-scale', 0.5) - return box(part); -}; + return box(part) +} diff --git a/packages/examples/src/snippet_attr.js b/packages/examples/src/snippet_attr.js index b6de0d0a2e7..cc5417a1393 100644 --- a/packages/examples/src/snippet_attr.js +++ b/packages/examples/src/snippet_attr.js @@ -1,12 +1,12 @@ -import { box } from "./shared"; +import { box } from './shared' export default part => { - let { Point, points, Snippet, snippets } = part.shorthand(); + let { Point, points, Snippet, snippets } = part.shorthand() - points.anchor = new Point(50, 15); - snippets.demo = new Snippet("logo", points.anchor) - .attr("data-scale", 0.8) - .attr("data-rotate", 180); + points.anchor = new Point(50, 15) + snippets.demo = new Snippet('logo', points.anchor) + .attr('data-scale', 0.8) + .attr('data-rotate', 180) - return box(part); -}; + return box(part) +} diff --git a/packages/examples/src/snippet_clone.js b/packages/examples/src/snippet_clone.js index 6c20f838216..32bcf3d9827 100644 --- a/packages/examples/src/snippet_clone.js +++ b/packages/examples/src/snippet_clone.js @@ -1,15 +1,12 @@ -import { box } from "./shared"; +import { box } from './shared' export default part => { - let { Point, points, Snippet, snippets } = part.shorthand(); + let { Point, points, Snippet, snippets } = part.shorthand() - points.anchor = new Point(35, 35); - snippets.demo = new Snippet("logo", points.anchor).attr( - "style", - "color: #f006" - ); + points.anchor = new Point(35, 35) + snippets.demo = new Snippet('logo', points.anchor).attr('style', 'color: #f006') - snippets.clone = snippets.demo.clone().attr("data-scale", 0.5); + snippets.clone = snippets.demo.clone().attr('data-scale', 0.5) - return box(part); -}; + return box(part) +} diff --git a/packages/examples/src/utils_beamintersectscircle.js b/packages/examples/src/utils_beamintersectscircle.js index 1e6a5f58fdb..b23be2933e1 100644 --- a/packages/examples/src/utils_beamintersectscircle.js +++ b/packages/examples/src/utils_beamintersectscircle.js @@ -1,56 +1,46 @@ -import { box } from "./shared"; +import { box } from './shared' export default part => { - let { - Point, - points, - Path, - paths, - Snippet, - snippets, - utils - } = part.shorthand(); + let { Point, points, Path, paths, Snippet, snippets, utils } = part.shorthand() - points.A = new Point(95, 45) - .attr("data-circle", 35) - .attr("data-circle-class", "fabric"); - points.B = new Point(55, 50); - points.C = new Point(75, 30); - points.D = new Point(55, 65); - points.E = new Point(115, 5); - points.F = new Point(65, 75); - points.G = new Point(125, 15); + points.A = new Point(95, 45).attr('data-circle', 35).attr('data-circle-class', 'fabric') + points.B = new Point(55, 50) + points.C = new Point(75, 30) + points.D = new Point(55, 65) + points.E = new Point(115, 5) + points.F = new Point(65, 75) + points.G = new Point(125, 15) - paths.line1 = new Path().move(points.B).line(points.C); - paths.line2 = new Path().move(points.D).line(points.E); - paths.line3 = new Path().move(points.F).line(points.G); + paths.line1 = new Path().move(points.B).line(points.C) + paths.line2 = new Path().move(points.D).line(points.E) + paths.line3 = new Path().move(points.F).line(points.G) let intersections1 = utils.beamIntersectsCircle( points.A, - points.A.attributes.get("data-circle"), + points.A.attributes.get('data-circle'), points.B, points.C - ); + ) let intersections2 = utils.beamIntersectsCircle( points.A, - points.A.attributes.get("data-circle"), + points.A.attributes.get('data-circle'), points.D, points.E, - "y" - ); + 'y' + ) let intersections3 = utils.beamIntersectsCircle( points.A, - points.A.attributes.get("data-circle"), + points.A.attributes.get('data-circle'), points.F, points.G - ); + ) - snippets.first1 = new Snippet("bnotch", intersections1[0]); - snippets.second1 = new Snippet("notch", intersections1[1]); - snippets.first2 = new Snippet("bnotch", intersections2[0]); - snippets.second2 = new Snippet("notch", intersections2[1]); - snippets.first3 = new Snippet("bnotch", intersections3[0]); - snippets.second3 = new Snippet("notch", intersections3[1]); + snippets.first1 = new Snippet('bnotch', intersections1[0]) + snippets.second1 = new Snippet('notch', intersections1[1]) + snippets.first2 = new Snippet('bnotch', intersections2[0]) + snippets.second2 = new Snippet('notch', intersections2[1]) + snippets.first3 = new Snippet('bnotch', intersections3[0]) + snippets.second3 = new Snippet('notch', intersections3[1]) - return box(part, 200, 80); -}; + return box(part, 200, 80) +} diff --git a/packages/examples/src/utils_beamintersectsx.js b/packages/examples/src/utils_beamintersectsx.js index f1dc60300a9..697a3462a52 100644 --- a/packages/examples/src/utils_beamintersectsx.js +++ b/packages/examples/src/utils_beamintersectsx.js @@ -1,28 +1,17 @@ export default part => { - let { - Point, - points, - Path, - paths, - Snippet, - snippets, - utils - } = part.shorthand(); + let { Point, points, Path, paths, Snippet, snippets, utils } = part.shorthand() - points.A = new Point(10, 10); - points.B = new Point(90, 30); + points.A = new Point(10, 10) + points.B = new Point(90, 30) - paths.AB = new Path().move(points.A).line(points.B); + paths.AB = new Path().move(points.A).line(points.B) - snippets.x = new Snippet( - "notch", - utils.beamIntersectsX(points.A, points.B, 40) - ); + snippets.x = new Snippet('notch', utils.beamIntersectsX(points.A, points.B, 40)) paths.help = new Path() .move(new Point(40, 5)) .line(new Point(40, 35)) - .attr("class", "note dashed"); + .attr('class', 'note dashed') - return part; -}; + return part +} diff --git a/packages/examples/src/utils_beamintersectsy.js b/packages/examples/src/utils_beamintersectsy.js index 5f54a76b3e5..7eb84ad529b 100644 --- a/packages/examples/src/utils_beamintersectsy.js +++ b/packages/examples/src/utils_beamintersectsy.js @@ -1,28 +1,17 @@ export default part => { - let { - Point, - points, - Path, - paths, - Snippet, - snippets, - utils - } = part.shorthand(); + let { Point, points, Path, paths, Snippet, snippets, utils } = part.shorthand() - points.A = new Point(10, 10); - points.B = new Point(50, 40); + points.A = new Point(10, 10) + points.B = new Point(50, 40) - paths.AB = new Path().move(points.A).line(points.B); + paths.AB = new Path().move(points.A).line(points.B) - snippets.x = new Snippet( - "notch", - utils.beamIntersectsY(points.A, points.B, 30) - ); + snippets.x = new Snippet('notch', utils.beamIntersectsY(points.A, points.B, 30)) paths.help = new Path() .move(new Point(0, 30)) .line(new Point(50, 30)) - .attr("class", "note dashed"); + .attr('class', 'note dashed') - return part; -}; + return part +} diff --git a/packages/examples/src/utils_beamsintersect.js b/packages/examples/src/utils_beamsintersect.js index 82c6f5fd868..f1cfa85a5cd 100644 --- a/packages/examples/src/utils_beamsintersect.js +++ b/packages/examples/src/utils_beamsintersect.js @@ -1,26 +1,15 @@ export default part => { - let { - Point, - points, - Path, - paths, - Snippet, - snippets, - utils - } = part.shorthand(); + let { Point, points, Path, paths, Snippet, snippets, utils } = part.shorthand() - points.A = new Point(10, 10); - points.B = new Point(50, 40); - points.C = new Point(45, 20); - points.D = new Point(60, 15); + points.A = new Point(10, 10) + points.B = new Point(50, 40) + points.C = new Point(45, 20) + points.D = new Point(60, 15) - paths.AB = new Path().move(points.A).line(points.B); - paths.CD = new Path().move(points.C).line(points.D); + paths.AB = new Path().move(points.A).line(points.B) + paths.CD = new Path().move(points.C).line(points.D) - snippets.x = new Snippet( - "notch", - utils.beamsIntersect(points.A, points.B, points.C, points.D) - ); + snippets.x = new Snippet('notch', utils.beamsIntersect(points.A, points.B, points.C, points.D)) - return part; -}; + return part +} diff --git a/packages/examples/src/utils_circlesintersect.js b/packages/examples/src/utils_circlesintersect.js index 5a0cb960428..eea8f06bd38 100644 --- a/packages/examples/src/utils_circlesintersect.js +++ b/packages/examples/src/utils_circlesintersect.js @@ -1,37 +1,29 @@ export default part => { - let { Point, points, Snippet, snippets, utils } = part.shorthand(); + let { Point, points, Snippet, snippets, utils } = part.shorthand() - points.A = new Point(10, 10) - .attr("data-circle", 15) - .attr("data-circle-class", "fabric"); - points.B = new Point(30, 30) - .attr("data-circle", 35) - .attr("data-circle-class", "fabric"); - points.C = new Point(90, 10) - .attr("data-circle", 15) - .attr("data-circle-class", "various"); - points.D = new Point(110, 30) - .attr("data-circle", 35) - .attr("data-circle-class", "various"); + points.A = new Point(10, 10).attr('data-circle', 15).attr('data-circle-class', 'fabric') + points.B = new Point(30, 30).attr('data-circle', 35).attr('data-circle-class', 'fabric') + points.C = new Point(90, 10).attr('data-circle', 15).attr('data-circle-class', 'various') + points.D = new Point(110, 30).attr('data-circle', 35).attr('data-circle-class', 'various') let intersections1 = utils.circlesIntersect( points.A, - points.A.attributes.get("data-circle"), + points.A.attributes.get('data-circle'), points.B, - points.B.attributes.get("data-circle") - ); + points.B.attributes.get('data-circle') + ) let intersections2 = utils.circlesIntersect( points.C, - points.C.attributes.get("data-circle"), + points.C.attributes.get('data-circle'), points.D, - points.D.attributes.get("data-circle"), - "y" - ); + points.D.attributes.get('data-circle'), + 'y' + ) - snippets.first1 = new Snippet("bnotch", intersections1[0]); - snippets.second1 = new Snippet("notch", intersections1[1]); - snippets.first2 = new Snippet("bnotch", intersections2[0]); - snippets.second2 = new Snippet("notch", intersections2[1]); + snippets.first1 = new Snippet('bnotch', intersections1[0]) + snippets.second1 = new Snippet('notch', intersections1[1]) + snippets.first2 = new Snippet('bnotch', intersections2[0]) + snippets.second2 = new Snippet('notch', intersections2[1]) - return part; -}; + return part +} diff --git a/packages/examples/src/utils_curveintersectsx.js b/packages/examples/src/utils_curveintersectsx.js index b071c246e46..63b6b666698 100644 --- a/packages/examples/src/utils_curveintersectsx.js +++ b/packages/examples/src/utils_curveintersectsx.js @@ -1,45 +1,29 @@ export default part => { - let { - Point, - points, - Path, - paths, - utils, - snippets, - Snippet - } = part.shorthand(); + let { Point, points, Path, paths, utils, snippets, Snippet } = part.shorthand() - points.start = new Point(10, 15); - points.cp1 = new Point(80, 10); - points.cp2 = new Point(-50, 80); - points.end = new Point(110, 70); + points.start = new Point(10, 15) + points.cp1 = new Point(80, 10) + points.cp2 = new Point(-50, 80) + points.end = new Point(110, 70) - paths.curve = new Path() - .move(points.start) - .curve(points.cp1, points.cp2, points.end); + paths.curve = new Path().move(points.start).curve(points.cp1, points.cp2, points.end) for (let x of [30, 40]) { - points["from" + x] = new Point(x, 10); - points["to" + x] = new Point(x, 80); - paths["line" + x] = new Path() - .move(points["from" + x]) - .line(points["to" + x]) - .attr("class", "lining dashed"); + points['from' + x] = new Point(x, 10) + points['to' + x] = new Point(x, 80) + paths['line' + x] = new Path() + .move(points['from' + x]) + .line(points['to' + x]) + .attr('class', 'lining dashed') } snippets.i40 = new Snippet( - "notch", + 'notch', utils.curveIntersectsX(points.start, points.cp1, points.cp2, points.end, 40) - ); + ) - for (let p of utils.curveIntersectsX( - points.start, - points.cp1, - points.cp2, - points.end, - 30 - )) - snippets[p.y] = new Snippet("notch", p); + for (let p of utils.curveIntersectsX(points.start, points.cp1, points.cp2, points.end, 30)) + snippets[p.y] = new Snippet('notch', p) - return part; -}; + return part +} diff --git a/packages/examples/src/utils_curveintersectsy.js b/packages/examples/src/utils_curveintersectsy.js index 505d8fdf8a9..77b4dbe070b 100644 --- a/packages/examples/src/utils_curveintersectsy.js +++ b/packages/examples/src/utils_curveintersectsy.js @@ -1,45 +1,29 @@ export default part => { - let { - Point, - points, - Path, - paths, - utils, - snippets, - Snippet - } = part.shorthand(); + let { Point, points, Path, paths, utils, snippets, Snippet } = part.shorthand() - points.start = new Point(10, 45); - points.cp1 = new Point(50, 10); - points.cp2 = new Point(0, 80); - points.end = new Point(110, 70); + points.start = new Point(10, 45) + points.cp1 = new Point(50, 10) + points.cp2 = new Point(0, 80) + points.end = new Point(110, 70) - paths.curve = new Path() - .move(points.start) - .curve(points.cp1, points.cp2, points.end); + paths.curve = new Path().move(points.start).curve(points.cp1, points.cp2, points.end) for (let y of [40, 50]) { - points["from" + y] = new Point(10, y); - points["to" + y] = new Point(110, y); - paths["line" + y] = new Path() - .move(points["from" + y]) - .line(points["to" + y]) - .attr("class", "lining dashed"); + points['from' + y] = new Point(10, y) + points['to' + y] = new Point(110, y) + paths['line' + y] = new Path() + .move(points['from' + y]) + .line(points['to' + y]) + .attr('class', 'lining dashed') } snippets.i50 = new Snippet( - "notch", + 'notch', utils.curveIntersectsY(points.start, points.cp1, points.cp2, points.end, 50) - ); + ) - for (let p of utils.curveIntersectsY( - points.start, - points.cp1, - points.cp2, - points.end, - 40 - )) - snippets[p.x] = new Snippet("notch", p); + for (let p of utils.curveIntersectsY(points.start, points.cp1, points.cp2, points.end, 40)) + snippets[p.x] = new Snippet('notch', p) - return part; -}; + return part +} diff --git a/packages/examples/src/utils_curvesintersect.js b/packages/examples/src/utils_curvesintersect.js index 49006bc4083..45aecba32f4 100644 --- a/packages/examples/src/utils_curvesintersect.js +++ b/packages/examples/src/utils_curvesintersect.js @@ -1,29 +1,17 @@ export default part => { - let { - Point, - points, - Path, - paths, - Snippet, - snippets, - utils - } = part.shorthand(); + let { Point, points, Path, paths, Snippet, snippets, utils } = part.shorthand() - points.A = new Point(10, 10); - points.Acp = new Point(310, 40); - points.B = new Point(110, 70); - points.Bcp = new Point(-210, 40); + points.A = new Point(10, 10) + points.Acp = new Point(310, 40) + points.B = new Point(110, 70) + points.Bcp = new Point(-210, 40) - points.C = new Point(20, -5); - points.Ccp = new Point(60, 300); - points.D = new Point(100, 85); - points.Dcp = new Point(70, -220); - paths.curveA = new Path() - .move(points.A) - .curve(points.Acp, points.Bcp, points.B); - paths.curveB = new Path() - .move(points.C) - .curve(points.Ccp, points.Dcp, points.D); + points.C = new Point(20, -5) + points.Ccp = new Point(60, 300) + points.D = new Point(100, 85) + points.Dcp = new Point(70, -220) + paths.curveA = new Path().move(points.A).curve(points.Acp, points.Bcp, points.B) + paths.curveB = new Path().move(points.C).curve(points.Ccp, points.Dcp, points.D) for (let p of utils.curvesIntersect( points.A, @@ -35,8 +23,8 @@ export default part => { points.Dcp, points.D )) { - snippets[part.getId()] = new Snippet("notch", p); + snippets[part.getId()] = new Snippet('notch', p) } - return part; -}; + return part +} diff --git a/packages/examples/src/utils_lineintersectscircle.js b/packages/examples/src/utils_lineintersectscircle.js index ee0f946e369..ba31020f7c4 100644 --- a/packages/examples/src/utils_lineintersectscircle.js +++ b/packages/examples/src/utils_lineintersectscircle.js @@ -1,55 +1,45 @@ -import { box } from "./shared"; +import { box } from './shared' export default part => { - let { - Point, - points, - Path, - paths, - Snippet, - snippets, - utils - } = part.shorthand(); + let { Point, points, Path, paths, Snippet, snippets, utils } = part.shorthand() - points.A = new Point(95, 45) - .attr("data-circle", 35) - .attr("data-circle-class", "fabric"); - points.B = new Point(55, 50); - points.C = new Point(75, 30); + points.A = new Point(95, 45).attr('data-circle', 35).attr('data-circle-class', 'fabric') + points.B = new Point(55, 50) + points.C = new Point(75, 30) - points.D = new Point(55, 65); - points.E = new Point(115, 5); - points.F = new Point(65, 75); - points.G = new Point(125, 15); + points.D = new Point(55, 65) + points.E = new Point(115, 5) + points.F = new Point(65, 75) + points.G = new Point(125, 15) - paths.line1 = new Path().move(points.B).line(points.C); - paths.line2 = new Path().move(points.D).line(points.E); - paths.line3 = new Path().move(points.F).line(points.G); + paths.line1 = new Path().move(points.B).line(points.C) + paths.line2 = new Path().move(points.D).line(points.E) + paths.line3 = new Path().move(points.F).line(points.G) let intersections1 = utils.lineIntersectsCircle( points.A, - points.A.attributes.get("data-circle"), + points.A.attributes.get('data-circle'), points.B, points.C - ); + ) let intersections2 = utils.lineIntersectsCircle( points.A, - points.A.attributes.get("data-circle"), + points.A.attributes.get('data-circle'), points.D, points.E, - "y" - ); + 'y' + ) let intersections3 = utils.lineIntersectsCircle( points.A, - points.A.attributes.get("data-circle"), + points.A.attributes.get('data-circle'), points.F, points.G - ); - snippets.first1 = new Snippet("bnotch", intersections1[0]); - snippets.first2 = new Snippet("bnotch", intersections2[0]); - snippets.second2 = new Snippet("notch", intersections2[1]); - snippets.first3 = new Snippet("bnotch", intersections3[0]); - snippets.second3 = new Snippet("notch", intersections3[1]); + ) + snippets.first1 = new Snippet('bnotch', intersections1[0]) + snippets.first2 = new Snippet('bnotch', intersections2[0]) + snippets.second2 = new Snippet('notch', intersections2[1]) + snippets.first3 = new Snippet('bnotch', intersections3[0]) + snippets.second3 = new Snippet('notch', intersections3[1]) - return box(part, 200, 80); -}; + return box(part, 200, 80) +} diff --git a/packages/examples/src/utils_lineintersectscurve.js b/packages/examples/src/utils_lineintersectscurve.js index 9bcfc80c6f3..04c0725ac7f 100644 --- a/packages/examples/src/utils_lineintersectscurve.js +++ b/packages/examples/src/utils_lineintersectscurve.js @@ -1,24 +1,14 @@ export default part => { - let { - Point, - points, - Path, - paths, - Snippet, - snippets, - utils - } = part.shorthand(); + let { Point, points, Path, paths, Snippet, snippets, utils } = part.shorthand() - points.A = new Point(10, 10); - points.Acp = new Point(310, 40); - points.B = new Point(110, 70); - points.Bcp = new Point(-210, 40); - points.E = new Point(20, -5); - points.D = new Point(100, 85); - paths.curve = new Path() - .move(points.A) - .curve(points.Acp, points.Bcp, points.B); - paths.line = new Path().move(points.E).line(points.D); + points.A = new Point(10, 10) + points.Acp = new Point(310, 40) + points.B = new Point(110, 70) + points.Bcp = new Point(-210, 40) + points.E = new Point(20, -5) + points.D = new Point(100, 85) + paths.curve = new Path().move(points.A).curve(points.Acp, points.Bcp, points.B) + paths.line = new Path().move(points.E).line(points.D) for (let p of utils.lineIntersectsCurve( points.D, @@ -28,8 +18,8 @@ export default part => { points.Bcp, points.B )) { - snippets[part.getId()] = new Snippet("notch", p); + snippets[part.getId()] = new Snippet('notch', p) } - return part; -}; + return part +} diff --git a/packages/examples/src/utils_linesintersect.js b/packages/examples/src/utils_linesintersect.js index 7211213cf4d..f3bedccd9a6 100644 --- a/packages/examples/src/utils_linesintersect.js +++ b/packages/examples/src/utils_linesintersect.js @@ -1,26 +1,15 @@ export default part => { - let { - Point, - points, - Path, - paths, - Snippet, - snippets, - utils - } = part.shorthand(); + let { Point, points, Path, paths, Snippet, snippets, utils } = part.shorthand() - points.A = new Point(10, 10); - points.B = new Point(50, 40); - points.C = new Point(15, 30); - points.D = new Point(60, 15); + points.A = new Point(10, 10) + points.B = new Point(50, 40) + points.C = new Point(15, 30) + points.D = new Point(60, 15) - paths.AB = new Path().move(points.A).line(points.B); - paths.CD = new Path().move(points.C).line(points.D); + paths.AB = new Path().move(points.A).line(points.B) + paths.CD = new Path().move(points.C).line(points.D) - snippets.X = new Snippet( - "notch", - utils.linesIntersect(points.A, points.B, points.C, points.D) - ); + snippets.X = new Snippet('notch', utils.linesIntersect(points.A, points.B, points.C, points.D)) - return part; -}; + return part +} diff --git a/packages/examples/src/utils_pointonbeam.js b/packages/examples/src/utils_pointonbeam.js index c2d86ff872b..742a710b351 100644 --- a/packages/examples/src/utils_pointonbeam.js +++ b/packages/examples/src/utils_pointonbeam.js @@ -1,53 +1,45 @@ export default part => { - let { - Point, - points, - Path, - paths, - Snippet, - snippets, - utils - } = part.shorthand(); + let { Point, points, Path, paths, Snippet, snippets, utils } = part.shorthand() - points.from1 = new Point(10, 10); - points.to1 = new Point(90, 60); - points.from2 = new Point(10, 30); - points.to2 = new Point(90, 80); - points.b1 = new Point(170, 110); - points.b2 = new Point(170, 130); + points.from1 = new Point(10, 10) + points.to1 = new Point(90, 60) + points.from2 = new Point(10, 30) + points.to2 = new Point(90, 80) + points.b1 = new Point(170, 110) + points.b2 = new Point(170, 130) - let scatter = []; + let scatter = [] for (let i = 1; i < 36; i++) { for (let j = 1; j < 27; j++) { - scatter.push(new Point(i * 10, j * 10)); + scatter.push(new Point(i * 10, j * 10)) } } - let snippet; + let snippet for (let point of scatter) { - if (utils.pointOnBeam(points.from1, points.to1, point)) snippet = "notch"; - else snippet = "bnotch"; - snippets[part.getId()] = new Snippet(snippet, point); + if (utils.pointOnBeam(points.from1, points.to1, point)) snippet = 'notch' + else snippet = 'bnotch' + snippets[part.getId()] = new Snippet(snippet, point) if (utils.pointOnBeam(points.from2, points.to2, point, 0.01)) { - snippet = "notch"; - } else snippet = "bnotch"; - snippets[part.getId()] = new Snippet(snippet, point); + snippet = 'notch' + } else snippet = 'bnotch' + snippets[part.getId()] = new Snippet(snippet, point) } paths.line1 = new Path() .move(points.from1) .line(points.to1) - .attr("class", "fabric stroke-lg"); + .attr('class', 'fabric stroke-lg') paths.lne1 = new Path() .move(points.to1) .line(points.b1) - .attr("class", "fabric dashed"); + .attr('class', 'fabric dashed') paths.line2 = new Path() .move(points.from2) .line(points.to2) - .attr("class", "fabric stroke-lg"); + .attr('class', 'fabric stroke-lg') paths.lne2 = new Path() .move(points.to2) .line(points.b2) - .attr("class", "fabric dashed"); + .attr('class', 'fabric dashed') - return part; -}; + return part +} diff --git a/packages/examples/src/utils_pointoncurve.js b/packages/examples/src/utils_pointoncurve.js index a8afaf31fbf..89df06ddc34 100644 --- a/packages/examples/src/utils_pointoncurve.js +++ b/packages/examples/src/utils_pointoncurve.js @@ -1,44 +1,28 @@ export default part => { - let { - Point, - points, - Path, - paths, - Snippet, - snippets, - utils - } = part.shorthand(); + let { Point, points, Path, paths, Snippet, snippets, utils } = part.shorthand() - points.start = new Point(10, 10); - points.cp1 = new Point(90, 10); - points.cp2 = new Point(10, 60); - points.end = new Point(90, 60); + points.start = new Point(10, 10) + points.cp1 = new Point(90, 10) + points.cp2 = new Point(10, 60) + points.end = new Point(90, 60) - let scatter = []; + let scatter = [] for (let i = 1; i < 19; i++) { for (let j = 1; j < 14; j++) { - scatter.push(new Point(i * 10, j * 10)); + scatter.push(new Point(i * 10, j * 10)) } } - let snippet; + let snippet for (let point of scatter) { - if ( - utils.pointOnCurve( - points.start, - points.cp1, - points.cp2, - points.end, - point - ) - ) { - snippet = "notch"; - } else snippet = "bnotch"; - snippets[part.getId()] = new Snippet(snippet, point); + if (utils.pointOnCurve(points.start, points.cp1, points.cp2, points.end, point)) { + snippet = 'notch' + } else snippet = 'bnotch' + snippets[part.getId()] = new Snippet(snippet, point) } paths.curve = new Path() .move(points.start) .curve(points.cp1, points.cp2, points.end) - .attr("class", "fabric stroke-lg"); + .attr('class', 'fabric stroke-lg') - return part; -}; + return part +} diff --git a/packages/examples/src/utils_pointonline.js b/packages/examples/src/utils_pointonline.js index f24e7fc1178..93ade4efcaf 100644 --- a/packages/examples/src/utils_pointonline.js +++ b/packages/examples/src/utils_pointonline.js @@ -1,53 +1,45 @@ export default part => { - let { - Point, - points, - Path, - paths, - Snippet, - snippets, - utils - } = part.shorthand(); + let { Point, points, Path, paths, Snippet, snippets, utils } = part.shorthand() - points.from1 = new Point(10, 10); - points.to1 = new Point(90, 60); - points.from2 = new Point(10, 30); - points.to2 = new Point(90, 80); - points.b1 = new Point(170, 110); - points.b2 = new Point(170, 130); + points.from1 = new Point(10, 10) + points.to1 = new Point(90, 60) + points.from2 = new Point(10, 30) + points.to2 = new Point(90, 80) + points.b1 = new Point(170, 110) + points.b2 = new Point(170, 130) - let scatter = []; + let scatter = [] for (let i = 1; i < 36; i++) { for (let j = 1; j < 27; j++) { - scatter.push(new Point(i * 10, j * 10)); + scatter.push(new Point(i * 10, j * 10)) } } - let snippet; + let snippet for (let point of scatter) { - if (utils.pointOnLine(points.from1, points.to1, point)) snippet = "notch"; - else snippet = "bnotch"; - snippets[part.getId()] = new Snippet(snippet, point); + if (utils.pointOnLine(points.from1, points.to1, point)) snippet = 'notch' + else snippet = 'bnotch' + snippets[part.getId()] = new Snippet(snippet, point) if (utils.pointOnLine(points.from2, points.to2, point, 0.01)) { - snippet = "notch"; - } else snippet = "bnotch"; - snippets[part.getId()] = new Snippet(snippet, point); + snippet = 'notch' + } else snippet = 'bnotch' + snippets[part.getId()] = new Snippet(snippet, point) } paths.line1 = new Path() .move(points.from1) .line(points.to1) - .attr("class", "fabric stroke-lg"); + .attr('class', 'fabric stroke-lg') paths.lne1 = new Path() .move(points.to1) .line(points.b1) - .attr("class", "fabric dashed"); + .attr('class', 'fabric dashed') paths.line2 = new Path() .move(points.from2) .line(points.to2) - .attr("class", "fabric stroke-lg"); + .attr('class', 'fabric stroke-lg') paths.lne2 = new Path() .move(points.to2) .line(points.b2) - .attr("class", "fabric dashed"); + .attr('class', 'fabric dashed') - return part; -}; + return part +} diff --git a/packages/examples/src/utils_splitcurve.js b/packages/examples/src/utils_splitcurve.js index dfc0f6f4f39..baf539e0834 100644 --- a/packages/examples/src/utils_splitcurve.js +++ b/packages/examples/src/utils_splitcurve.js @@ -1,42 +1,30 @@ export default part => { - let { Point, points, Path, paths, utils } = part.shorthand(); + let { Point, points, Path, paths, utils } = part.shorthand() - points.from = new Point(40, 10); - points.to = new Point(40, 80); + points.from = new Point(40, 10) + points.to = new Point(40, 80) paths.line = new Path() .move(points.from) .line(points.to) - .attr("class", "lining dashed"); + .attr('class', 'lining dashed') - points.start = new Point(10, 15); - points.cp1 = new Point(80, 10); - points.cp2 = new Point(-50, 80); - points.end = new Point(110, 70); + points.start = new Point(10, 15) + points.cp1 = new Point(80, 10) + points.cp2 = new Point(-50, 80) + points.end = new Point(110, 70) - points.i40 = utils.curveIntersectsX( - points.start, - points.cp1, - points.cp2, - points.end, - 40 - ); + points.i40 = utils.curveIntersectsX(points.start, points.cp1, points.cp2, points.end, 40) - let parts = utils.splitCurve( - points.start, - points.cp1, - points.cp2, - points.end, - points.i40 - ); + let parts = utils.splitCurve(points.start, points.cp1, points.cp2, points.end, points.i40) - let colors = ["lining", "interfacing"]; + let colors = ['lining', 'interfacing'] for (let p of parts) { - let color = colors.pop(); + let color = colors.pop() paths[color] = new Path() .move(p.start) .curve(p.cp1, p.cp2, p.end) - .attr("class", "stroke-xl " + color); + .attr('class', 'stroke-xl ' + color) } - return part; -}; + return part +} diff --git a/packages/florent/example/src/App.js b/packages/florent/example/src/App.js index e7936330e5d..115cdf683af 100644 --- a/packages/florent/example/src/App.js +++ b/packages/florent/example/src/App.js @@ -1,22 +1,15 @@ -import React from "react"; -import freesewing from "@freesewing/core"; -import Workbench from "@freesewing/components/Workbench"; -import "typeface-roboto-condensed"; -import "@freesewing/css-theme"; +import React from 'react' +import freesewing from '@freesewing/core' +import Workbench from '@freesewing/components/Workbench' +import 'typeface-roboto-condensed' +import '@freesewing/css-theme' -import Pattern from "pattern"; +import Pattern from 'pattern' const App = props => { - let instance = new Pattern(); - let config = instance.config; - return ( - - ); -}; + let instance = new Pattern() + let config = instance.config + return +} -export default App; +export default App diff --git a/packages/florent/example/src/index.js b/packages/florent/example/src/index.js index 7900787a4d2..9dd7ba788d4 100644 --- a/packages/florent/example/src/index.js +++ b/packages/florent/example/src/index.js @@ -1,11 +1,11 @@ -import React from "react"; -import ReactDOM from "react-dom"; -import App from "./App"; -import * as serviceWorker from "./serviceWorker"; +import React from 'react' +import ReactDOM from 'react-dom' +import App from './App' +import * as serviceWorker from './serviceWorker' -ReactDOM.render(, document.getElementById("root")); +ReactDOM.render(, document.getElementById('root')) // If you want your app to work offline and load faster, you can change // unregister() to register() below. Note this comes with some pitfalls. // Learn more about service workers: http://bit.ly/CRA-PWA -serviceWorker.unregister(); +serviceWorker.unregister() diff --git a/packages/florent/example/src/serviceWorker.js b/packages/florent/example/src/serviceWorker.js index 68fda5a0eb6..44e1b1b2f8c 100644 --- a/packages/florent/example/src/serviceWorker.js +++ b/packages/florent/example/src/serviceWorker.js @@ -9,46 +9,44 @@ // This link also includes instructions on opting out of this behavior. const isLocalhost = Boolean( - window.location.hostname === "localhost" || + window.location.hostname === 'localhost' || // [::1] is the IPv6 localhost address. - window.location.hostname === "[::1]" || + window.location.hostname === '[::1]' || // 127.0.0.1/8 is considered localhost for IPv4. - window.location.hostname.match( - /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ - ) -); + window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/) +) export function register(config) { - if (process.env.NODE_ENV === "production" && "serviceWorker" in navigator) { + if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) { // The URL constructor is available in all browsers that support SW. - const publicUrl = new URL(process.env.PUBLIC_URL, window.location); + const publicUrl = new URL(process.env.PUBLIC_URL, window.location) if (publicUrl.origin !== window.location.origin) { // Our service worker won't work if PUBLIC_URL is on a different origin // from what our page is served on. This might happen if a CDN is used to // serve assets; see https://github.com/facebook/create-react-app/issues/2374 - return; + return } - window.addEventListener("load", () => { - const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; + window.addEventListener('load', () => { + const swUrl = `${process.env.PUBLIC_URL}/service-worker.js` if (isLocalhost) { // This is running on localhost. Let's check if a service worker still exists or not. - checkValidServiceWorker(swUrl, config); + checkValidServiceWorker(swUrl, config) // Add some additional logging to localhost, pointing developers to the // service worker/PWA documentation. navigator.serviceWorker.ready.then(() => { console.log( - "This web app is being served cache-first by a service " + - "worker. To learn more, visit https://goo.gl/SC7cgQ" - ); - }); + 'This web app is being served cache-first by a service ' + + 'worker. To learn more, visit https://goo.gl/SC7cgQ' + ) + }) } else { // Is not local host. Just register service worker - registerValidSW(swUrl, config); + registerValidSW(swUrl, config) } - }); + }) } } @@ -57,38 +55,38 @@ function registerValidSW(swUrl, config) { .register(swUrl) .then(registration => { registration.onupdatefound = () => { - const installingWorker = registration.installing; + const installingWorker = registration.installing installingWorker.onstatechange = () => { - if (installingWorker.state === "installed") { + if (installingWorker.state === 'installed') { if (navigator.serviceWorker.controller) { // At this point, the old content will have been purged and // the fresh content will have been added to the cache. // It's the perfect time to display a "New content is // available; please refresh." message in your web app. - console.log("New content is available; please refresh."); + console.log('New content is available; please refresh.') // Execute callback if (config.onUpdate) { - config.onUpdate(registration); + config.onUpdate(registration) } } else { // At this point, everything has been precached. // It's the perfect time to display a // "Content is cached for offline use." message. - console.log("Content is cached for offline use."); + console.log('Content is cached for offline use.') // Execute callback if (config.onSuccess) { - config.onSuccess(registration); + config.onSuccess(registration) } } } - }; - }; + } + } }) .catch(error => { - console.error("Error during service worker registration:", error); - }); + console.error('Error during service worker registration:', error) + }) } function checkValidServiceWorker(swUrl, config) { @@ -98,30 +96,28 @@ function checkValidServiceWorker(swUrl, config) { // Ensure service worker exists, and that we really are getting a JS file. if ( response.status === 404 || - response.headers.get("content-type").indexOf("javascript") === -1 + response.headers.get('content-type').indexOf('javascript') === -1 ) { // No service worker found. Probably a different app. Reload the page. navigator.serviceWorker.ready.then(registration => { registration.unregister().then(() => { - window.location.reload(); - }); - }); + window.location.reload() + }) + }) } else { // Service worker found. Proceed as normal. - registerValidSW(swUrl, config); + registerValidSW(swUrl, config) } }) .catch(() => { - console.log( - "No internet connection found. App is running in offline mode." - ); - }); + console.log('No internet connection found. App is running in offline mode.') + }) } export function unregister() { - if ("serviceWorker" in navigator) { + if ('serviceWorker' in navigator) { navigator.serviceWorker.ready.then(registration => { - registration.unregister(); - }); + registration.unregister() + }) } } diff --git a/packages/florent/src/brimbottom.js b/packages/florent/src/brimbottom.js index bc3b784e651..4612c1bc81a 100644 --- a/packages/florent/src/brimbottom.js +++ b/packages/florent/src/brimbottom.js @@ -11,31 +11,31 @@ export default function(part) { paths, Path, measurements - } = part.shorthand(); + } = part.shorthand() - let scale = 1; - let base = scale * measurements.headCircumference * (1 + options.headEase); + let scale = 1 + let base = scale * measurements.headCircumference * (1 + options.headEase) - points.tipRight = new Point(base * 0.147, 0); - points.tipLeft = points.tipRight.flipX(); - points.tipRightCp2 = points.tipRight.shift(-115, base * 0.051); - points.tipLeftCp1 = points.tipRightCp2.flipX(); - points.tipRightCp1 = points.tipRight.shift(-75, base * 0.195); - points.tipLeftCp2 = points.tipRightCp1.flipX(); - points.innerMid = new Point(0, base * 0.13); - points.outerMid = new Point(0, base * 0.226); - points.innerMidCp2 = points.innerMid.shift(180, base * 0.13); - points.innerMidCp1 = points.innerMidCp2.flipX(); - points.outerMidCp1 = points.outerMid.shift(180, base * 0.066); - points.outerMidCp2 = points.outerMidCp1.flipX(); + points.tipRight = new Point(base * 0.147, 0) + points.tipLeft = points.tipRight.flipX() + points.tipRightCp2 = points.tipRight.shift(-115, base * 0.051) + points.tipLeftCp1 = points.tipRightCp2.flipX() + points.tipRightCp1 = points.tipRight.shift(-75, base * 0.195) + points.tipLeftCp2 = points.tipRightCp1.flipX() + points.innerMid = new Point(0, base * 0.13) + points.outerMid = new Point(0, base * 0.226) + points.innerMidCp2 = points.innerMid.shift(180, base * 0.13) + points.innerMidCp1 = points.innerMidCp2.flipX() + points.outerMidCp1 = points.outerMid.shift(180, base * 0.066) + points.outerMidCp2 = points.outerMidCp1.flipX() store.set( - "brimInnerLength", + 'brimInnerLength', new Path() .move(points.tipRight) .curve(points.tipRightCp2, points.innerMidCp1, points.innerMid) .length() * 2 - ); + ) paths.seam = new Path() .move(points.tipLeft) @@ -45,48 +45,45 @@ export default function(part) { .curve(points.innerMidCp2, points.tipLeftCp1, points.tipLeft) .line(points.tipLeft) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') if (complete) { - points.title = points.innerMid.shiftFractionTowards( - points.outerMidCp2, - 0.35 - ); - macro("title", { + points.title = points.innerMid.shiftFractionTowards(points.outerMidCp2, 0.35) + macro('title', { at: points.title, nr: 3, - title: "brimBottom" - }); - macro("grainline", { + title: 'brimBottom' + }) + macro('grainline', { from: points.outerMid, to: points.innerMid - }); + }) - if (sa) paths.sa = paths.seam.offset(sa).attr("class", "fabric sa"); + if (sa) paths.sa = paths.seam.offset(sa).attr('class', 'fabric sa') if (paperless) { - macro("hd", { + macro('hd', { from: points.tipLeft, to: points.tipRight, y: points.tipLeft.y - sa - 15 - }); - macro("hd", { - from: paths.seam.edge("left"), - to: paths.seam.edge("right"), + }) + macro('hd', { + from: paths.seam.edge('left'), + to: paths.seam.edge('right'), y: points.tipLeft.y - sa - 30 - }); - macro("vd", { + }) + macro('vd', { from: points.outerMid, to: points.innerMid, x: points.innerMid.x - 15 - }); - macro("vd", { + }) + macro('vd', { from: points.outerMid, to: points.tipRight, x: points.tipRight.x + sa + 18 - }); + }) } } - return part; + return part } diff --git a/packages/florent/src/briminterfacing.js b/packages/florent/src/briminterfacing.js index 7e7f55c57a5..80cf3c5a0d8 100644 --- a/packages/florent/src/briminterfacing.js +++ b/packages/florent/src/briminterfacing.js @@ -1,99 +1,88 @@ export default function(part) { - let { - paperless, - sa, - complete, - points, - macro, - paths, - Path - } = part.shorthand(); + let { paperless, sa, complete, points, macro, paths, Path } = part.shorthand() - paths.hint = paths.seam.clone().attr("class", "dashed stroke-sm"); + paths.hint = paths.seam.clone().attr('class', 'dashed stroke-sm') paths.outset = new Path() .move(points.tipLeft) .curve(points.tipLeftCp2, points.outerMidCp1, points.outerMid) .curve(points.outerMidCp2, points.tipRightCp1, points.tipRight) - .attr("class", "lining"); + .attr('class', 'lining') //.offset(1.5) - points.outsetStart = paths.outset.shiftAlong(5); - points.outsetEnd = paths.outset.reverse().shiftAlong(5); + points.outsetStart = paths.outset.shiftAlong(5) + points.outsetEnd = paths.outset.reverse().shiftAlong(5) paths.outset = paths.outset .split(points.outsetStart) .pop() .split(points.outsetEnd) - .shift(); + .shift() // We check for sa here because it's a good way to sidestep issue #19 - if (sa) paths.outset = paths.outset.offset(1.5); + if (sa) paths.outset = paths.outset.offset(1.5) paths.inset = new Path() .move(points.tipLeft) .curve(points.tipLeftCp1, points.innerMidCp2, points.innerMid) .curve(points.innerMidCp1, points.tipRightCp2, points.tipRight) - .attr("class", "various"); + .attr('class', 'various') //.offset(1.5) - points.insetStart = paths.inset.shiftAlong(5); - points.insetEnd = paths.inset.reverse().shiftAlong(5); + points.insetStart = paths.inset.shiftAlong(5) + points.insetEnd = paths.inset.reverse().shiftAlong(5) paths.inset = paths.inset .split(points.insetStart) .pop() .split(points.insetEnd) - .shift(); + .shift() // We check for sa here because it's a good way to sidestep issue #19 - if (sa) paths.inset = paths.inset.offset(1.5); - paths.inset.render = false; - paths.outset.render = false; + if (sa) paths.inset = paths.inset.offset(1.5) + paths.inset.render = false + paths.outset.render = false - paths.hint = paths.seam.clone().attr("class", "dashed stroke-sm"); + paths.hint = paths.seam.clone().attr('class', 'dashed stroke-sm') paths.seam = paths.outset .clone() .line(paths.inset.end()) .join(paths.inset.reverse()) .line(paths.outset.start()) .close() - .attr("class", "interfacing"); + .attr('class', 'interfacing') // Clean up for (let i of Object.keys(paths)) { - if (["seam", "inset", "outset"].indexOf(i) === -1) delete paths[i]; + if (['seam', 'inset', 'outset'].indexOf(i) === -1) delete paths[i] } if (complete) { - points.title = points.innerMid.shiftFractionTowards( - points.outerMidCp2, - 0.35 - ); - macro("title", { + points.title = points.innerMid.shiftFractionTowards(points.outerMidCp2, 0.35) + macro('title', { at: points.title, nr: 5, - title: "brimInterfacing" - }); - macro("grainline", { + title: 'brimInterfacing' + }) + macro('grainline', { from: points.outerMid, to: points.innerMid - }); + }) - if (sa) paths.sa = paths.seam.offset(sa).attr("class", "fabric sa"); + if (sa) paths.sa = paths.seam.offset(sa).attr('class', 'fabric sa') if (paperless) { - macro("hd", { - from: paths.seam.edge("left"), - to: paths.seam.edge("right"), + macro('hd', { + from: paths.seam.edge('left'), + to: paths.seam.edge('right'), y: points.tipLeft.y - sa - 15 - }); - macro("vd", { - from: paths.outset.edge("bottom"), - to: paths.inset.edge("bottom"), + }) + macro('vd', { + from: paths.outset.edge('bottom'), + to: paths.inset.edge('bottom'), x: points.innerMid.x - 15 - }); - macro("vd", { - from: paths.outset.edge("bottom"), - to: paths.inset.edge("topRight"), + }) + macro('vd', { + from: paths.outset.edge('bottom'), + to: paths.inset.edge('topRight'), x: points.tipRight.x + sa + 18 - }); + }) } } - return part; + return part } diff --git a/packages/florent/src/brimtop.js b/packages/florent/src/brimtop.js index 13047c97d4d..af7caea611b 100644 --- a/packages/florent/src/brimtop.js +++ b/packages/florent/src/brimtop.js @@ -1,66 +1,55 @@ export default function(part) { - let { - paperless, - sa, - complete, - points, - macro, - paths, - Path - } = part.shorthand(); + let { paperless, sa, complete, points, macro, paths, Path } = part.shorthand() paths.hint = new Path() .move(points.tipLeft) .curve(points.tipLeftCp2, points.outerMidCp1, points.outerMid) .curve(points.outerMidCp2, points.tipRightCp1, points.tipRight) - .attr("class", "dashed stroke-sm"); + .attr('class', 'dashed stroke-sm') // We check for sa here because it's a good way to sidestep issue #19 - if (sa) paths.seam = paths.hint.offset(3); + if (sa) paths.seam = paths.hint.offset(3) paths.seam = paths.seam .line(points.tipRight) .curve(points.tipRightCp2, points.innerMidCp1, points.innerMid) .curve(points.innerMidCp2, points.tipLeftCp1, points.tipLeft) .line(paths.seam.start()) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') if (complete) { - points.title = points.innerMid.shiftFractionTowards( - points.outerMidCp2, - 0.35 - ); - macro("title", { + points.title = points.innerMid.shiftFractionTowards(points.outerMidCp2, 0.35) + macro('title', { at: points.title, nr: 4, - title: "brimTop" - }); - macro("grainline", { + title: 'brimTop' + }) + macro('grainline', { from: points.outerMid, to: points.innerMid - }); + }) - if (sa) paths.sa = paths.seam.offset(sa).attr("class", "fabric sa"); + if (sa) paths.sa = paths.seam.offset(sa).attr('class', 'fabric sa') if (paperless) { - let bottom = paths.seam.edge("bottom"); - macro("hd", { - from: paths.seam.edge("left"), - to: paths.seam.edge("right"), + let bottom = paths.seam.edge('bottom') + macro('hd', { + from: paths.seam.edge('left'), + to: paths.seam.edge('right'), y: points.tipLeft.y - sa - 15 - }); - macro("vd", { + }) + macro('vd', { from: bottom, to: points.innerMid, x: points.innerMid.x - 15 - }); - macro("vd", { + }) + macro('vd', { from: bottom, to: points.tipRight, x: points.tipRight.x + sa + 18 - }); + }) } } - return part; + return part } diff --git a/packages/florent/src/index.js b/packages/florent/src/index.js index 3f50cb95ac1..65a85e5bcfb 100644 --- a/packages/florent/src/index.js +++ b/packages/florent/src/index.js @@ -1,21 +1,21 @@ -import freesewing from "@freesewing/core"; -import plugins from "@freesewing/plugin-bundle"; -import config from "../config"; +import freesewing from '@freesewing/core' +import plugins from '@freesewing/plugin-bundle' +import config from '../config' // Parts -import draftTop from "./top"; -import draftSide from "./side"; -import draftBrimBottom from "./brimbottom"; -import draftBrimTop from "./brimtop"; -import draftBrimInterfacing from "./briminterfacing"; +import draftTop from './top' +import draftSide from './side' +import draftBrimBottom from './brimbottom' +import draftBrimTop from './brimtop' +import draftBrimInterfacing from './briminterfacing' // Create new design -const Pattern = new freesewing.Design(config, plugins); +const Pattern = new freesewing.Design(config, plugins) // Attachdraft methods to prototype -Pattern.prototype.draftTop = draftTop; -Pattern.prototype.draftSide = draftSide; -Pattern.prototype.draftBrimBottom = draftBrimBottom; -Pattern.prototype.draftBrimTop = draftBrimTop; -Pattern.prototype.draftBrimInterfacing = draftBrimInterfacing; +Pattern.prototype.draftTop = draftTop +Pattern.prototype.draftSide = draftSide +Pattern.prototype.draftBrimBottom = draftBrimBottom +Pattern.prototype.draftBrimTop = draftBrimTop +Pattern.prototype.draftBrimInterfacing = draftBrimInterfacing -export default Pattern; +export default Pattern diff --git a/packages/florent/src/side.js b/packages/florent/src/side.js index 9656f4b130e..2d17feee45f 100644 --- a/packages/florent/src/side.js +++ b/packages/florent/src/side.js @@ -1,45 +1,32 @@ export default function(part) { - let { - paperless, - sa, - complete, - points, - macro, - paths, - Path, - snippets, - Snippet - } = part.shorthand(); + let { paperless, sa, complete, points, macro, paths, Path, snippets, Snippet } = part.shorthand() // Clean up for (let i of Object.keys(paths)) { - if (i !== "side") delete paths[i]; + if (i !== 'side') delete paths[i] } paths.seam = paths.side .clone() .line(points.foldTop) - .attr("class", "fabric"); - paths.seam.render = true; + .attr('class', 'fabric') + paths.seam.render = true if (complete) { - points.title = points.innerGuide.shiftFractionTowards( - points.outerGuide, - 0.5 - ); - macro("title", { + points.title = points.innerGuide.shiftFractionTowards(points.outerGuide, 0.5) + macro('title', { at: points.title, nr: 2, - title: "side" - }); - points.logo = points.tipCp2.shiftFractionTowards(points.outerTopCp1, 0.5); - snippets.logo = new Snippet("logo", points.logo).attr("data-scale", 0.75); - macro("cutonfold", { + title: 'side' + }) + points.logo = points.tipCp2.shiftFractionTowards(points.outerTopCp1, 0.5) + snippets.logo = new Snippet('logo', points.logo).attr('data-scale', 0.75) + macro('cutonfold', { from: points.foldBottom, to: points.foldTop, offset: 15, grainline: true - }); + }) if (sa) { paths.sa = new Path() @@ -47,37 +34,37 @@ export default function(part) { .line(points.foldTop.shift(180, sa)) .join(paths.side.offset(sa)) .line(points.foldBottom) - .attr("class", "fabric sa"); + .attr('class', 'fabric sa') } if (paperless) { - macro("vd", { + macro('vd', { from: points.tip, to: points.foldBottom, x: points.tip.x + sa + 15 - }); - macro("vd", { + }) + macro('vd', { from: points.outerTop, to: points.foldBottom, x: points.tip.x + sa + 30 - }); - macro("hd", { + }) + macro('hd', { from: points.foldTop, to: points.foldBottom, y: points.foldTop.y - 15 - }); - macro("hd", { + }) + macro('hd', { from: points.foldTop, to: points.outerTop, y: points.outerTop.y + sa + 15 - }); - macro("hd", { + }) + macro('hd', { from: points.foldTop, to: points.tip, y: points.outerTop.y + sa + 30 - }); + }) } } - return part; + return part } diff --git a/packages/florent/src/top.js b/packages/florent/src/top.js index 1bb5a63daba..780066b2bd0 100644 --- a/packages/florent/src/top.js +++ b/packages/florent/src/top.js @@ -10,66 +10,63 @@ export default function(part) { snippets, Snippet, complete - } = part.shorthand(); + } = part.shorthand() const fitCap = (part, scale) => { - let { points, options, Point, Path, measurements } = part.shorthand(); + let { points, options, Point, Path, measurements } = part.shorthand() - let base = scale * measurements.headCircumference * (1 + options.headEase); + let base = scale * measurements.headCircumference * (1 + options.headEase) // Top - points.midFront = new Point(0, 0); - points.midFrontCp2 = points.midFront.shift(-90, base * 0.074); - points.midMid = points.midFront.shift(0, base * 0.34); - points.midBack = new Point(base * 0.654, base * 0.124); - points.midSide = new Point(base * 0.2525, base * 0.178); - points.midSideCp1 = points.midSide.shift(180, base * 0.185); - points.midSideCp2 = points.midSide.shift(0, base * 0.101); - points.backHollow = new Point(base * 0.488, base * 0.136); - points.backHollowCp1 = points.backHollow.shift(180, base * 0.033); - points.backHollowCp2 = points.backHollow.shift(0, base * 0.033); - points.backEdge = new Point(base * 0.576, base * 0.185); - let angle = points.backEdge.angle(points.midBack) + 90; - points.backSide = points.backEdge.shift(angle, base * 0.025); - points.backSideCp1 = points.backSide.shift(angle, base * 0.02); - points.midMidCp1 = points.midMid.shift(0, base * 0.1); - points.midBackCp2 = points.midBack.shift(angle, base * 0.09); + points.midFront = new Point(0, 0) + points.midFrontCp2 = points.midFront.shift(-90, base * 0.074) + points.midMid = points.midFront.shift(0, base * 0.34) + points.midBack = new Point(base * 0.654, base * 0.124) + points.midSide = new Point(base * 0.2525, base * 0.178) + points.midSideCp1 = points.midSide.shift(180, base * 0.185) + points.midSideCp2 = points.midSide.shift(0, base * 0.101) + points.backHollow = new Point(base * 0.488, base * 0.136) + points.backHollowCp1 = points.backHollow.shift(180, base * 0.033) + points.backHollowCp2 = points.backHollow.shift(0, base * 0.033) + points.backEdge = new Point(base * 0.576, base * 0.185) + let angle = points.backEdge.angle(points.midBack) + 90 + points.backSide = points.backEdge.shift(angle, base * 0.025) + points.backSideCp1 = points.backSide.shift(angle, base * 0.02) + points.midMidCp1 = points.midMid.shift(0, base * 0.1) + points.midBackCp2 = points.midBack.shift(angle, base * 0.09) // Side - points.foldTop = new Point(0, 0); - points.foldTopCp1 = points.foldTop.shift(-90, base * 0.0433); - points.foldBottom = points.foldTop.shift(0, base * 0.126); - points.foldBottomCp2 = points.foldBottom.shift(-90, base * 0.0866); - points.tip = new Point(base * 0.411, base * 0.207); - points.tipCp1 = points.tip.shift(-85, base * 0.1); - points.tipCp2 = points.tip.shift(177, base * 0.067); - points.outerTop = new Point(base * 0.328, base * 0.337); - points.outerTopCp1 = points.outerTop.shift(180, base * 0.05); - points.outerTopCp2 = points.outerTop.shift(0, base * 0.05); - points.outerGuide = new Point(base * 0.0867, base * 0.1913); - points.outerGuideCp1 = points.outerGuide.shift(135, base * 0.076); - points.outerGuideCp2 = points.outerGuide.shift(-45, base * 0.145); - points.innerGuide = new Point(base * 0.22, base * 0.172); - points.innerGuideCp1 = points.innerGuide.shift(-38, base * 0.052); - points.innerGuideCp2 = points.innerGuide.shift(142, base * 0.035); + points.foldTop = new Point(0, 0) + points.foldTopCp1 = points.foldTop.shift(-90, base * 0.0433) + points.foldBottom = points.foldTop.shift(0, base * 0.126) + points.foldBottomCp2 = points.foldBottom.shift(-90, base * 0.0866) + points.tip = new Point(base * 0.411, base * 0.207) + points.tipCp1 = points.tip.shift(-85, base * 0.1) + points.tipCp2 = points.tip.shift(177, base * 0.067) + points.outerTop = new Point(base * 0.328, base * 0.337) + points.outerTopCp1 = points.outerTop.shift(180, base * 0.05) + points.outerTopCp2 = points.outerTop.shift(0, base * 0.05) + points.outerGuide = new Point(base * 0.0867, base * 0.1913) + points.outerGuideCp1 = points.outerGuide.shift(135, base * 0.076) + points.outerGuideCp2 = points.outerGuide.shift(-45, base * 0.145) + points.innerGuide = new Point(base * 0.22, base * 0.172) + points.innerGuideCp1 = points.innerGuide.shift(-38, base * 0.052) + points.innerGuideCp2 = points.innerGuide.shift(142, base * 0.035) - let backLength = points.backEdge.dist(points.midBack) * 2; + let backLength = points.backEdge.dist(points.midBack) * 2 let sideLength = new Path() .move(points.tip) .curve(points.tipCp2, points.innerGuideCp1, points.innerGuide) .curve(points.innerGuideCp2, points.foldBottomCp2, points.foldBottom) - .length() * 2; + .length() * 2 // Return delta between target and actual seam length - return ( - measurements.headCircumference * (1 + options.headEase) - - (backLength + sideLength) - ); - }; + return measurements.headCircumference * (1 + options.headEase) - (backLength + sideLength) + } const sideSeamDelta = part => { - let { Path } = part.shorthand(); + let { Path } = part.shorthand() let top = new Path() .move(points.midFront) @@ -77,40 +74,40 @@ export default function(part) { .curve(points.midSideCp2, points.backHollowCp1, points.backHollow) .curve(points.backHollowCp2, points.backSideCp1, points.backSide) .line(points.backEdge) - .length(); + .length() let side = new Path() .move(points.foldTop) .curve(points.foldTopCp1, points.outerGuideCp1, points.outerGuide) .curve(points.outerGuideCp2, points.outerTopCp1, points.outerTop) .curve(points.outerTopCp2, points.tipCp1, points.tip) - .length(); + .length() - return top - side; - }; + return top - side + } // Fit head - let scale = 1; - let count = 1; - let delta = fitCap(part, scale); + let scale = 1 + let count = 1 + let delta = fitCap(part, scale) while (Math.abs(delta) > 1 && count < 25) { - count++; - if (delta > 0) scale = 1000 / (1000 - delta); + count++ + if (delta > 0) scale = 1000 / (1000 - delta) // Too small - else scale = 1000 / (1000 + delta); // Too large - delta = fitCap(part, scale); + else scale = 1000 / (1000 + delta) // Too large + delta = fitCap(part, scale) } // Match side seam - delta = sideSeamDelta(part); - count = 1; - let top = ["outerTop", "outerTopCp1", "outerTopCp2"]; - let guide = ["outerGuide", "outerGuideCp1", "outerGuideCp2"]; + delta = sideSeamDelta(part) + count = 1 + let top = ['outerTop', 'outerTopCp1', 'outerTopCp2'] + let guide = ['outerGuide', 'outerGuideCp1', 'outerGuideCp2'] while (Math.abs(delta) > 1 && count < 25) { - for (let i of top) points[i] = points[i].shift(-90, delta / 3); - for (let i of guide) points[i] = points[i].shift(-135, delta / 3); - delta = sideSeamDelta(part); - count++; + for (let i of top) points[i] = points[i].shift(-90, delta / 3) + for (let i of guide) points[i] = points[i].shift(-135, delta / 3) + delta = sideSeamDelta(part) + count++ } // Paths @@ -124,7 +121,7 @@ export default function(part) { .line(points.midBack) .curve(points.midBackCp2, points.midMidCp1, points.midMid) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') paths.side = new Path() .move(points.foldTop) @@ -133,72 +130,72 @@ export default function(part) { .curve(points.outerTopCp2, points.tipCp1, points.tip) .curve(points.tipCp2, points.innerGuideCp1, points.innerGuide) .curve(points.innerGuideCp2, points.foldBottomCp2, points.foldBottom) - .attr("class", "fabric"); + .attr('class', 'fabric') // Uncomment to see the side part here - paths.side.render = false; + paths.side.render = false if (complete) { - points.title = new Point(points.midMid.x, points.midFrontCp2.y); - macro("title", { + points.title = new Point(points.midMid.x, points.midFrontCp2.y) + macro('title', { at: points.title, nr: 1, - title: "top" - }); - points.logo = new Point(points.title.x / 2, points.title.y); - snippets.logo = new Snippet("logo", points.logo).attr("data-scale", 0.75); - points.grainlineFrom = new Point(points.midSideCp1.x, points.midBack.y); - points.grainlineTo = points.midBack.clone(); - macro("grainline", { + title: 'top' + }) + points.logo = new Point(points.title.x / 2, points.title.y) + snippets.logo = new Snippet('logo', points.logo).attr('data-scale', 0.75) + points.grainlineFrom = new Point(points.midSideCp1.x, points.midBack.y) + points.grainlineTo = points.midBack.clone() + macro('grainline', { from: points.grainlineFrom, to: points.grainlineTo - }); + }) - if (sa) paths.sa = paths.seam.offset(sa).attr("class", "fabric sa"); + if (sa) paths.sa = paths.seam.offset(sa).attr('class', 'fabric sa') if (paperless) { - macro("vd", { + macro('vd', { from: points.midSide, to: points.foldTop, x: points.foldTop.x - sa - 15 - }); - macro("vd", { + }) + macro('vd', { from: points.backHollow, to: points.midMid, x: points.midMid.x - 15 - }); - macro("vd", { + }) + macro('vd', { from: points.midBack, to: points.midMid, x: points.midBack.x + sa + 15 - }); - macro("vd", { + }) + macro('vd', { from: points.backEdge, to: points.midMid, x: points.midBack.x + sa + 30 - }); - macro("hd", { + }) + macro('hd', { from: points.foldTop, to: points.midSide, y: points.midSide.y + sa + 15 - }); - macro("hd", { + }) + macro('hd', { from: points.foldTop, to: points.backHollow, y: points.midSide.y + sa + 30 - }); - macro("hd", { + }) + macro('hd', { from: points.foldTop, to: points.backEdge, y: points.midSide.y + sa + 45 - }); - macro("hd", { + }) + macro('hd', { from: points.foldTop, to: points.midBack, y: points.midSide.y + sa + 60 - }); + }) } } - return part; + return part } diff --git a/packages/huey/example/src/App.js b/packages/huey/example/src/App.js index e7936330e5d..115cdf683af 100644 --- a/packages/huey/example/src/App.js +++ b/packages/huey/example/src/App.js @@ -1,22 +1,15 @@ -import React from "react"; -import freesewing from "@freesewing/core"; -import Workbench from "@freesewing/components/Workbench"; -import "typeface-roboto-condensed"; -import "@freesewing/css-theme"; +import React from 'react' +import freesewing from '@freesewing/core' +import Workbench from '@freesewing/components/Workbench' +import 'typeface-roboto-condensed' +import '@freesewing/css-theme' -import Pattern from "pattern"; +import Pattern from 'pattern' const App = props => { - let instance = new Pattern(); - let config = instance.config; - return ( - - ); -}; + let instance = new Pattern() + let config = instance.config + return +} -export default App; +export default App diff --git a/packages/huey/example/src/index.js b/packages/huey/example/src/index.js index 7900787a4d2..9dd7ba788d4 100644 --- a/packages/huey/example/src/index.js +++ b/packages/huey/example/src/index.js @@ -1,11 +1,11 @@ -import React from "react"; -import ReactDOM from "react-dom"; -import App from "./App"; -import * as serviceWorker from "./serviceWorker"; +import React from 'react' +import ReactDOM from 'react-dom' +import App from './App' +import * as serviceWorker from './serviceWorker' -ReactDOM.render(, document.getElementById("root")); +ReactDOM.render(, document.getElementById('root')) // If you want your app to work offline and load faster, you can change // unregister() to register() below. Note this comes with some pitfalls. // Learn more about service workers: http://bit.ly/CRA-PWA -serviceWorker.unregister(); +serviceWorker.unregister() diff --git a/packages/huey/example/src/serviceWorker.js b/packages/huey/example/src/serviceWorker.js index 68fda5a0eb6..44e1b1b2f8c 100644 --- a/packages/huey/example/src/serviceWorker.js +++ b/packages/huey/example/src/serviceWorker.js @@ -9,46 +9,44 @@ // This link also includes instructions on opting out of this behavior. const isLocalhost = Boolean( - window.location.hostname === "localhost" || + window.location.hostname === 'localhost' || // [::1] is the IPv6 localhost address. - window.location.hostname === "[::1]" || + window.location.hostname === '[::1]' || // 127.0.0.1/8 is considered localhost for IPv4. - window.location.hostname.match( - /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ - ) -); + window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/) +) export function register(config) { - if (process.env.NODE_ENV === "production" && "serviceWorker" in navigator) { + if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) { // The URL constructor is available in all browsers that support SW. - const publicUrl = new URL(process.env.PUBLIC_URL, window.location); + const publicUrl = new URL(process.env.PUBLIC_URL, window.location) if (publicUrl.origin !== window.location.origin) { // Our service worker won't work if PUBLIC_URL is on a different origin // from what our page is served on. This might happen if a CDN is used to // serve assets; see https://github.com/facebook/create-react-app/issues/2374 - return; + return } - window.addEventListener("load", () => { - const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; + window.addEventListener('load', () => { + const swUrl = `${process.env.PUBLIC_URL}/service-worker.js` if (isLocalhost) { // This is running on localhost. Let's check if a service worker still exists or not. - checkValidServiceWorker(swUrl, config); + checkValidServiceWorker(swUrl, config) // Add some additional logging to localhost, pointing developers to the // service worker/PWA documentation. navigator.serviceWorker.ready.then(() => { console.log( - "This web app is being served cache-first by a service " + - "worker. To learn more, visit https://goo.gl/SC7cgQ" - ); - }); + 'This web app is being served cache-first by a service ' + + 'worker. To learn more, visit https://goo.gl/SC7cgQ' + ) + }) } else { // Is not local host. Just register service worker - registerValidSW(swUrl, config); + registerValidSW(swUrl, config) } - }); + }) } } @@ -57,38 +55,38 @@ function registerValidSW(swUrl, config) { .register(swUrl) .then(registration => { registration.onupdatefound = () => { - const installingWorker = registration.installing; + const installingWorker = registration.installing installingWorker.onstatechange = () => { - if (installingWorker.state === "installed") { + if (installingWorker.state === 'installed') { if (navigator.serviceWorker.controller) { // At this point, the old content will have been purged and // the fresh content will have been added to the cache. // It's the perfect time to display a "New content is // available; please refresh." message in your web app. - console.log("New content is available; please refresh."); + console.log('New content is available; please refresh.') // Execute callback if (config.onUpdate) { - config.onUpdate(registration); + config.onUpdate(registration) } } else { // At this point, everything has been precached. // It's the perfect time to display a // "Content is cached for offline use." message. - console.log("Content is cached for offline use."); + console.log('Content is cached for offline use.') // Execute callback if (config.onSuccess) { - config.onSuccess(registration); + config.onSuccess(registration) } } } - }; - }; + } + } }) .catch(error => { - console.error("Error during service worker registration:", error); - }); + console.error('Error during service worker registration:', error) + }) } function checkValidServiceWorker(swUrl, config) { @@ -98,30 +96,28 @@ function checkValidServiceWorker(swUrl, config) { // Ensure service worker exists, and that we really are getting a JS file. if ( response.status === 404 || - response.headers.get("content-type").indexOf("javascript") === -1 + response.headers.get('content-type').indexOf('javascript') === -1 ) { // No service worker found. Probably a different app. Reload the page. navigator.serviceWorker.ready.then(registration => { registration.unregister().then(() => { - window.location.reload(); - }); - }); + window.location.reload() + }) + }) } else { // Service worker found. Proceed as normal. - registerValidSW(swUrl, config); + registerValidSW(swUrl, config) } }) .catch(() => { - console.log( - "No internet connection found. App is running in offline mode." - ); - }); + console.log('No internet connection found. App is running in offline mode.') + }) } export function unregister() { - if ("serviceWorker" in navigator) { + if ('serviceWorker' in navigator) { navigator.serviceWorker.ready.then(registration => { - registration.unregister(); - }); + registration.unregister() + }) } } diff --git a/packages/huey/src/back.js b/packages/huey/src/back.js index 380da7f3aa2..87760d9c257 100644 --- a/packages/huey/src/back.js +++ b/packages/huey/src/back.js @@ -1,4 +1,4 @@ -import { sharedDimensions } from "./shared"; +import { sharedDimensions } from './shared' export default function(part) { let { @@ -12,33 +12,32 @@ export default function(part) { sa, options, measurements - } = part.shorthand(); + } = part.shorthand() // Clear paths from Brian - for (let p of Object.keys(paths)) delete paths[p]; + for (let p of Object.keys(paths)) delete paths[p] // Shorten body to take ribbing into account if (options.ribbing) { let rh = - options.ribbingHeight * - (measurements.centerBackNeckToWaist + measurements.naturalWaistToHip); - for (let p of ["hem", "cbHem"]) points[p] = points[p].shift(90, rh); - store.set("ribbingHeight", rh); + options.ribbingHeight * (measurements.centerBackNeckToWaist + measurements.naturalWaistToHip) + for (let p of ['hem', 'cbHem']) points[p] = points[p].shift(90, rh) + store.set('ribbingHeight', rh) } // Shape side seam - points.waist.x = (measurements.naturalWaist * (1 + options.waistEase)) / 4; - points.hips.x = (measurements.hipsCircumference * (1 + options.hipsEase)) / 4; - points.hem.x = points.hips.x; + points.waist.x = (measurements.naturalWaist * (1 + options.waistEase)) / 4 + points.hips.x = (measurements.hipsCircumference * (1 + options.hipsEase)) / 4 + points.hem.x = points.hips.x // Store length of the neck seam store.set( - "backNeckSeamLength", + 'backNeckSeamLength', new Path() .move(points.neck) .curve_(points.neckCp2, points.cbNeck) .length() - ); + ) // Paths paths.saBase = new Path() @@ -49,43 +48,41 @@ export default function(part) { .curve(points.armholePitchCp2, points.shoulderCp1, points.shoulder) .line(points.neck) .curve_(points.neckCp2, points.cbNeck) - .attr("class", "note stroke-xxl"); + .attr('class', 'note stroke-xxl') paths.hemBase = new Path() .move(points.cbHem) .line(points.hem) - .attr("class", "note stroke-xxl"); - paths.saBase.render = false; - paths.hemBase.render = false; + .attr('class', 'note stroke-xxl') + paths.saBase.render = false + paths.hemBase.render = false paths.seam = paths.saBase .clone() .line(points.cbHem) .join(paths.hemBase) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') // Complete? if (complete) { - macro("cutonfold", { + macro('cutonfold', { from: points.cbNeck, to: points.cbHem, grainline: true - }); + }) if (sa) { - paths.sa = paths.hemBase - .offset(options.ribbing ? sa : 3 * sa) - .join(paths.saBase.offset(sa)); + paths.sa = paths.hemBase.offset(options.ribbing ? sa : 3 * sa).join(paths.saBase.offset(sa)) paths.sa .move(paths.sa.end()) .line(points.cbNeck) .move(paths.sa.start()) .line(points.cbHem) - .attr("class", "fabric sa"); + .attr('class', 'fabric sa') } } // Paperless? - if (paperless) sharedDimensions(part, "back"); + if (paperless) sharedDimensions(part, 'back') - return part; + return part } diff --git a/packages/huey/src/cuff.js b/packages/huey/src/cuff.js index 61fcdd6f335..d4a3523b941 100644 --- a/packages/huey/src/cuff.js +++ b/packages/huey/src/cuff.js @@ -1,24 +1,22 @@ -import { draftRibbing } from "./shared"; +import { draftRibbing } from './shared' export default part => { - let { complete, points, measurements, options, macro } = part.shorthand(); - if (!options.ribbing) return part; + let { complete, points, measurements, options, macro } = part.shorthand() + if (!options.ribbing) return part draftRibbing( part, - measurements.wristCircumference * - (1 + options.cuffEase) * - (1 - options.ribbingStretch) - ); + measurements.wristCircumference * (1 + options.cuffEase) * (1 - options.ribbingStretch) + ) // Complete pattern? if (complete) { - macro("title", { + macro('title', { at: points.title, nr: 7, - title: "cuff" - }); + title: 'cuff' + }) } - return part; -}; + return part +} diff --git a/packages/huey/src/front.js b/packages/huey/src/front.js index 2585eab83de..ff5b81bf484 100644 --- a/packages/huey/src/front.js +++ b/packages/huey/src/front.js @@ -1,4 +1,4 @@ -import { sharedDimensions } from "./shared"; +import { sharedDimensions } from './shared' export default function(part) { let { @@ -13,54 +13,47 @@ export default function(part) { sa, options, measurements - } = part.shorthand(); + } = part.shorthand() // Clear paths from Brian - for (let p of Object.keys(paths)) delete paths[p]; + for (let p of Object.keys(paths)) delete paths[p] // Shorten body to take ribbing into account if (options.ribbing) { - for (let p of ["hem", "cfHem"]) - points[p] = points[p].shift(90, store.get("ribbingHeight")); + for (let p of ['hem', 'cfHem']) points[p] = points[p].shift(90, store.get('ribbingHeight')) } // Shape side seam - points.waist.x = (measurements.naturalWaist * (1 + options.waistEase)) / 4; - points.hips.x = (measurements.hipsCircumference * (1 + options.hipsEase)) / 4; - points.hem.x = points.hips.x; + points.waist.x = (measurements.naturalWaist * (1 + options.waistEase)) / 4 + points.hips.x = (measurements.hipsCircumference * (1 + options.hipsEase)) / 4 + points.hem.x = points.hips.x // Front pocket - points.pocketCfTop = points.cfNeck.shiftFractionTowards( - points.cfHem, - 1 - options.pocketHeight - ); - points.pocketTopRight = points.pocketCfTop.shift( - 0, - points.waist.x * options.pocketWidth - ); + points.pocketCfTop = points.cfNeck.shiftFractionTowards(points.cfHem, 1 - options.pocketHeight) + points.pocketTopRight = points.pocketCfTop.shift(0, points.waist.x * options.pocketWidth) points.pocketTip = new Point( points.pocketTopRight.x * 1.2, points.waist.y + points.waist.dy(points.hem) * 0.7 - ); + ) points.pocketHem = new Point( points.pocketTopRight.x + points.pocketTopRight.dx(points.pocketTip) / 2, points.hem.y - ); + ) points.pocketTipCp2 = utils.beamsIntersect( points.pocketTopRight, points.pocketTopRight.shift(90, 10), points.pocketTip, points.pocketHem.rotate(-90, points.pocketTip) - ); + ) // Store length of the neck seam store.set( - "frontNeckSeamLength", + 'frontNeckSeamLength', new Path() .move(points.neck) .curve(points.neckCp2Front, points.cfNeckCp1, points.cfNeck) .length() - ); + ) // Paths paths.saBase = new Path() @@ -71,20 +64,20 @@ export default function(part) { .curve(points.armholePitchCp2, points.shoulderCp1, points.shoulder) .line(points.neck) .curve(points.neckCp2, points.cfNeckCp1, points.cfNeck) - .attr("class", "note stroke-xxl"); + .attr('class', 'note stroke-xxl') paths.hemBase = new Path() .move(points.cfHem) .line(points.hem) - .attr("class", "note stroke-xxl"); - paths.saBase.render = false; - paths.hemBase.render = false; + .attr('class', 'note stroke-xxl') + paths.saBase.render = false + paths.hemBase.render = false paths.seam = paths.saBase .clone() .line(points.cfHem) .join(paths.hemBase) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') // Complete? if (complete) { @@ -94,24 +87,22 @@ export default function(part) { .line(points.pocketTip) .curve_(points.pocketTipCp2, points.pocketTopRight) .line(points.pocketCfTop) - .attr("class", "fabric dashed stroke-sm"); + .attr('class', 'fabric dashed stroke-sm') } if (sa) { - paths.sa = paths.hemBase - .offset(options.ribbing ? sa : 3 * sa) - .join(paths.saBase.offset(sa)); + paths.sa = paths.hemBase.offset(options.ribbing ? sa : 3 * sa).join(paths.saBase.offset(sa)) paths.sa .move(paths.sa.end()) .line(points.cfNeck) .move(paths.sa.start()) .line(points.cfHem) - .attr("class", "fabric sa"); + .attr('class', 'fabric sa') } } // Paperless? - if (paperless) sharedDimensions(part, "front"); + if (paperless) sharedDimensions(part, 'front') - return part; + return part } diff --git a/packages/huey/src/hood.js b/packages/huey/src/hood.js index db690b604c6..78b30bf30b3 100644 --- a/packages/huey/src/hood.js +++ b/packages/huey/src/hood.js @@ -13,35 +13,30 @@ export default function(part) { sa, options, measurements - } = part.shorthand(); + } = part.shorthand() - let base = store.get("frontNeckSeamLength") + store.get("backNeckSeamLength"); - points.cfBottom = new Point(0, 0); - points.cbBottom = points.cfBottom - .shift(0, base) - .rotate(options.hoodAngle, points.cfBottom); + let base = store.get('frontNeckSeamLength') + store.get('backNeckSeamLength') + points.cfBottom = new Point(0, 0) + points.cbBottom = points.cfBottom.shift(0, base).rotate(options.hoodAngle, points.cfBottom) points.cfHeightLeft = points.cfBottom.shift( 90, measurements.headCircumference * options.hoodHeight - ); - points.cfHeightRight = points.cfHeightLeft.shift(0, base); + ) + points.cfHeightRight = points.cfHeightLeft.shift(0, base) points.cfTop = points.cfBottom .shift(90, measurements.headCircumference * options.hoodClosure) - .rotate(options.hoodAngle, points.cfBottom); + .rotate(options.hoodAngle, points.cfBottom) points.frontTop = points.cfHeightLeft.shift( 0, measurements.headCircumference * options.hoodCutback - ); - points.frontTopCp2 = new Point(points.frontTop.x, points.cfTop.y); + ) + points.frontTopCp2 = new Point(points.frontTop.x, points.cfTop.y) points.backPitch = new Point( points.cbBottom.x + measurements.headCircumference * options.hoodDepth, points.cfHeightRight.y * 0.6 - ); - points.backPitchCp1 = points.backPitch.shift( - -90, - measurements.headCircumference * 0.1 - ); - points.backPitchCp2 = points.backPitchCp1.flipY(points.backPitch); + ) + points.backPitchCp1 = points.backPitch.shift(-90, measurements.headCircumference * 0.1) + points.backPitchCp2 = points.backPitchCp1.flipY(points.backPitch) // Paths paths.seam = new Path() @@ -52,64 +47,64 @@ export default function(part) { .curve_(points.frontTopCp2, points.cfTop) .line(points.cfBottom) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') // Complete? if (complete) { - points.logo = points.frontTop.shiftFractionTowards(points.cbBottom, 0.7); - points.title = points.frontTop.shiftFractionTowards(points.cbBottom, 0.3); - snippets.logo = new Snippet("logo", points.logo); - macro("title", { + points.logo = points.frontTop.shiftFractionTowards(points.cbBottom, 0.7) + points.title = points.frontTop.shiftFractionTowards(points.cbBottom, 0.3) + snippets.logo = new Snippet('logo', points.logo) + macro('title', { at: points.title, nr: 5, - title: "hood" - }); - if (sa) paths.sa = paths.seam.offset(sa).attr("class", "fabric sa"); + title: 'hood' + }) + if (sa) paths.sa = paths.seam.offset(sa).attr('class', 'fabric sa') } // Paperless? if (paperless) { - macro("hd", { + macro('hd', { from: points.cfBottom, to: points.cbBottom, y: points.cfBottom.y + sa + 15 - }); - macro("hd", { + }) + macro('hd', { from: points.cbBottom, to: points.backPitch, y: points.cfBottom.y + sa + 15 - }); - macro("hd", { + }) + macro('hd', { from: points.cfTop, to: points.backPitch, y: points.cfBottom.y + sa + 30 - }); - macro("hd", { + }) + macro('hd', { from: points.frontTop, to: points.backPitch, y: points.frontTop.y - sa - 15 - }); - macro("ld", { + }) + macro('ld', { from: points.cfBottom, to: points.cfTop, d: -15 - }); - macro("ld", { + }) + macro('ld', { from: points.cfBottom, to: points.cbBottom, d: 15 - }); - macro("vd", { + }) + macro('vd', { from: points.cfTop, to: points.frontTop, x: points.cfBottom.x - sa - 15 - }); - macro("vd", { + }) + macro('vd', { from: points.cfBottom, to: points.frontTop, x: points.cfBottom.x - sa - 30 - }); + }) } - return part; + return part } diff --git a/packages/huey/src/index.js b/packages/huey/src/index.js index 0139436d5cd..da411d3d43c 100644 --- a/packages/huey/src/index.js +++ b/packages/huey/src/index.js @@ -1,43 +1,43 @@ -import freesewing from "@freesewing/core"; -import plugins from "@freesewing/plugin-bundle"; -import Brian from "@freesewing/brian"; -import config from "../config"; +import freesewing from '@freesewing/core' +import plugins from '@freesewing/plugin-bundle' +import Brian from '@freesewing/brian' +import config from '../config' // Parts -import draftBack from "./back"; -import draftFront from "./front"; -import draftSleeve from "./sleeve"; -import draftPocket from "./pocket"; -import draftHood from "./hood"; -import draftWaistband from "./waistband"; -import draftCuff from "./cuff"; +import draftBack from './back' +import draftFront from './front' +import draftSleeve from './sleeve' +import draftPocket from './pocket' +import draftHood from './hood' +import draftWaistband from './waistband' +import draftCuff from './cuff' // Create new design -const Pattern = new freesewing.Design(config, plugins); +const Pattern = new freesewing.Design(config, plugins) // Attach draft methods from Brian to prototype Pattern.prototype.draftBase = function(part) { - return new Brian(this.settings).draftBase(part); -}; + return new Brian(this.settings).draftBase(part) +} Pattern.prototype.draftFrontBase = function(part) { - return new Brian(this.settings).draftFront(part); -}; + return new Brian(this.settings).draftFront(part) +} Pattern.prototype.draftBackBase = function(part) { - return new Brian(this.settings).draftBack(part); -}; + return new Brian(this.settings).draftBack(part) +} Pattern.prototype.draftSleevecap = function(part) { - return new Brian(this.settings).draftSleevecap(part); -}; + return new Brian(this.settings).draftSleevecap(part) +} Pattern.prototype.draftSleeveBase = function(part) { - return new Brian(this.settings).draftSleeve(part); -}; + return new Brian(this.settings).draftSleeve(part) +} // Attach own draft methods to prototype -Pattern.prototype.draftBack = draftBack; -Pattern.prototype.draftFront = draftFront; -Pattern.prototype.draftSleeve = draftSleeve; -Pattern.prototype.draftPocket = draftPocket; -Pattern.prototype.draftHood = draftHood; -Pattern.prototype.draftWaistband = draftWaistband; -Pattern.prototype.draftCuff = draftCuff; +Pattern.prototype.draftBack = draftBack +Pattern.prototype.draftFront = draftFront +Pattern.prototype.draftSleeve = draftSleeve +Pattern.prototype.draftPocket = draftPocket +Pattern.prototype.draftHood = draftHood +Pattern.prototype.draftWaistband = draftWaistband +Pattern.prototype.draftCuff = draftCuff -export default Pattern; +export default Pattern diff --git a/packages/huey/src/pocket.js b/packages/huey/src/pocket.js index c3fa47b0e2f..be24bb3af89 100644 --- a/packages/huey/src/pocket.js +++ b/packages/huey/src/pocket.js @@ -10,12 +10,12 @@ export default function(part) { Snippet, sa, options - } = part.shorthand(); + } = part.shorthand() - if (!options.pocket) return part; + if (!options.pocket) return part // Clear paths, apart from the pocket - for (let p of Object.keys(paths)) delete paths[p]; + for (let p of Object.keys(paths)) delete paths[p] // Paths paths.seam = new Path() @@ -26,57 +26,51 @@ export default function(part) { .line(points.pocketCfTop) .line(points.cfHem) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') // Complete? if (complete) { - points.logo = points.pocketCfTop.shiftFractionTowards( - points.pocketHem, - 0.3 - ); - points.title = points.pocketCfTop.shiftFractionTowards( - points.pocketHem, - 0.5 - ); - snippets.logo = new Snippet("logo", points.logo); - macro("title", { + points.logo = points.pocketCfTop.shiftFractionTowards(points.pocketHem, 0.3) + points.title = points.pocketCfTop.shiftFractionTowards(points.pocketHem, 0.5) + snippets.logo = new Snippet('logo', points.logo) + macro('title', { at: points.title, nr: 4, - title: "pocket" - }); + title: 'pocket' + }) if (sa) { - paths.sa = paths.seam.offset(sa).attr("class", "fabric sa"); + paths.sa = paths.seam.offset(sa).attr('class', 'fabric sa') } } // Paperless? if (paperless) { - macro("hd", { + macro('hd', { from: points.cfHem, to: points.pocketHem, y: points.cfHem.y + sa + 15 - }); - macro("hd", { + }) + macro('hd', { from: points.cfHem, to: points.pocketTip, y: points.cfHem.y + sa + 30 - }); - macro("hd", { + }) + macro('hd', { from: points.pocketCfTop, to: points.pocketTopRight, y: points.pocketCfTop.y - sa - 15 - }); - macro("vd", { + }) + macro('vd', { from: points.cfHem, to: points.pocketCfTop, x: points.cfHem.x - sa - 15 - }); - macro("vd", { + }) + macro('vd', { from: points.pocketHem, to: points.pocketTip, x: points.pocketTip.x + sa + 15 - }); + }) } - return part; + return part } diff --git a/packages/huey/src/shared.js b/packages/huey/src/shared.js index b7934190a83..319e30b31f5 100644 --- a/packages/huey/src/shared.js +++ b/packages/huey/src/shared.js @@ -1,84 +1,84 @@ export const sharedDimensions = function(part, s) { - let { macro, Point, points, sa } = part.shorthand(); + let { macro, Point, points, sa } = part.shorthand() - if (s === "front") { - points.cHem = points.cfHem; - points.cNeck = points.cfNeck; + if (s === 'front') { + points.cHem = points.cfHem + points.cNeck = points.cfNeck } else { - points.cHem = points.cbHem; - points.cNeck = points.cbNeck; + points.cHem = points.cbHem + points.cNeck = points.cbNeck } - macro("hd", { + macro('hd', { from: points.cHem, to: points.hem, y: points.cHem.y + 3 * sa + 15 - }); - macro("ld", { + }) + macro('ld', { from: new Point(0, points.armholePitch.y), to: points.armholePitch - }); - macro("hd", { + }) + macro('hd', { from: points.cNeck, to: points.neck, y: points.neck.y - sa - 15 - }); - macro("hd", { + }) + macro('hd', { from: points.cNeck, to: points.shoulder, y: points.neck.y - sa - 30 - }); - macro("hd", { + }) + macro('hd', { from: points.cNeck, to: points.armhole, y: points.neck.y - sa - 45 - }); - macro("ld", { + }) + macro('ld', { from: points.neck, to: points.shoulder, d: -15 - }); - macro("vd", { + }) + macro('vd', { from: points.hem, to: points.armhole, x: points.armhole.x + sa + 15 - }); - macro("vd", { + }) + macro('vd', { from: points.armhole, to: points.armholePitch, x: points.armhole.x + sa + 15 - }); - macro("vd", { + }) + macro('vd', { from: points.armholePitch, to: points.shoulder, x: points.armhole.x + sa + 15 - }); - macro("vd", { + }) + macro('vd', { from: points.armhole, to: points.shoulder, x: points.armhole.x + sa + 30 - }); - macro("vd", { + }) + macro('vd', { from: points.armhole, to: points.neck, x: points.armhole.x + sa + 45 - }); - macro("vd", { + }) + macro('vd', { from: points.cNeck, to: points.neck, x: points.cNeck.x - 15 - }); - macro("vd", { + }) + macro('vd', { from: points.cHem, to: points.cNeck, x: points.cNeck.x - 15 - }); - macro("vd", { + }) + macro('vd', { from: points.cHem, to: points.neck, x: points.cNeck.x - 30 - }); -}; + }) +} export const draftRibbing = function(part, length) { let { @@ -94,27 +94,26 @@ export const draftRibbing = function(part, length) { paperless, macro, units - } = part.shorthand(); - if (typeof store.get("ribbingHeight") === "undefined") { + } = part.shorthand() + if (typeof store.get('ribbingHeight') === 'undefined') { store.set( - "ribbingHeight", - (measurements.centerBackNeckToWaist + measurements.naturalWaistToHip) * - options.ribbingHeight - ); + 'ribbingHeight', + (measurements.centerBackNeckToWaist + measurements.naturalWaistToHip) * options.ribbingHeight + ) } - let height = store.get("ribbingHeight"); - let gap = 25; - let lead = 50; - if (length < 125) lead = length / 3; + let height = store.get('ribbingHeight') + let gap = 25 + let lead = 50 + if (length < 125) lead = length / 3 - points.topLeft = new Point(0, 0); - points.topRight = new Point(height * 2, 0); - points.leftGapStart = new Point(0, lead); - points.rightGapEnd = new Point(points.topRight.x, lead); - points.leftGapEnd = new Point(0, lead + gap); - points.rightGapStart = new Point(points.topRight.x, lead + gap); - points.bottomLeft = new Point(0, gap + 2 * lead); - points.bottomRight = new Point(points.topRight.x, gap + 2 * lead); + points.topLeft = new Point(0, 0) + points.topRight = new Point(height * 2, 0) + points.leftGapStart = new Point(0, lead) + points.rightGapEnd = new Point(points.topRight.x, lead) + points.leftGapEnd = new Point(0, lead + gap) + points.rightGapStart = new Point(points.topRight.x, lead + gap) + points.bottomLeft = new Point(0, gap + 2 * lead) + points.bottomRight = new Point(points.topRight.x, gap + 2 * lead) paths.seam = new Path() .move(points.rightGapEnd) @@ -125,20 +124,17 @@ export const draftRibbing = function(part, length) { .line(points.bottomLeft) .line(points.bottomRight) .line(points.rightGapStart) - .attr("class", "various"); + .attr('class', 'various') paths.hint = new Path() .move(points.leftGapStart) .line(points.leftGapEnd) .move(points.rightGapStart) .line(points.rightGapEnd) - .attr("class", "various dashed"); + .attr('class', 'various dashed') if (complete) { - points.title = new Point( - points.bottomRight.x / 2, - points.bottomRight.y / 2 - ); + points.title = new Point(points.bottomRight.x / 2, points.bottomRight.y / 2) if (sa) { paths.sa = new Path() .move(points.topLeft) @@ -148,21 +144,21 @@ export const draftRibbing = function(part, length) { .line(points.topLeft) .close() .offset(sa) - .attr("class", "various sa"); + .attr('class', 'various sa') } - macro("vd", { + macro('vd', { from: points.bottomRight, to: points.topRight, x: points.topRight.x - 25, text: units(length) - }); + }) } if (paperless) { - macro("hd", { + macro('hd', { from: points.topLeft, to: points.topRight, y: points.topRight.y - sa - 15 - }); + }) } -}; +} diff --git a/packages/huey/src/sleeve.js b/packages/huey/src/sleeve.js index ff49d8b2b64..2db615f064e 100644 --- a/packages/huey/src/sleeve.js +++ b/packages/huey/src/sleeve.js @@ -10,17 +10,17 @@ export default function(part) { sa, paperless, macro - } = part.shorthand(); + } = part.shorthand() // Clear paths from Brian, but keep sleevecap for (let p of Object.keys(paths)) { - if (p !== "sleevecap") delete paths[p]; + if (p !== 'sleevecap') delete paths[p] } // Shorten sleeve to take ribbing into account if (options.ribbing) { - for (let p of ["wristLeft", "wristRight"]) - points[p] = points[p].shift(90, store.get("ribbingHeight")); + for (let p of ['wristLeft', 'wristRight']) + points[p] = points[p].shift(90, store.get('ribbingHeight')) } // Paths @@ -29,63 +29,63 @@ export default function(part) { .line(points.bicepsRight) .join(paths.sleevecap) .line(points.wristLeft) - .attr("class", "various stroke-xxl"); + .attr('class', 'various stroke-xxl') paths.hemBase = new Path() .move(points.wristLeft) .line(points.wristRight) - .attr("class", "various stroke-xxl"); - paths.saBase.render = false; - paths.hemBase.render = false; + .attr('class', 'various stroke-xxl') + paths.saBase.render = false + paths.hemBase.render = false paths.seam = paths.saBase .join(paths.hemBase) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') // Complete? if (complete) { - macro("grainline", { + macro('grainline', { from: new Point(0, points.wristLeft.y), to: new Point(0, points.backPitch.y) - }); + }) if (sa) { - if (options.ribbing) paths.sa = paths.seam.offset(sa); + if (options.ribbing) paths.sa = paths.seam.offset(sa) else { paths.sa = paths.saBase .clone() .offset(sa) .join(paths.hemBase.offset(3 * sa)) - .close(); + .close() } - paths.sa.attr("class", "fabric sa"); + paths.sa.attr('class', 'fabric sa') } } // Paperless? if (paperless) { - let hemSa = sa; - if (!options.ribbing) hemSa = 3 * sa; - macro("hd", { + let hemSa = sa + if (!options.ribbing) hemSa = 3 * sa + macro('hd', { from: points.wristLeft, to: points.wristRight, y: points.wristLeft.y + hemSa + 15 - }); - macro("hd", { + }) + macro('hd', { from: points.bicepsLeft, to: points.bicepsRight, y: points.sleeveTip.y - sa - 15 - }); - macro("vd", { + }) + macro('vd', { from: points.wristLeft, to: points.bicepsLeft, x: points.bicepsLeft.x - sa - 15 - }); - macro("vd", { + }) + macro('vd', { from: points.wristLeft, to: points.sleeveTip, x: points.bicepsLeft.x - sa - 30 - }); + }) } - return part; + return part } diff --git a/packages/huey/src/waistband.js b/packages/huey/src/waistband.js index eb9f39cc8a4..57949af5156 100644 --- a/packages/huey/src/waistband.js +++ b/packages/huey/src/waistband.js @@ -1,23 +1,21 @@ -import { draftRibbing } from "./shared"; +import { draftRibbing } from './shared' export default function(part) { - let { complete, points, measurements, options, macro } = part.shorthand(); - if (!options.ribbing) return part; + let { complete, points, measurements, options, macro } = part.shorthand() + if (!options.ribbing) return part draftRibbing( part, - measurements.hipsCircumference * - (1 + options.hipsEase) * - (1 - options.ribbingStretch) - ); + measurements.hipsCircumference * (1 + options.hipsEase) * (1 - options.ribbingStretch) + ) // Complete pattern? if (complete) { - macro("title", { + macro('title', { at: points.title, nr: 6, - title: "waistband" - }); + title: 'waistband' + }) } - return part; + return part } diff --git a/packages/hugo/example/src/App.js b/packages/hugo/example/src/App.js index e7936330e5d..115cdf683af 100644 --- a/packages/hugo/example/src/App.js +++ b/packages/hugo/example/src/App.js @@ -1,22 +1,15 @@ -import React from "react"; -import freesewing from "@freesewing/core"; -import Workbench from "@freesewing/components/Workbench"; -import "typeface-roboto-condensed"; -import "@freesewing/css-theme"; +import React from 'react' +import freesewing from '@freesewing/core' +import Workbench from '@freesewing/components/Workbench' +import 'typeface-roboto-condensed' +import '@freesewing/css-theme' -import Pattern from "pattern"; +import Pattern from 'pattern' const App = props => { - let instance = new Pattern(); - let config = instance.config; - return ( - - ); -}; + let instance = new Pattern() + let config = instance.config + return +} -export default App; +export default App diff --git a/packages/hugo/example/src/index.js b/packages/hugo/example/src/index.js index 7900787a4d2..9dd7ba788d4 100644 --- a/packages/hugo/example/src/index.js +++ b/packages/hugo/example/src/index.js @@ -1,11 +1,11 @@ -import React from "react"; -import ReactDOM from "react-dom"; -import App from "./App"; -import * as serviceWorker from "./serviceWorker"; +import React from 'react' +import ReactDOM from 'react-dom' +import App from './App' +import * as serviceWorker from './serviceWorker' -ReactDOM.render(, document.getElementById("root")); +ReactDOM.render(, document.getElementById('root')) // If you want your app to work offline and load faster, you can change // unregister() to register() below. Note this comes with some pitfalls. // Learn more about service workers: http://bit.ly/CRA-PWA -serviceWorker.unregister(); +serviceWorker.unregister() diff --git a/packages/hugo/example/src/serviceWorker.js b/packages/hugo/example/src/serviceWorker.js index 68fda5a0eb6..44e1b1b2f8c 100644 --- a/packages/hugo/example/src/serviceWorker.js +++ b/packages/hugo/example/src/serviceWorker.js @@ -9,46 +9,44 @@ // This link also includes instructions on opting out of this behavior. const isLocalhost = Boolean( - window.location.hostname === "localhost" || + window.location.hostname === 'localhost' || // [::1] is the IPv6 localhost address. - window.location.hostname === "[::1]" || + window.location.hostname === '[::1]' || // 127.0.0.1/8 is considered localhost for IPv4. - window.location.hostname.match( - /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ - ) -); + window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/) +) export function register(config) { - if (process.env.NODE_ENV === "production" && "serviceWorker" in navigator) { + if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) { // The URL constructor is available in all browsers that support SW. - const publicUrl = new URL(process.env.PUBLIC_URL, window.location); + const publicUrl = new URL(process.env.PUBLIC_URL, window.location) if (publicUrl.origin !== window.location.origin) { // Our service worker won't work if PUBLIC_URL is on a different origin // from what our page is served on. This might happen if a CDN is used to // serve assets; see https://github.com/facebook/create-react-app/issues/2374 - return; + return } - window.addEventListener("load", () => { - const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; + window.addEventListener('load', () => { + const swUrl = `${process.env.PUBLIC_URL}/service-worker.js` if (isLocalhost) { // This is running on localhost. Let's check if a service worker still exists or not. - checkValidServiceWorker(swUrl, config); + checkValidServiceWorker(swUrl, config) // Add some additional logging to localhost, pointing developers to the // service worker/PWA documentation. navigator.serviceWorker.ready.then(() => { console.log( - "This web app is being served cache-first by a service " + - "worker. To learn more, visit https://goo.gl/SC7cgQ" - ); - }); + 'This web app is being served cache-first by a service ' + + 'worker. To learn more, visit https://goo.gl/SC7cgQ' + ) + }) } else { // Is not local host. Just register service worker - registerValidSW(swUrl, config); + registerValidSW(swUrl, config) } - }); + }) } } @@ -57,38 +55,38 @@ function registerValidSW(swUrl, config) { .register(swUrl) .then(registration => { registration.onupdatefound = () => { - const installingWorker = registration.installing; + const installingWorker = registration.installing installingWorker.onstatechange = () => { - if (installingWorker.state === "installed") { + if (installingWorker.state === 'installed') { if (navigator.serviceWorker.controller) { // At this point, the old content will have been purged and // the fresh content will have been added to the cache. // It's the perfect time to display a "New content is // available; please refresh." message in your web app. - console.log("New content is available; please refresh."); + console.log('New content is available; please refresh.') // Execute callback if (config.onUpdate) { - config.onUpdate(registration); + config.onUpdate(registration) } } else { // At this point, everything has been precached. // It's the perfect time to display a // "Content is cached for offline use." message. - console.log("Content is cached for offline use."); + console.log('Content is cached for offline use.') // Execute callback if (config.onSuccess) { - config.onSuccess(registration); + config.onSuccess(registration) } } } - }; - }; + } + } }) .catch(error => { - console.error("Error during service worker registration:", error); - }); + console.error('Error during service worker registration:', error) + }) } function checkValidServiceWorker(swUrl, config) { @@ -98,30 +96,28 @@ function checkValidServiceWorker(swUrl, config) { // Ensure service worker exists, and that we really are getting a JS file. if ( response.status === 404 || - response.headers.get("content-type").indexOf("javascript") === -1 + response.headers.get('content-type').indexOf('javascript') === -1 ) { // No service worker found. Probably a different app. Reload the page. navigator.serviceWorker.ready.then(registration => { registration.unregister().then(() => { - window.location.reload(); - }); - }); + window.location.reload() + }) + }) } else { // Service worker found. Proceed as normal. - registerValidSW(swUrl, config); + registerValidSW(swUrl, config) } }) .catch(() => { - console.log( - "No internet connection found. App is running in offline mode." - ); - }); + console.log('No internet connection found. App is running in offline mode.') + }) } export function unregister() { - if ("serviceWorker" in navigator) { + if ('serviceWorker' in navigator) { navigator.serviceWorker.ready.then(registration => { - registration.unregister(); - }); + registration.unregister() + }) } } diff --git a/packages/hugo/src/back.js b/packages/hugo/src/back.js index 3d95bd72507..6f88fa432e7 100644 --- a/packages/hugo/src/back.js +++ b/packages/hugo/src/back.js @@ -1,8 +1,8 @@ export default function(part) { // Remove clutter - let seam = part.paths.seam; - part.paths = {}; - part.paths.seam = seam; + let seam = part.paths.seam + part.paths = {} + part.paths.seam = seam let { store, @@ -17,22 +17,20 @@ export default function(part) { paperless, macro, debug - } = part.shorthand(); + } = part.shorthand() // Hem is more descripting than hips in this case //points.cbHem = points.cbHips; // points.hem = points.hips; // Ribbing - points.cbRibbing = points.cbHem.shift(90, store.get("ribbing")); - points.ribbing = points.hem.shift(90, store.get("ribbing")); + points.cbRibbing = points.cbHem.shift(90, store.get('ribbing')) + points.ribbing = points.hem.shift(90, store.get('ribbing')) // Raglan tip - let neckOpening = new Path() - .move(points.cbNeck) - .curve(points.cbNeck, points.neckCp2, points.neck); - points.raglanTipBack = neckOpening.shiftFractionAlong(0.7); - let neckOpeningParts = neckOpening.split(points.raglanTipBack); + let neckOpening = new Path().move(points.cbNeck).curve(points.cbNeck, points.neckCp2, points.neck) + points.raglanTipBack = neckOpening.shiftFractionAlong(0.7) + let neckOpeningParts = neckOpening.split(points.raglanTipBack) // Paths paths.saBase = new Path() .move(points.cbRibbing) @@ -40,82 +38,79 @@ export default function(part) { .line(points.armhole) .curve(points.armholeCp2, points.armholeHollowCp1, points.armholeHollow) .line(points.raglanTipBack) - .join(neckOpeningParts[0].reverse()); + .join(neckOpeningParts[0].reverse()) paths.seam = paths.saBase .clone() .close() - .attr("class", "fabric"); - paths.saBase.render = false; + .attr('class', 'fabric') + paths.saBase.render = false // Store neck opening path - store.set("neckOpeningPartBack", neckOpeningParts[1]); - store.set("neckOpeningAnchorBack", points.neck); - store.set("neckOpeningLenBack", neckOpening.length()); - store.set("neckCutoutBack", points.cbNeck.y); + store.set('neckOpeningPartBack', neckOpeningParts[1]) + store.set('neckOpeningAnchorBack', points.neck) + store.set('neckOpeningLenBack', neckOpening.length()) + store.set('neckCutoutBack', points.cbNeck.y) // Complete pattern? if (complete) { - macro("cutonfold", { + macro('cutonfold', { from: points.cbNeck, to: points.cbRibbing, grainline: true - }); - points.title = new Point(points.armhole.x / 2, points.armhole.y); - macro("title", { at: points.title, nr: 2, title: "back" }); - store.set("notchBack", points.raglanTipBack.dist(points.armholeHollow) / 2); + }) + points.title = new Point(points.armhole.x / 2, points.armhole.y) + macro('title', { at: points.title, nr: 2, title: 'back' }) + store.set('notchBack', points.raglanTipBack.dist(points.armholeHollow) / 2) points.sleeveNotch = points.raglanTipBack.shiftTowards( points.armholeHollow, - store.get("notchBack") - ); - snippets.sleeveNotch = new Snippet("bnotch", points.sleeveNotch); - store.set( - "backRaglanTipToNotch", - points.raglanTipBack.dist(points.sleeveNotch) - ); - points.logo = points.title.shift(-90, 70); - snippets.logo = new Snippet("logo", points.logo); + store.get('notchBack') + ) + snippets.sleeveNotch = new Snippet('bnotch', points.sleeveNotch) + store.set('backRaglanTipToNotch', points.raglanTipBack.dist(points.sleeveNotch)) + points.logo = points.title.shift(-90, 70) + snippets.logo = new Snippet('logo', points.logo) if (sa) { paths.sa = paths.saBase .offset(sa) .line(points.cbNeck) - .attr("class", "fabric sa"); - paths.sa.move(points.cbRibbing).line(paths.sa.start()); + .attr('class', 'fabric sa') + paths.sa.move(points.cbRibbing).line(paths.sa.start()) } } // Paperless? if (paperless) { - macro("vd", { + macro('vd', { from: points.cbRibbing, to: points.cbNeck, x: points.cbNeck.x - 15 - }); - macro("vd", { + }) + macro('vd', { from: points.cbRibbing, to: points.raglanTipBack, x: points.cbNeck.x - 30 - }); - macro("vd", { + }) + macro('vd', { from: points.ribbing, to: points.armhole, x: points.ribbing.x + 15 + sa - }); - macro("hd", { + }) + macro('hd', { from: points.cbNeck, to: points.raglanTipBack, y: points.raglanTipBack.y - 15 - sa - }); - macro("hd", { + }) + macro('hd', { from: points.raglanTipBack, to: points.armhole, y: points.raglanTipBack.y - 15 - sa - }); - macro("hd", { + }) + macro('hd', { from: points.cbRibbing, to: points.ribbing, y: points.cbRibbing.y + 15 + sa - }); + }) } - return part; + return part } diff --git a/packages/hugo/src/cuff.js b/packages/hugo/src/cuff.js index 7ea03a9454a..1ca6560162b 100644 --- a/packages/hugo/src/cuff.js +++ b/packages/hugo/src/cuff.js @@ -10,21 +10,19 @@ export default function(part) { complete, paperless, macro - } = part.shorthand(); + } = part.shorthand() let width = (measurements.centerBackNeckToWaist + measurements.naturalWaistToHip) * options.ribbingHeight * - 2; + 2 let length = - measurements.wristCircumference * - (1 + options.cuffEase) * - (1 - options.ribbingStretch); + measurements.wristCircumference * (1 + options.cuffEase) * (1 - options.ribbingStretch) - points.topLeft = new Point(0, 0); - points.bottomLeft = new Point(0, width); - points.topRight = new Point(length, 0); - points.bottomRight = new Point(length, width); + points.topLeft = new Point(0, 0) + points.bottomLeft = new Point(0, width) + points.topRight = new Point(length, 0) + points.bottomRight = new Point(length, width) paths.seam = new Path() .move(points.topLeft) @@ -33,34 +31,34 @@ export default function(part) { .line(points.topRight) .line(points.topLeft) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') // Complete pattern? if (complete) { if (sa) { - paths.sa = paths.seam.offset(sa); + paths.sa = paths.seam.offset(sa) } - points.title = points.bottomLeft.shiftFractionTowards(points.topRight, 0.5); - macro("title", { at: points.title, nr: 9, title: "cuff" }); - macro("grainline", { + points.title = points.bottomLeft.shiftFractionTowards(points.topRight, 0.5) + macro('title', { at: points.title, nr: 9, title: 'cuff' }) + macro('grainline', { from: points.bottomLeft.shift(0, 20), to: points.topLeft.shift(0, 20) - }); + }) } // Paperless? if (paperless) { - macro("vd", { + macro('vd', { from: points.bottomRight, to: points.topRight, x: points.topRight.x + sa + 15 - }); - macro("hd", { + }) + macro('hd', { from: points.bottomLeft, to: points.bottomRight, y: points.bottomRight.y + sa + 15 - }); + }) } - return part; + return part } diff --git a/packages/hugo/src/front.js b/packages/hugo/src/front.js index a52b83e3656..9744d12e742 100644 --- a/packages/hugo/src/front.js +++ b/packages/hugo/src/front.js @@ -1,8 +1,8 @@ export default function(part) { // Remove clutter - let seam = part.paths.seam; - part.paths = {}; - part.paths.seam = seam; + let seam = part.paths.seam + part.paths = {} + part.paths.seam = seam let { utils, @@ -20,51 +20,47 @@ export default function(part) { paperless, macro, debug - } = part.shorthand(); + } = part.shorthand() // Absolute values for percentages store.set( - "lengthBonus", - options.lengthBonus * - (measurements.centerBackNeckToWaist + measurements.naturalWaistToHip) - ); + 'lengthBonus', + options.lengthBonus * (measurements.centerBackNeckToWaist + measurements.naturalWaistToHip) + ) store.set( - "ribbing", - (measurements.centerBackNeckToWaist + measurements.naturalWaistToHip) * - options.ribbingHeight - ); + 'ribbing', + (measurements.centerBackNeckToWaist + measurements.naturalWaistToHip) * options.ribbingHeight + ) // Hem is more descripting than hips in this case //points.cfHem = points.cfHips; //points.hem = points.hips; // Ribbing - points.cfRibbing = points.cfHem.shift(90, store.get("ribbing")); - points.ribbing = points.hem.shift(90, store.get("ribbing")); + points.cfRibbing = points.cfHem.shift(90, store.get('ribbing')) + points.ribbing = points.hem.shift(90, store.get('ribbing')) // Raglan tip - let neckOpening = new Path() - .move(points.cfNeck) - .curve(points.cfNeck, points.neckCp2, points.neck); - points.raglanTipFront = neckOpening.shiftFractionAlong(0.8); - let neckOpeningParts = neckOpening.split(points.raglanTipFront); + let neckOpening = new Path().move(points.cfNeck).curve(points.cfNeck, points.neckCp2, points.neck) + points.raglanTipFront = neckOpening.shiftFractionAlong(0.8) + let neckOpeningParts = neckOpening.split(points.raglanTipFront) // Pocket - points.pocketHem = points.cfRibbing.shiftFractionTowards(points.ribbing, 0.6); + points.pocketHem = points.cfRibbing.shiftFractionTowards(points.ribbing, 0.6) points.pocketCf = points.cfHem.shift( 90, - measurements.centerBackNeckToWaist * 0.33 + store.get("ribbing") - ); - points.pocketTop = new Point(points.pocketHem.x, points.pocketCf.y); + measurements.centerBackNeckToWaist * 0.33 + store.get('ribbing') + ) + points.pocketTop = new Point(points.pocketHem.x, points.pocketCf.y) points.pocketTip = points.pocketHem .shift(90, points.pocketHem.x / 3) - .rotate(-30, points.pocketHem); + .rotate(-30, points.pocketHem) points.pocketTopCp = utils.beamsIntersect( points.pocketTop, points.pocketHem, points.pocketTip, points.pocketHem.rotate(90, points.pocketTip) - ); + ) // Paths paths.saBase = new Path() @@ -73,117 +69,111 @@ export default function(part) { .line(points.armhole) .curve(points.armholeCp2, points.armholeHollowCp1, points.armholeHollow) .line(points.raglanTipFront) - .join(neckOpeningParts[0].reverse()); + .join(neckOpeningParts[0].reverse()) paths.seam = paths.saBase .clone() .close() - .attr("class", "fabric"); - paths.saBase.render = false; + .attr('class', 'fabric') + paths.saBase.render = false paths.pocket = new Path() .move(points.pocketHem) .line(points.pocketTip) .curve(points.pocketTip, points.pocketTopCp, points.pocketTop) .line(points.pocketCf) - .attr("class", "fabric help"); + .attr('class', 'fabric help') // Store shoulder seam length, neck opening path, shoulder slope and raglan length - store.set("shoulderLength", points.neck.dist(points.shoulder)); - store.set("neckOpeningPartFront", neckOpeningParts[1]); - store.set("neckOpeningAnchorFront", points.neck); - store.set("shoulderSlopeDeltaY", points.neck.dy(points.shoulder)); + store.set('shoulderLength', points.neck.dist(points.shoulder)) + store.set('neckOpeningPartFront', neckOpeningParts[1]) + store.set('neckOpeningAnchorFront', points.neck) + store.set('shoulderSlopeDeltaY', points.neck.dy(points.shoulder)) store.set( - "raglen", + 'raglen', new Path() .move(points.raglanTipFront) .line(points.armholeHollow) .curve(points.armholeHollowCp1, points.armholeCp2, points.armhole) .length() - ); - store.set("neckOpeningLenFront", neckOpening.length()); - store.set("neckCutoutFront", points.cfNeck.y); + ) + store.set('neckOpeningLenFront', neckOpening.length()) + store.set('neckCutoutFront', points.cfNeck.y) // Complete pattern? if (complete) { - macro("cutonfold", { + macro('cutonfold', { from: points.cfNeck, to: points.cfRibbing, grainline: true - }); - points.title = new Point(points.armhole.x / 2, points.armhole.y); - macro("title", { at: points.title, nr: 1, title: "front" }); - store.set( - "notchFront", - points.raglanTipFront.dist(points.armholeHollow) / 2 - ); + }) + points.title = new Point(points.armhole.x / 2, points.armhole.y) + macro('title', { at: points.title, nr: 1, title: 'front' }) + store.set('notchFront', points.raglanTipFront.dist(points.armholeHollow) / 2) points.sleeveNotch = points.raglanTipFront.shiftTowards( points.armholeHollow, - store.get("notchFront") - ); - snippets.sleeveNotch = new Snippet("notch", points.sleeveNotch); - store.set( - "frontRaglanTipToNotch", - points.raglanTipFront.dist(points.sleeveNotch) - ); - points.logo = points.title.shift(-90, 70); - snippets.logo = new Snippet("logo", points.logo); + store.get('notchFront') + ) + snippets.sleeveNotch = new Snippet('notch', points.sleeveNotch) + store.set('frontRaglanTipToNotch', points.raglanTipFront.dist(points.sleeveNotch)) + points.logo = points.title.shift(-90, 70) + snippets.logo = new Snippet('logo', points.logo) if (sa) { paths.sa = paths.saBase .offset(sa) .line(points.cfNeck) - .attr("class", "fabric sa"); - paths.sa.move(points.cfRibbing).line(paths.sa.start()); + .attr('class', 'fabric sa') + paths.sa.move(points.cfRibbing).line(paths.sa.start()) } } // Paperless? if (paperless) { - macro("vd", { + macro('vd', { from: points.cfRibbing, to: points.cfNeck, x: points.cfNeck.x - 15 - }); - macro("vd", { + }) + macro('vd', { from: points.cfRibbing, to: points.raglanTipFront, x: points.cfNeck.x - 30 - }); - macro("vd", { + }) + macro('vd', { from: points.ribbing, to: points.armhole, x: points.ribbing.x + 15 + sa - }); - macro("hd", { + }) + macro('hd', { from: points.cfNeck, to: points.raglanTipFront, y: points.raglanTipFront.y - 15 - sa - }); - macro("hd", { + }) + macro('hd', { from: points.raglanTipFront, to: points.armhole, y: points.raglanTipFront.y - 15 - sa - }); - macro("hd", { + }) + macro('hd', { from: points.cfRibbing, to: points.pocketTop, y: points.cfRibbing.y + 15 + sa - }); - macro("hd", { + }) + macro('hd', { from: points.cfRibbing, to: points.pocketTip, y: points.cfRibbing.y + 30 + sa - }); - macro("hd", { + }) + macro('hd', { from: points.cfRibbing, to: points.ribbing, y: points.cfRibbing.y + 45 + sa - }); - macro("vd", { + }) + macro('vd', { from: points.pocketHem, to: points.pocketTop, x: points.pocketTip.x + 15 - }); + }) } - return part; + return part } diff --git a/packages/hugo/src/hoodcenter.js b/packages/hugo/src/hoodcenter.js index fbabe18dcfb..618af985fc6 100644 --- a/packages/hugo/src/hoodcenter.js +++ b/packages/hugo/src/hoodcenter.js @@ -10,17 +10,17 @@ export default function(part) { paperless, macro, units - } = part.shorthand(); + } = part.shorthand() - let width = store.get("hoodCenterWidth"); - points.topLeft = new Point(0, 0); - points.bottomLeft = new Point(0, width); - points.topMidLeft = new Point(width, 0); - points.bottomMidLeft = new Point(width, width); - points.topMidRight = new Point(width * 1.5, 0); - points.bottomMidRight = new Point(width * 1.5, width); - points.topRight = new Point(width * 2.5, 0); - points.bottomRight = new Point(width * 2.5, width); + let width = store.get('hoodCenterWidth') + points.topLeft = new Point(0, 0) + points.bottomLeft = new Point(0, width) + points.topMidLeft = new Point(width, 0) + points.bottomMidLeft = new Point(width, width) + points.topMidRight = new Point(width * 1.5, 0) + points.bottomMidRight = new Point(width * 1.5, width) + points.topRight = new Point(width * 2.5, 0) + points.bottomRight = new Point(width * 2.5, width) paths.seam = new Path() .move(points.topMidLeft) @@ -31,41 +31,41 @@ export default function(part) { .line(points.bottomRight) .line(points.topRight) .line(points.topMidRight) - .attr("class", "fabric"); + .attr('class', 'fabric') paths.hint = new Path() .move(points.topMidLeft) .line(points.topMidRight) .move(points.bottomMidLeft) .line(points.bottomMidRight) - .attr("class", "fabric dashed"); + .attr('class', 'fabric dashed') // Complete pattern? if (complete) { if (sa) { - paths.sa = paths.seam.offset(sa); + paths.sa = paths.seam.offset(sa) } - points.title = points.bottomLeft.shiftFractionTowards(points.topRight, 0.5); - macro("title", { at: points.title, nr: 7, title: "hoodCenter" }); - macro("grainline", { + points.title = points.bottomLeft.shiftFractionTowards(points.topRight, 0.5) + macro('title', { at: points.title, nr: 7, title: 'hoodCenter' }) + macro('grainline', { from: points.topLeft.shift(-90, width / 2), to: points.topRight.shift(-90, width / 2) - }); + }) } // Paperless? if (paperless) { - macro("vd", { + macro('vd', { from: points.bottomRight, to: points.topRight, x: points.topRight.x + sa + 15 - }); - macro("hd", { + }) + macro('hd', { from: points.bottomLeft, to: points.bottomRight, y: points.bottomRight.y + sa + 15, - text: units(store.get("hoodCenterLength")) - }); + text: units(store.get('hoodCenterLength')) + }) } - return part; + return part } diff --git a/packages/hugo/src/hoodside.js b/packages/hugo/src/hoodside.js index db679592606..0e49885c305 100644 --- a/packages/hugo/src/hoodside.js +++ b/packages/hugo/src/hoodside.js @@ -13,58 +13,44 @@ export default function(part) { paperless, macro, debug - } = part.shorthand(); + } = part.shorthand() - let neckOpening = - store.get("neckOpeningLenFront") + store.get("neckOpeningLenBack"); - let hoodOpening = measurements.headCircumference; - let neckCutoutDelta = - store.get("neckCutoutFront") - store.get("neckCutoutBack"); - store.set("hoodCenterWidth", measurements.headCircumference / 10); - let halfCenterPanel = store.get("hoodCenterWidth") / 2; - points.topLeft = new Point(0, 0); - points.topRight = new Point(neckOpening, 0); - points.neckRight = new Point( - neckOpening, - (hoodOpening - halfCenterPanel) / 2 - ); - points.neckLeft = new Point(0, points.neckRight.y); - points.frontLeft = points.neckLeft.shift(-90, neckCutoutDelta); - points.frontEdge = points.neckRight.shift(-90, neckCutoutDelta); - points.neckEdge = points.neckLeft.shift(0, halfCenterPanel); - points.neckEdgeCp2 = new Point(points.neckRight.x / 2, points.neckEdge.y); - points.frontEdgeCp1 = new Point(points.neckEdgeCp2.x, points.frontEdge.y); + let neckOpening = store.get('neckOpeningLenFront') + store.get('neckOpeningLenBack') + let hoodOpening = measurements.headCircumference + let neckCutoutDelta = store.get('neckCutoutFront') - store.get('neckCutoutBack') + store.set('hoodCenterWidth', measurements.headCircumference / 10) + let halfCenterPanel = store.get('hoodCenterWidth') / 2 + points.topLeft = new Point(0, 0) + points.topRight = new Point(neckOpening, 0) + points.neckRight = new Point(neckOpening, (hoodOpening - halfCenterPanel) / 2) + points.neckLeft = new Point(0, points.neckRight.y) + points.frontLeft = points.neckLeft.shift(-90, neckCutoutDelta) + points.frontEdge = points.neckRight.shift(-90, neckCutoutDelta) + points.neckEdge = points.neckLeft.shift(0, halfCenterPanel) + points.neckEdgeCp2 = new Point(points.neckRight.x / 2, points.neckEdge.y) + points.frontEdgeCp1 = new Point(points.neckEdgeCp2.x, points.frontEdge.y) points.shoulderNotch = new Path() .move(points.neckEdge) .curve(points.neckEdgeCp2, points.frontEdgeCp1, points.frontEdge) - .shiftAlong(store.get("neckOpeningLenBack") - halfCenterPanel); - points.hoodTop = new Point(points.shoulderNotch.x, points.topLeft.y); - points.hoodTopCp2 = points.hoodTop.shift(180, points.neckEdge.y * 0.7); - points.hoodRim = new Point(points.frontEdge.x, points.neckRight.y * 0.2); - points.hoodTopCp1 = points.hoodTop.shift( - 0, - points.hoodTop.dx(points.hoodRim) / 2 - ); - points.frontEdgeCp2 = points.frontEdge.shift(90, halfCenterPanel); + .shiftAlong(store.get('neckOpeningLenBack') - halfCenterPanel) + points.hoodTop = new Point(points.shoulderNotch.x, points.topLeft.y) + points.hoodTopCp2 = points.hoodTop.shift(180, points.neckEdge.y * 0.7) + points.hoodRim = new Point(points.frontEdge.x, points.neckRight.y * 0.2) + points.hoodTopCp1 = points.hoodTop.shift(0, points.hoodTop.dx(points.hoodRim) / 2) + points.frontEdgeCp2 = points.frontEdge.shift(90, halfCenterPanel) points._tmp1 = new Path() .move(points.hoodRim) .curve(points.hoodRim, points.hoodTopCp1, points.hoodTop) .shiftAlong(2) - .rotate(90, points.hoodRim); - points.hoodRimCp = points.hoodRim.shiftTowards( - points._tmp1, - points.neckRight.y / 3 - ); - points.neckRoll = points.neckRight.shift(180, halfCenterPanel); + .rotate(90, points.hoodRim) + points.hoodRimCp = points.hoodRim.shiftTowards(points._tmp1, points.neckRight.y / 3) + points.neckRoll = points.neckRight.shift(180, halfCenterPanel) points._tmp2 = new Path() .move(points.neckRoll) .curve(points.neckRoll, points.hoodRimCp, points.hoodRim) - .shiftAlong(2); - points.neckRollCp2 = points.neckRoll.shiftTowards( - points._tmp2, - halfCenterPanel - ); - points.neckRollCp1 = points.neckRollCp2.rotate(180, points.neckRoll); + .shiftAlong(2) + points.neckRollCp2 = points.neckRoll.shiftTowards(points._tmp2, halfCenterPanel) + points.neckRollCp1 = points.neckRollCp2.rotate(180, points.neckRoll) paths.seam = new Path() .move(points.frontEdge) @@ -74,32 +60,32 @@ export default function(part) { .curve(points.hoodTopCp2, points.neckEdge, points.neckEdge) .curve(points.neckEdgeCp2, points.frontEdgeCp1, points.frontEdge) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') // Store length of center seam store.set( - "hoodCenterLength", + 'hoodCenterLength', new Path() .move(points.hoodRim) .curve(points.hoodRim, points.hoodTopCp1, points.hoodTop) .curve(points.hoodTopCp2, points.neckEdge, points.neckEdge) .length() - ); + ) // Complete pattern? if (complete) { if (sa) { // Reversing this curve sidesteps a bezierjs edge case - paths.sa = paths.seam.reverse().offset(sa * -1); + paths.sa = paths.seam.reverse().offset(sa * -1) } - points.title = points.hoodTop.shift(-90, 50); - macro("title", { at: points.title, nr: 6, title: "hoodSide" }); - points.logo = points.title.shift(-90, 60); - snippets.logo = new Snippet("logo", points.logo); - macro("grainline", { + points.title = points.hoodTop.shift(-90, 50) + macro('title', { at: points.title, nr: 6, title: 'hoodSide' }) + points.logo = points.title.shift(-90, 60) + snippets.logo = new Snippet('logo', points.logo) + macro('grainline', { from: points.shoulderNotch, to: points.hoodTop - }); + }) } // Paperless? @@ -107,55 +93,55 @@ export default function(part) { let neckSeam = new Path() .move(points.neckEdge) .curve(points.neckEdgeCp2, points.frontEdgeCp1, points.frontEdge) - .split(points.shoulderNotch); + .split(points.shoulderNotch) let centralSeam = new Path() .move(points.hoodRim) .curve(points.hoodRim, points.hoodTopCp1, points.hoodTop) .curve(points.hoodTopCp2, points.neckEdge, points.neckEdge) - .reverse(); + .reverse() let openingSeam = new Path() .move(points.neckRoll) - .curve(points.neckRollCp2, points.hoodRimCp, points.hoodRim); + .curve(points.neckRollCp2, points.hoodRimCp, points.hoodRim) - macro("pd", { + macro('pd', { path: neckSeam[0], d: sa + 15 - }); - macro("pd", { + }) + macro('pd', { path: neckSeam[1], d: sa + 15 - }); - macro("pd", { + }) + macro('pd', { path: centralSeam, d: sa * -1 - 15 - }); - macro("hd", { + }) + macro('hd', { from: points.neckEdge, to: points.frontEdge, y: points.frontEdge.y + sa + 30 - }); - macro("hd", { - from: centralSeam.edge("left"), + }) + macro('hd', { + from: centralSeam.edge('left'), to: points.frontEdge, y: points.frontEdge.y + sa + 45 - }); - let openingEdge = openingSeam.edge("left"); - macro("hd", { + }) + let openingEdge = openingSeam.edge('left') + macro('hd', { from: openingEdge, to: points.frontEdge, y: openingEdge.y - }); - macro("vd", { + }) + macro('vd', { from: points.frontEdge, to: points.hoodRim, x: points.hoodRim.x + sa + 15 - }); - macro("vd", { + }) + macro('vd', { from: points.frontEdge, to: points.hoodTop, x: points.hoodRim.x + sa + 30 - }); + }) } - return part; + return part } diff --git a/packages/hugo/src/index.js b/packages/hugo/src/index.js index 10cf9dee73d..a3b0b8a109b 100644 --- a/packages/hugo/src/index.js +++ b/packages/hugo/src/index.js @@ -1,45 +1,45 @@ -import freesewing from "@freesewing/core"; -import Brian from "@freesewing/brian"; -import plugins from "@freesewing/plugin-bundle"; -import config from "../config"; +import freesewing from '@freesewing/core' +import Brian from '@freesewing/brian' +import plugins from '@freesewing/plugin-bundle' +import config from '../config' // Parts -import draftBack from "./back"; -import draftFront from "./front"; -import draftSleeve from "./sleeve"; -import draftPocket from "./pocket"; -import draftPocketFacing from "./pocketfacing"; -import draftHoodSide from "./hoodside"; -import draftHoodCenter from "./hoodcenter"; -import draftWaistband from "./waistband"; -import draftCuff from "./cuff"; +import draftBack from './back' +import draftFront from './front' +import draftSleeve from './sleeve' +import draftPocket from './pocket' +import draftPocketFacing from './pocketfacing' +import draftHoodSide from './hoodside' +import draftHoodCenter from './hoodcenter' +import draftWaistband from './waistband' +import draftCuff from './cuff' // Create design -const Pattern = new freesewing.Design(config, plugins); +const Pattern = new freesewing.Design(config, plugins) // Attach draft methods to prototype Pattern.prototype.draftBase = function(part) { - return new Brian(this.settings).draftBase(part); -}; + return new Brian(this.settings).draftBase(part) +} Pattern.prototype.draftFrontBase = function(part) { - return new Brian(this.settings).draftFront(part); -}; + return new Brian(this.settings).draftFront(part) +} Pattern.prototype.draftBackBase = function(part) { - return new Brian(this.settings).draftBack(part); -}; + return new Brian(this.settings).draftBack(part) +} Pattern.prototype.draftSleeveBase = function(part) { - return new Brian(this.settings).draftSleeve(part); -}; + return new Brian(this.settings).draftSleeve(part) +} Pattern.prototype.draftSleevecap = function(part) { - return new Brian(this.settings).draftSleevecap(part); -}; -Pattern.prototype.draftBack = draftBack; -Pattern.prototype.draftFront = draftFront; -Pattern.prototype.draftSleeve = draftSleeve; -Pattern.prototype.draftPocket = draftPocket; -Pattern.prototype.draftPocketFacing = draftPocketFacing; -Pattern.prototype.draftHoodSide = draftHoodSide; -Pattern.prototype.draftHoodCenter = draftHoodCenter; -Pattern.prototype.draftWaistband = draftWaistband; -Pattern.prototype.draftCuff = draftCuff; + return new Brian(this.settings).draftSleevecap(part) +} +Pattern.prototype.draftBack = draftBack +Pattern.prototype.draftFront = draftFront +Pattern.prototype.draftSleeve = draftSleeve +Pattern.prototype.draftPocket = draftPocket +Pattern.prototype.draftPocketFacing = draftPocketFacing +Pattern.prototype.draftHoodSide = draftHoodSide +Pattern.prototype.draftHoodCenter = draftHoodCenter +Pattern.prototype.draftWaistband = draftWaistband +Pattern.prototype.draftCuff = draftCuff -export default Pattern; +export default Pattern diff --git a/packages/hugo/src/pocket.js b/packages/hugo/src/pocket.js index db35b2ed550..379b6b2e0c0 100644 --- a/packages/hugo/src/pocket.js +++ b/packages/hugo/src/pocket.js @@ -1,8 +1,8 @@ export default function(part) { // Remove clutter - let pocket = part.paths.pocket; - part.paths = {}; - part.snippets = {}; + let pocket = part.paths.pocket + part.paths = {} + part.snippets = {} let { utils, @@ -15,69 +15,69 @@ export default function(part) { paperless, macro, debug - } = part.shorthand(); + } = part.shorthand() paths.seam = pocket .line(points.cfRibbing) .line(points.pocketHem) - .attr("class", "fabric", true); + .attr('class', 'fabric', true) - store.set("facingWidth", points.pocketHem.dist(points.pocketTip) / 2); + store.set('facingWidth', points.pocketHem.dist(points.pocketTip) / 2) let facing = new Path() .move(points.pocketTip) .curve(points.pocketTip, points.pocketTopCp, points.pocketTop) - .offset(store.get("facingWidth") * -1); + .offset(store.get('facingWidth') * -1) - points._tmp = facing.shiftAlong(2); + points._tmp = facing.shiftAlong(2) points.facingEnd = utils.beamsIntersect( points._tmp, facing.start(), points.pocketHem, points.pocketTip - ); + ) paths.facing = new Path() .move(points.facingEnd) .line(facing.start()) .join(facing) - .attr("class", " fabric help"); + .attr('class', ' fabric help') // Complete pattern? if (complete) { - macro("grainline", { + macro('grainline', { from: points.cfRibbing.shift(0, 15), to: points.pocketCf.shift(0, 15) - }); - points.title = points.cfRibbing.shiftFractionTowards(points.pocketTop, 0.5); - macro("title", { at: points.title, nr: 4, title: "pocket" }); + }) + points.title = points.cfRibbing.shiftFractionTowards(points.pocketTop, 0.5) + macro('title', { at: points.title, nr: 4, title: 'pocket' }) if (sa) { - paths.sa = paths.seam.offset(sa).attr("class", "fabric sa"); + paths.sa = paths.seam.offset(sa).attr('class', 'fabric sa') } } // Paperless? if (paperless) { - macro("hd", { + macro('hd', { from: points.cfRibbing, to: points.pocketTop, y: points.cfRibbing.y + 15 + sa - }); - macro("hd", { + }) + macro('hd', { from: points.cfRibbing, to: points.pocketTip, y: points.cfRibbing.y + 30 + sa - }); - macro("vd", { + }) + macro('vd', { from: points.pocketHem, to: points.pocketTip, x: points.pocketTip.x + 15 + sa - }); - macro("vd", { + }) + macro('vd', { from: points.pocketHem, to: points.pocketTop, x: points.cfRibbing.x - 15 - sa - }); + }) } - return part; + return part } diff --git a/packages/hugo/src/pocketfacing.js b/packages/hugo/src/pocketfacing.js index c6f79d8f7be..bdd7b050e45 100644 --- a/packages/hugo/src/pocketfacing.js +++ b/packages/hugo/src/pocketfacing.js @@ -1,32 +1,23 @@ export default function(part) { // Remove clutter - let facing = part.paths.facing; - part.paths = {}; + let facing = part.paths.facing + part.paths = {} - let { - sa, - points, - Path, - paths, - complete, - paperless, - macro, - store - } = part.shorthand(); + let { sa, points, Path, paths, complete, paperless, macro, store } = part.shorthand() paths.seam = facing .line(points.pocketTop) .curve(points.pocketTopCp, points.pocketTip, points.pocketTip) .line(points.facingEnd) .close() - .attr("class", "fabric", true); + .attr('class', 'fabric', true) - points.saStart = points.pocketTop.shift(180, store.get("facingWidth")); + points.saStart = points.pocketTop.shift(180, store.get('facingWidth')) // Complete pattern? if (complete) { - points.title = points.pocketTopCp.clone(); - macro("title", { at: points.title, nr: 5, title: "pocketFacing" }); + points.title = points.pocketTopCp.clone() + macro('title', { at: points.title, nr: 5, title: 'pocketFacing' }) if (sa) { paths.sa = new Path() .move(points.saStart) @@ -34,22 +25,22 @@ export default function(part) { .curve(points.pocketTopCp, points.pocketTip, points.pocketTip) .line(points.facingEnd) .offset(sa * -1) - .attr("class", "fabric sa"); + .attr('class', 'fabric sa') paths.sa .line(points.facingEnd) .move(points.saStart) - .line(paths.sa.start()); + .line(paths.sa.start()) } } // Paperless? if (paperless) { - macro("hd", { + macro('hd', { from: points.saStart, to: points.pocketTop, y: points.saStart.y - 15 - sa - }); + }) } - return part; + return part } diff --git a/packages/hugo/src/sleeve.js b/packages/hugo/src/sleeve.js index 963b93b8b2a..4626c30f76f 100644 --- a/packages/hugo/src/sleeve.js +++ b/packages/hugo/src/sleeve.js @@ -15,147 +15,110 @@ export default function(part) { paperless, macro, debug - } = part.shorthand(); + } = part.shorthand() // Top of raglan sleeve - points.raglanTop = new Point( - 0, - points.sleeveTip.y - store.get("shoulderLength") - ); + points.raglanTop = new Point(0, points.sleeveTip.y - store.get('shoulderLength')) // Move and rotate front neck opening part - let anchor = store.get("neckOpeningAnchorFront"); - let neckOpeningFront = store.get("neckOpeningPartFront"); + let anchor = store.get('neckOpeningAnchorFront') + let neckOpeningFront = store.get('neckOpeningPartFront') neckOpeningFront = neckOpeningFront.translate( anchor.dx(points.raglanTop), anchor.dy(points.raglanTop) - ); - let cp2 = neckOpeningFront.ops[1].cp1; - let cp1 = neckOpeningFront.ops[1].cp2; - let to = neckOpeningFront.ops[0].to; - let angle = points.raglanTop.angle(cp1); - points.raglanTopCp2 = cp1.rotate(180 - angle, points.raglanTop); - points.raglanTipFrontCp1 = cp2.rotate(180 - angle, points.raglanTop); - points.raglanTipFront = to.rotate(180 - angle, points.raglanTop); + ) + let cp2 = neckOpeningFront.ops[1].cp1 + let cp1 = neckOpeningFront.ops[1].cp2 + let to = neckOpeningFront.ops[0].to + let angle = points.raglanTop.angle(cp1) + points.raglanTopCp2 = cp1.rotate(180 - angle, points.raglanTop) + points.raglanTipFrontCp1 = cp2.rotate(180 - angle, points.raglanTop) + points.raglanTipFront = to.rotate(180 - angle, points.raglanTop) // Move and rotate back neck opening part - anchor = store.get("neckOpeningAnchorBack"); - let neckOpeningBack = store.get("neckOpeningPartBack"); + anchor = store.get('neckOpeningAnchorBack') + let neckOpeningBack = store.get('neckOpeningPartBack') neckOpeningBack = neckOpeningBack.translate( anchor.dx(points.raglanTop), anchor.dy(points.raglanTop) - ); - cp2 = neckOpeningBack.ops[1].cp1; - cp1 = neckOpeningBack.ops[1].cp2; - to = neckOpeningBack.ops[0].to; - points.raglanTopCp1 = cp1.flipX(); //rotate(180 - angle, points.raglanTop); - points.raglanTipBackCp2 = cp2.flipX(); //rotate(180 - angle, points.raglanTop); - points.raglanTipBack = to.flipX(); //rotate(180 - angle, points.raglanTop); - angle = points.raglanTop.angle(points.raglanTopCp1); - points.raglanTopCp1 = points.raglanTopCp1.rotate( - 360 - angle, - points.raglanTop - ); - points.raglanTipBackCp2 = points.raglanTipBackCp2.rotate( - 360 - angle, - points.raglanTop - ); - points.raglanTipBack = points.raglanTipBack.rotate( - 360 - angle, - points.raglanTop - ); + ) + cp2 = neckOpeningBack.ops[1].cp1 + cp1 = neckOpeningBack.ops[1].cp2 + to = neckOpeningBack.ops[0].to + points.raglanTopCp1 = cp1.flipX() //rotate(180 - angle, points.raglanTop); + points.raglanTipBackCp2 = cp2.flipX() //rotate(180 - angle, points.raglanTop); + points.raglanTipBack = to.flipX() //rotate(180 - angle, points.raglanTop); + angle = points.raglanTop.angle(points.raglanTopCp1) + points.raglanTopCp1 = points.raglanTopCp1.rotate(360 - angle, points.raglanTop) + points.raglanTipBackCp2 = points.raglanTipBackCp2.rotate(360 - angle, points.raglanTop) + points.raglanTipBack = points.raglanTipBack.rotate(360 - angle, points.raglanTop) - let ragDiff = 0; - let runs = 0; + let ragDiff = 0 + let runs = 0 do { // Curve raglan seam to accomodate shoulder slope - points.raglanMidFront = points.raglanTipFront.shiftFractionTowards( - points.capQ4Base, - 0.5 - ); + points.raglanMidFront = points.raglanTipFront.shiftFractionTowards(points.capQ4Base, 0.5) points.raglanMidBack = utils.beamsIntersect( points.raglanTipBack, points.capQ1Base, points.raglanMidFront, points.raglanMidFront.shift(0, 100) - ); - points.raglanFrontCp1 = points.raglanTipFront.shiftFractionTowards( - points.capQ4Base, - 0.25 - ); - points.raglanFrontCp2 = points.raglanTipFront.shiftFractionTowards( - points.capQ4Base, - 0.75 - ); - points.raglanBackCp1 = points.raglanTipBack.shiftFractionTowards( - points.capQ1Base, - 0.8 - ); - points.raglanBackCp2 = points.raglanTipBack.shiftFractionTowards( - points.capQ1Base, - 0.3 - ); - let slope = store.get("shoulderSlopeDeltaY"); - let angleFront = points.raglanTipFront.angle(points.capQ4Base); - let angleBack = points.raglanTipBack.angle(points.capQ1Base); - points.slopeFront = points.raglanMidFront.shift(angleFront + 90, slope / 2); - points.slopeBack = points.raglanMidBack.shift(angleBack - 90, slope / 2); - points.slopeFrontCp1 = points.raglanFrontCp1.shift( - angleFront + 90, - slope / 2 - ); - points.slopeFrontCp2 = points.raglanFrontCp2.shift( - angleFront + 90, - slope / 2 - ); - points.slopeBackCp1 = points.raglanBackCp1.shift(angleBack - 90, slope / 2); - points.slopeBackCp2 = points.raglanBackCp2.shift(angleBack - 90, slope / 2); + ) + points.raglanFrontCp1 = points.raglanTipFront.shiftFractionTowards(points.capQ4Base, 0.25) + points.raglanFrontCp2 = points.raglanTipFront.shiftFractionTowards(points.capQ4Base, 0.75) + points.raglanBackCp1 = points.raglanTipBack.shiftFractionTowards(points.capQ1Base, 0.8) + points.raglanBackCp2 = points.raglanTipBack.shiftFractionTowards(points.capQ1Base, 0.3) + let slope = store.get('shoulderSlopeDeltaY') + let angleFront = points.raglanTipFront.angle(points.capQ4Base) + let angleBack = points.raglanTipBack.angle(points.capQ1Base) + points.slopeFront = points.raglanMidFront.shift(angleFront + 90, slope / 2) + points.slopeBack = points.raglanMidBack.shift(angleBack - 90, slope / 2) + points.slopeFrontCp1 = points.raglanFrontCp1.shift(angleFront + 90, slope / 2) + points.slopeFrontCp2 = points.raglanFrontCp2.shift(angleFront + 90, slope / 2) + points.slopeBackCp1 = points.raglanBackCp1.shift(angleBack - 90, slope / 2) + points.slopeBackCp2 = points.raglanBackCp2.shift(angleBack - 90, slope / 2) points.capQ4BaseCp = utils.beamsIntersect( points.slopeFrontCp2, points.capQ4Base, points.bicepsLeft, points.capQ4Cp2 - ); + ) points.capQ1BaseCp = utils.beamsIntersect( points.slopeBackCp1, points.capQ1Base, points.bicepsRight, points.capQ1Cp2 - ); + ) // Now make sure the length matches the front raglan seam let raglen = new Path() .move(points.raglanTipBack) .curve(points.raglanTipBackCp2, points.raglanTopCp1, points.raglanTop) - .curve( - points.raglanTopCp2, - points.raglanTipFrontCp1, - points.raglanTipFront - ) + .curve(points.raglanTopCp2, points.raglanTipFrontCp1, points.raglanTipFront) .curve(points.raglanTipFront, points.slopeFrontCp1, points.slopeFront) .curve(points.slopeFrontCp2, points.capQ4Base, points.capQ4Base) - .length(); - ragDiff = store.get("raglen") - raglen; + .length() + ragDiff = store.get('raglen') - raglen let tipPoints = [ - "raglanTipFront", - "raglanTipFrontCp1", - "raglanTopCp2", - "raglanTop", - "raglanTopCp1", - "raglanTipBackCp2", - "raglanTipBack" - ]; - for (let pid of tipPoints) points[pid] = points[pid].shift(90, ragDiff); + 'raglanTipFront', + 'raglanTipFrontCp1', + 'raglanTopCp2', + 'raglanTop', + 'raglanTopCp1', + 'raglanTipBackCp2', + 'raglanTipBack' + ] + for (let pid of tipPoints) points[pid] = points[pid].shift(90, ragDiff) // Fix sleeve length let lenTotal = - store.get("shoulderLength") + + store.get('shoulderLength') + measurements.shoulderToWrist * (1 + options.sleeveLengthBonus) - - options.ribbingHeight; - let lenDelta = points.raglanTop.dist(points.centerWrist) - lenTotal; - let wristPoints = ["wristLeft", "centerWrist", "wristRight"]; - for (let pid of wristPoints) points[pid] = points[pid].shift(90, lenDelta); - runs++; - } while (Math.abs(ragDiff) > 5 && runs < 10); + options.ribbingHeight + let lenDelta = points.raglanTop.dist(points.centerWrist) - lenTotal + let wristPoints = ['wristLeft', 'centerWrist', 'wristRight'] + for (let pid of wristPoints) points[pid] = points[pid].shift(90, lenDelta) + runs++ + } while (Math.abs(ragDiff) > 5 && runs < 10) paths.seam = new Path() .move(points.raglanTipBack) @@ -169,87 +132,87 @@ export default function(part) { .curve(points.capQ1Cp1, points.slopeBackCp1, points.slopeBack) .curve(points.slopeBackCp2, points.raglanTipBack, points.raglanTipBack) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') // Complete pattern? if (complete) { - macro("grainline", { + macro('grainline', { from: points.centerWrist, to: points.raglanTop - }); + }) //points.title = new Point(points.armhole.x/2, points.armhole.y); - macro("title", { at: points.gridAnchor, nr: 3, title: "sleeve" }); + macro('title', { at: points.gridAnchor, nr: 3, title: 'sleeve' }) //points.sleeveNotch = points.raglanTipFront.shiftFractionTowards(points.armholeHollow, 0.5); //snippets.sleeveNotch = new Snippet("notch", points.sleeveNotch); //store.set('frontRaglanTipToNotch', points.raglanTipFront.dist(points.sleeveNotch)); - points.logo = points.gridAnchor.shift(-90, 70); - snippets.logo = new Snippet("logo", points.logo); - points.scalebox = points.logo.shift(-90, 70); - macro("scalebox", { at: points.scalebox }); + points.logo = points.gridAnchor.shift(-90, 70) + snippets.logo = new Snippet('logo', points.logo) + points.scalebox = points.logo.shift(-90, 70) + macro('scalebox', { at: points.scalebox }) points.frontNotch = new Path() .move(points.raglanTipFront) .curve(points.raglanTipFront, points.slopeFrontCp1, points.slopeFront) .curve(points.slopeFrontCp2, points.capQ4Cp2, points.bicepsLeft) - .shiftAlong(store.get("notchFront")); - snippets.frontNotch = new Snippet("notch", points.frontNotch); + .shiftAlong(store.get('notchFront')) + snippets.frontNotch = new Snippet('notch', points.frontNotch) points.backNotch = new Path() .move(points.raglanTipBack) .curve(points.raglanTipBack, points.slopeBackCp2, points.slopeBack) .curve(points.slopeBackCp1, points.capQ1Cp1, points.bicepsRight) - .shiftAlong(store.get("notchBack")); - snippets.backNotch = new Snippet("bnotch", points.backNotch); + .shiftAlong(store.get('notchBack')) + snippets.backNotch = new Snippet('bnotch', points.backNotch) if (sa) { - paths.sa = paths.seam.offset(sa).attr("class", "fabric sa"); + paths.sa = paths.seam.offset(sa).attr('class', 'fabric sa') } } // Paperless? if (paperless) { - macro("vd", { + macro('vd', { from: points.wristLeft, to: points.bicepsLeft, x: points.bicepsLeft.x - 15 - sa - }); - macro("vd", { + }) + macro('vd', { from: points.bicepsLeft, to: points.raglanTipFront, x: points.bicepsLeft.x - 15 - sa - }); - macro("vd", { + }) + macro('vd', { from: points.bicepsRight, to: points.raglanTop, x: points.bicepsRight.x + 15 + sa - }); - macro("vd", { + }) + macro('vd', { from: points.bicepsRight, to: points.raglanTipBack, x: points.bicepsRight.x + 30 + sa - }); - macro("hd", { + }) + macro('hd', { from: points.raglanTipFront, to: points.raglanTop, y: points.raglanTipBack.y - 15 - sa - }); - macro("hd", { + }) + macro('hd', { from: points.raglanTop, to: points.raglanTipBack, y: points.raglanTipBack.y - 15 - sa - }); - macro("hd", { + }) + macro('hd', { from: points.bicepsLeft, to: points.raglanTop, y: points.raglanTipBack.y - 30 - sa - }); - macro("hd", { + }) + macro('hd', { from: points.bicepsLeft, to: points.bicepsRight, y: points.raglanTipBack.y - 45 - sa - }); - macro("hd", { + }) + macro('hd', { from: points.wristLeft, to: points.wristRight, y: points.wristLeft.y + 15 + sa - }); + }) } - return part; + return part } diff --git a/packages/hugo/src/waistband.js b/packages/hugo/src/waistband.js index ec9ee25dd4d..7dbdf3c9499 100644 --- a/packages/hugo/src/waistband.js +++ b/packages/hugo/src/waistband.js @@ -11,21 +11,21 @@ export default function(part) { paperless, macro, units - } = part.shorthand(); + } = part.shorthand() let width = (measurements.centerBackNeckToWaist + measurements.naturalWaistToHip) * options.ribbingHeight * - 2; + 2 - points.topLeft = new Point(0, 0); - points.bottomLeft = new Point(0, width); - points.topMidLeft = new Point(width, 0); - points.bottomMidLeft = new Point(width, width); - points.topMidRight = new Point(width * 1.5, 0); - points.bottomMidRight = new Point(width * 1.5, width); - points.topRight = new Point(width * 2.5, 0); - points.bottomRight = new Point(width * 2.5, width); + points.topLeft = new Point(0, 0) + points.bottomLeft = new Point(0, width) + points.topMidLeft = new Point(width, 0) + points.bottomMidLeft = new Point(width, width) + points.topMidRight = new Point(width * 1.5, 0) + points.bottomMidRight = new Point(width * 1.5, width) + points.topRight = new Point(width * 2.5, 0) + points.bottomRight = new Point(width * 2.5, width) paths.seam = new Path() .move(points.topMidLeft) @@ -36,45 +36,43 @@ export default function(part) { .line(points.bottomRight) .line(points.topRight) .line(points.topMidRight) - .attr("class", "fabric"); + .attr('class', 'fabric') paths.hint = new Path() .move(points.topMidLeft) .line(points.topMidRight) .move(points.bottomMidLeft) .line(points.bottomMidRight) - .attr("class", "fabric dashed"); + .attr('class', 'fabric dashed') // Complete pattern? if (complete) { if (sa) { - paths.sa = paths.seam.offset(sa); + paths.sa = paths.seam.offset(sa) } - points.title = points.bottomLeft.shiftFractionTowards(points.topRight, 0.5); - macro("title", { at: points.title, nr: 8, title: "waistband" }); - macro("grainline", { + points.title = points.bottomLeft.shiftFractionTowards(points.topRight, 0.5) + macro('title', { at: points.title, nr: 8, title: 'waistband' }) + macro('grainline', { from: points.bottomMidLeft, to: points.topMidLeft - }); + }) } // Paperless? if (paperless) { - macro("vd", { + macro('vd', { from: points.bottomRight, to: points.topRight, x: points.topRight.x + sa + 15 - }); - macro("hd", { + }) + macro('hd', { from: points.bottomLeft, to: points.bottomRight, y: points.bottomRight.y + sa + 15, text: units( - measurements.chestCircumference * - (1 + options.chestEase) * - (1 - options.ribbingStretch) + measurements.chestCircumference * (1 + options.chestEase) * (1 - options.ribbingStretch) ) - }); + }) } - return part; + return part } diff --git a/packages/i18n/src/index.js b/packages/i18n/src/index.js index 94b687d7655..c4567116ce9 100644 --- a/packages/i18n/src/index.js +++ b/packages/i18n/src/index.js @@ -1,18 +1,18 @@ -import en from "./locales/en"; -import de from "./locales/de"; -import es from "./locales/es"; -import fr from "./locales/fr"; -import nl from "./locales/nl"; +import en from './locales/en' +import de from './locales/de' +import es from './locales/es' +import fr from './locales/fr' +import nl from './locales/nl' -const languageCodes = ["en", "de", "es", "fr", "nl"]; -const imports = { en, de, es, fr, nl }; +const languageCodes = ['en', 'de', 'es', 'fr', 'nl'] +const imports = { en, de, es, fr, nl } -const strings = {}; -const languages = {}; +const strings = {} +const languages = {} for (let l of languageCodes) { - strings[l] = imports[l]; - languages[l] = strings[l]["i18n." + l]; + strings[l] = imports[l] + languages[l] = strings[l]['i18n.' + l] } -export { strings, languages }; +export { strings, languages } diff --git a/packages/jaeger/example/src/App.js b/packages/jaeger/example/src/App.js index e7936330e5d..115cdf683af 100644 --- a/packages/jaeger/example/src/App.js +++ b/packages/jaeger/example/src/App.js @@ -1,22 +1,15 @@ -import React from "react"; -import freesewing from "@freesewing/core"; -import Workbench from "@freesewing/components/Workbench"; -import "typeface-roboto-condensed"; -import "@freesewing/css-theme"; +import React from 'react' +import freesewing from '@freesewing/core' +import Workbench from '@freesewing/components/Workbench' +import 'typeface-roboto-condensed' +import '@freesewing/css-theme' -import Pattern from "pattern"; +import Pattern from 'pattern' const App = props => { - let instance = new Pattern(); - let config = instance.config; - return ( - - ); -}; + let instance = new Pattern() + let config = instance.config + return +} -export default App; +export default App diff --git a/packages/jaeger/example/src/index.js b/packages/jaeger/example/src/index.js index 7900787a4d2..9dd7ba788d4 100644 --- a/packages/jaeger/example/src/index.js +++ b/packages/jaeger/example/src/index.js @@ -1,11 +1,11 @@ -import React from "react"; -import ReactDOM from "react-dom"; -import App from "./App"; -import * as serviceWorker from "./serviceWorker"; +import React from 'react' +import ReactDOM from 'react-dom' +import App from './App' +import * as serviceWorker from './serviceWorker' -ReactDOM.render(, document.getElementById("root")); +ReactDOM.render(, document.getElementById('root')) // If you want your app to work offline and load faster, you can change // unregister() to register() below. Note this comes with some pitfalls. // Learn more about service workers: http://bit.ly/CRA-PWA -serviceWorker.unregister(); +serviceWorker.unregister() diff --git a/packages/jaeger/example/src/serviceWorker.js b/packages/jaeger/example/src/serviceWorker.js index 68fda5a0eb6..44e1b1b2f8c 100644 --- a/packages/jaeger/example/src/serviceWorker.js +++ b/packages/jaeger/example/src/serviceWorker.js @@ -9,46 +9,44 @@ // This link also includes instructions on opting out of this behavior. const isLocalhost = Boolean( - window.location.hostname === "localhost" || + window.location.hostname === 'localhost' || // [::1] is the IPv6 localhost address. - window.location.hostname === "[::1]" || + window.location.hostname === '[::1]' || // 127.0.0.1/8 is considered localhost for IPv4. - window.location.hostname.match( - /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ - ) -); + window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/) +) export function register(config) { - if (process.env.NODE_ENV === "production" && "serviceWorker" in navigator) { + if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) { // The URL constructor is available in all browsers that support SW. - const publicUrl = new URL(process.env.PUBLIC_URL, window.location); + const publicUrl = new URL(process.env.PUBLIC_URL, window.location) if (publicUrl.origin !== window.location.origin) { // Our service worker won't work if PUBLIC_URL is on a different origin // from what our page is served on. This might happen if a CDN is used to // serve assets; see https://github.com/facebook/create-react-app/issues/2374 - return; + return } - window.addEventListener("load", () => { - const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; + window.addEventListener('load', () => { + const swUrl = `${process.env.PUBLIC_URL}/service-worker.js` if (isLocalhost) { // This is running on localhost. Let's check if a service worker still exists or not. - checkValidServiceWorker(swUrl, config); + checkValidServiceWorker(swUrl, config) // Add some additional logging to localhost, pointing developers to the // service worker/PWA documentation. navigator.serviceWorker.ready.then(() => { console.log( - "This web app is being served cache-first by a service " + - "worker. To learn more, visit https://goo.gl/SC7cgQ" - ); - }); + 'This web app is being served cache-first by a service ' + + 'worker. To learn more, visit https://goo.gl/SC7cgQ' + ) + }) } else { // Is not local host. Just register service worker - registerValidSW(swUrl, config); + registerValidSW(swUrl, config) } - }); + }) } } @@ -57,38 +55,38 @@ function registerValidSW(swUrl, config) { .register(swUrl) .then(registration => { registration.onupdatefound = () => { - const installingWorker = registration.installing; + const installingWorker = registration.installing installingWorker.onstatechange = () => { - if (installingWorker.state === "installed") { + if (installingWorker.state === 'installed') { if (navigator.serviceWorker.controller) { // At this point, the old content will have been purged and // the fresh content will have been added to the cache. // It's the perfect time to display a "New content is // available; please refresh." message in your web app. - console.log("New content is available; please refresh."); + console.log('New content is available; please refresh.') // Execute callback if (config.onUpdate) { - config.onUpdate(registration); + config.onUpdate(registration) } } else { // At this point, everything has been precached. // It's the perfect time to display a // "Content is cached for offline use." message. - console.log("Content is cached for offline use."); + console.log('Content is cached for offline use.') // Execute callback if (config.onSuccess) { - config.onSuccess(registration); + config.onSuccess(registration) } } } - }; - }; + } + } }) .catch(error => { - console.error("Error during service worker registration:", error); - }); + console.error('Error during service worker registration:', error) + }) } function checkValidServiceWorker(swUrl, config) { @@ -98,30 +96,28 @@ function checkValidServiceWorker(swUrl, config) { // Ensure service worker exists, and that we really are getting a JS file. if ( response.status === 404 || - response.headers.get("content-type").indexOf("javascript") === -1 + response.headers.get('content-type').indexOf('javascript') === -1 ) { // No service worker found. Probably a different app. Reload the page. navigator.serviceWorker.ready.then(registration => { registration.unregister().then(() => { - window.location.reload(); - }); - }); + window.location.reload() + }) + }) } else { // Service worker found. Proceed as normal. - registerValidSW(swUrl, config); + registerValidSW(swUrl, config) } }) .catch(() => { - console.log( - "No internet connection found. App is running in offline mode." - ); - }); + console.log('No internet connection found. App is running in offline mode.') + }) } export function unregister() { - if ("serviceWorker" in navigator) { + if ('serviceWorker' in navigator) { navigator.serviceWorker.ready.then(registration => { - registration.unregister(); - }); + registration.unregister() + }) } } diff --git a/packages/jaeger/src/back.js b/packages/jaeger/src/back.js index 4b11d9d6e73..8d237bc3d5d 100644 --- a/packages/jaeger/src/back.js +++ b/packages/jaeger/src/back.js @@ -1,9 +1,25 @@ export default function(part) { - let { paperless, sa, snippets, Snippet, utils, store, complete, points, measurements, options, macro, Point, paths, Path } = part.shorthand(); + let { + paperless, + sa, + snippets, + Snippet, + utils, + store, + complete, + points, + measurements, + options, + macro, + Point, + paths, + Path + } = part.shorthand() // Back vent(s) - let ventY = points.cbHips.y - points.cbWaistCp2.dy(points.cbHips) * options.backVentLength; - if (options.backVent === 1) { // Single back vent + let ventY = points.cbHips.y - points.cbWaistCp2.dy(points.cbHips) * options.backVentLength + if (options.backVent === 1) { + // Single back vent // Vent tip points.ventStart = utils.curveIntersectsY( points.cbHips, @@ -11,15 +27,15 @@ export default function(part) { points.cbWaistCp2, points.cbWaist, ventY - ); + ) paths.ventBase = new Path() .move(points.cbWaist) .curve(points.cbWaistCp2, points.cbHipsCp1, points.cbHips) .split(points.ventStart) .pop() - .line(points.cbHem); - paths.vent = paths.ventBase.offset(measurements.neckCircumference / 10); - paths.vent.render = false; + .line(points.cbHem) + paths.vent = paths.ventBase.offset(measurements.neckCircumference / 10) + paths.vent.render = false points.ventSlopeStart = utils.lineIntersectsCurve( paths.vent.start(), paths.vent.start().shift(10, measurements.neckCircumference / 5), @@ -27,8 +43,9 @@ export default function(part) { points.cbHipsCp1, points.cbWaistCp2, points.cbWaist - ); - } else if (options.backVent === 2) { // Double back vent + ) + } else if (options.backVent === 2) { + // Double back vent // Vent tip points.ventStart = utils.curveIntersectsY( points.hips, @@ -36,15 +53,15 @@ export default function(part) { points.waistCp1, points.waist, ventY - ); + ) paths.ventBase = new Path() .move(points.waist) .curve(points.waistCp1, points.hipsCp2, points.hips) .split(points.ventStart) .pop() - .line(points.hem); - paths.vent = paths.ventBase.offset(measurements.neckCircumference / -10); - paths.vent.render = false; + .line(points.hem) + paths.vent = paths.ventBase.offset(measurements.neckCircumference / -10) + paths.vent.render = false points.ventSlopeStart = utils.lineIntersectsCurve( paths.vent.start(), paths.vent.start().shift(170, measurements.neckCircumference / 5), @@ -52,16 +69,15 @@ export default function(part) { points.hipsCp2, points.waistCp1, points.waist - ); + ) } // Store shoulder slope - store.set("shoulderSlope", Math.abs(points.neck.angle(points.shoulder)-360)); + store.set('shoulderSlope', Math.abs(points.neck.angle(points.shoulder) - 360)) // Clean up - Remove this to understand what's going on - for (let i of Object.keys(paths)) - if(i !== "vent") delete paths[i]; - for (let i of Object.keys(snippets)) delete snippets[i]; + for (let i of Object.keys(paths)) if (i !== 'vent') delete paths[i] + for (let i of Object.keys(snippets)) delete snippets[i] // Paths if (options.backVent === 2) { @@ -69,13 +85,14 @@ export default function(part) { .clone() .reverse() .line(points.ventSlopeStart) - .join(new Path() - .move(points.hips) - .curve(points.hipsCp2, points.waistCp1, points.waist) - .split(points.ventSlopeStart) - .pop() + .join( + new Path() + .move(points.hips) + .curve(points.hipsCp2, points.waistCp1, points.waist) + .split(points.ventSlopeStart) + .pop() ) - paths.saBase.render = true; + paths.saBase.render = true } else { paths.saBase = new Path() .move(points.hem) @@ -87,10 +104,11 @@ export default function(part) { .curve(points.armholeHollowCp2, points.armholePitchCp1, points.armholePitch) .curve(points.armholePitchCp2, points.shoulderCp1, points.shoulder) .line(points.neck) - .curve_(points.neckCp2, points.cbNeck); - if (options.centerBackDart > 0) paths.saBase = paths.saBase._curve(points.cbChestCp1, points.cbChest); - else paths.saBase = paths.saBase.line(points.cbChest); - paths.saBase = paths.saBase.curve(points.cbChestCp2, points.cbWaistCp1, points.cbWaist); + .curve_(points.neckCp2, points.cbNeck) + if (options.centerBackDart > 0) + paths.saBase = paths.saBase._curve(points.cbChestCp1, points.cbChest) + else paths.saBase = paths.saBase.line(points.cbChest) + paths.saBase = paths.saBase.curve(points.cbChestCp2, points.cbWaistCp1, points.cbWaist) if (options.backVent === 1) { paths.saBase = paths.saBase .join( @@ -104,153 +122,143 @@ export default function(part) { .line(paths.vent.start()) .join(paths.vent) } else { - paths.saBase - .curve(points.cbWaistCp2, points.cbHipsCp1, points.cbHips) - .line(points.cbHem); + paths.saBase.curve(points.cbWaistCp2, points.cbHipsCp1, points.cbHips).line(points.cbHem) } - paths.saBase.render = false; + paths.saBase.render = false - if (options.backVent === 2) paths.hemBase = new Path().move(points.cbHem).line(paths.vent.end()); - else if (options.backVent === 1) paths.hemBase = new Path().move(paths.vent.end()).line(points.hem); - else paths.hemBase = new Path().move(points.cbHem).line(points.hem); - paths.hemBase.render = false; + if (options.backVent === 2) paths.hemBase = new Path().move(points.cbHem).line(paths.vent.end()) + else if (options.backVent === 1) + paths.hemBase = new Path().move(paths.vent.end()).line(points.hem) + else paths.hemBase = new Path().move(points.cbHem).line(points.hem) + paths.hemBase.render = false - paths.seam = paths.saBase.join(paths.hemBase).attr("class", "fabric"); + paths.seam = paths.saBase.join(paths.hemBase).attr('class', 'fabric') if (complete) { // Logo - points.logo = new Point( - points.title.x, - points.armholeHollow.y - ); - snippets.logo = new Snippet("logo", points.logo); + points.logo = new Point(points.title.x, points.armholeHollow.y) + snippets.logo = new Snippet('logo', points.logo) // Notches - macro("sprinkle", { - snippet: "notch", - on: [ - "neck", - "shoulder", - "armholePitch", - "cbWaist", - "waist" - ] - }); + macro('sprinkle', { + snippet: 'notch', + on: ['neck', 'shoulder', 'armholePitch', 'cbWaist', 'waist'] + }) // Grainline - macro("grainline", { + macro('grainline', { from: new Point(points.neck.x, points.hips.y), to: points.neck - }); + }) if (sa) { paths.sa = paths.saBase .offset(sa) .join(paths.hemBase.offset(sa * 3)) .close() - .attr("class", "fabric sa"); + .attr('class', 'fabric sa') } if (paperless) { - macro("hd", { + macro('hd', { from: points.cbNeck, to: points.neck, - y: points.neck.y - 15 -sa - }); - macro("hd", { + y: points.neck.y - 15 - sa + }) + macro('hd', { from: points.cbChest, to: points.neck, - y: points.neck.y - 30 -sa - }); - macro("hd", { + y: points.neck.y - 30 - sa + }) + macro('hd', { from: points.cbChest, to: points.armholePitch, - y: points.neck.y - 45 -sa - }); - macro("hd", { + y: points.neck.y - 45 - sa + }) + macro('hd', { from: points.cbChest, to: points.shoulder, - y: points.neck.y - 60 -sa - }); - macro("hd", { + y: points.neck.y - 60 - sa + }) + macro('hd', { from: points.cbChest, to: points.bsArmholeHollow, - y: points.neck.y - 75 -sa - }); - macro("vd", { + y: points.neck.y - 75 - sa + }) + macro('vd', { from: points.bsArmholeHollow, to: points.armholePitch, - x: points.bsArmholeHollow.x + sa + 15, - }); - macro("vd", { + x: points.bsArmholeHollow.x + sa + 15 + }) + macro('vd', { from: points.bsArmholeHollow, to: points.shoulder, - x: points.bsArmholeHollow.x + sa + 30, - }); - macro("vd", { + x: points.bsArmholeHollow.x + sa + 30 + }) + macro('vd', { from: points.hem, to: points.hips, - x: points.hem.x + sa + 15, - }); - macro("vd", { + x: points.hem.x + sa + 15 + }) + macro('vd', { from: points.hem, to: points.waist, - x: points.hem.x + sa + 30, - }); - macro("vd", { + x: points.hem.x + sa + 30 + }) + macro('vd', { from: points.hem, to: points.bsArmholeHollow, - x: points.hem.x + sa + 45, - }); - macro("hd", { + x: points.hem.x + sa + 45 + }) + macro('hd', { from: paths.vent.start(), to: points.ventSlopeStart, - y: points.ventSlopeStart.y + 25, - }); - macro("hd", { + y: points.ventSlopeStart.y + 25 + }) + macro('hd', { from: paths.vent.end(), to: points.hem, - y: points.hem.y + 3*sa + 15, - }); - macro("vd", { + y: points.hem.y + 3 * sa + 15 + }) + macro('vd', { from: paths.vent.end(), to: paths.vent.start(), - x: paths.vent.end().x - sa - 15, - }); - macro("vd", { + x: paths.vent.end().x - sa - 15 + }) + macro('vd', { from: paths.vent.end(), to: points.ventSlopeStart, - x: paths.vent.end().x - sa - 30, - }); - macro("vd", { + x: paths.vent.end().x - sa - 30 + }) + macro('vd', { from: paths.vent.end(), to: points.cbWaist, - x: paths.vent.end().x - sa - 45, - }); - macro("vd", { + x: paths.vent.end().x - sa - 45 + }) + macro('vd', { from: paths.vent.end(), to: points.cbChest, - x: paths.vent.end().x - sa - 60, - }); - macro("vd", { + x: paths.vent.end().x - sa - 60 + }) + macro('vd', { from: paths.vent.end(), to: points.cbNeck, - x: paths.vent.end().x - sa - 75, - }); - macro("vd", { + x: paths.vent.end().x - sa - 75 + }) + macro('vd', { from: paths.vent.end(), to: points.neck, - x: paths.vent.end().x - sa - 90, - }); - macro("ld", { + x: paths.vent.end().x - sa - 90 + }) + macro('ld', { from: points.cbWaist, to: points.waist - }); - macro("ld", { + }) + macro('ld', { from: points.neck, to: points.shoulder, d: -15 - }); + }) } } - return part; + return part } diff --git a/packages/jaeger/src/backbase.js b/packages/jaeger/src/backbase.js index 114cb380f93..8fa8df7c073 100644 --- a/packages/jaeger/src/backbase.js +++ b/packages/jaeger/src/backbase.js @@ -1,65 +1,81 @@ -import { calculateRatios, backSideBoundary } from "./shared"; +import { calculateRatios, backSideBoundary } from './shared' export default function(part) { - calculateRatios(part); - let { store, points, measurements, options, Point, paths, Path } = part.shorthand(); + calculateRatios(part) + let { store, points, measurements, options, Point, paths, Path } = part.shorthand() /** * Shaping the back seam */ - points.cbChest = new Point(0, points.armholePitchCp1.y); + points.cbChest = new Point(0, points.armholePitchCp1.y) if (options.centerBackDart > 0) { - points.cbChestCp1 = points.cbChest.shiftFractionTowards(points.cbNeck, 0.5); - points.cbNeck = points.cbNeck.shift(0, measurements.chestCircumference * options.centerBackDart); + points.cbChestCp1 = points.cbChest.shiftFractionTowards(points.cbNeck, 0.5) + points.cbNeck = points.cbNeck.shift(0, measurements.chestCircumference * options.centerBackDart) } - points.cbChestCp2 = points.cbChest.shift(-90, points.cbChest.dy(points.cbWaist)/3); - points.cbWaist = points.cbWaist.shift(0, store.get("waistReduction") * options.reduceWaistStandardFraction); - points.cbWaistCp1 = points.cbWaist.shift(90, points.cbChest.dy(points.cbWaist)/3); - points.cbHips = points.cbHips.shift(0, store.get("hipsReduction") * options.reduceHipsStandardFraction); - points.cbHem = points.cbHem.shift(0, store.get("hipsReduction") * options.reduceHipsStandardFraction); - points.cbWaistCp2 = points.cbWaist.shift(-90, points.cbWaist.dy(points.cbHips)/3); - points.cbHipsCp1 = points.cbHips.shift(90, points.cbWaist.dy(points.cbHips)/3); + points.cbChestCp2 = points.cbChest.shift(-90, points.cbChest.dy(points.cbWaist) / 3) + points.cbWaist = points.cbWaist.shift( + 0, + store.get('waistReduction') * options.reduceWaistStandardFraction + ) + points.cbWaistCp1 = points.cbWaist.shift(90, points.cbChest.dy(points.cbWaist) / 3) + points.cbHips = points.cbHips.shift( + 0, + store.get('hipsReduction') * options.reduceHipsStandardFraction + ) + points.cbHem = points.cbHem.shift( + 0, + store.get('hipsReduction') * options.reduceHipsStandardFraction + ) + points.cbWaistCp2 = points.cbWaist.shift(-90, points.cbWaist.dy(points.cbHips) / 3) + points.cbHipsCp1 = points.cbHips.shift(90, points.cbWaist.dy(points.cbHips) / 3) /** * Shaping the side seam */ - backSideBoundary(part); + backSideBoundary(part) // Divide reduction by 4: two side panels x two sides per panel = 4 - points.waist = points.bsWaist.shift(180, store.get("waistReduction") * options.reduceWaistStandardFraction); - points.waistCp2 = points.waist.shift(90, points.cbChest.dy(points.waist)/3); - points.hips = points.bsHips.shift(180, store.get("hipsReduction") * options.reduceHipsStandardFraction); - points.waistCp1 = points.waist.shift(-90, points.waist.dy(points.hips)/3); - points.hipsCp2 = points.hips.shift(90, points.waist.dy(points.hips)/3); - points.hem = new Point(points.hips.x, points.hem.y); + points.waist = points.bsWaist.shift( + 180, + store.get('waistReduction') * options.reduceWaistStandardFraction + ) + points.waistCp2 = points.waist.shift(90, points.cbChest.dy(points.waist) / 3) + points.hips = points.bsHips.shift( + 180, + store.get('hipsReduction') * options.reduceHipsStandardFraction + ) + points.waistCp1 = points.waist.shift(-90, points.waist.dy(points.hips) / 3) + points.hipsCp2 = points.hips.shift(90, points.waist.dy(points.hips) / 3) + points.hem = new Point(points.hips.x, points.hem.y) // Store length of back collar - store.set("backCollarLength", new Path() - .move(points.cbNeck) - ._curve(points.neckCp2, points.neck) - .length() - ); + store.set( + 'backCollarLength', + new Path() + .move(points.cbNeck) + ._curve(points.neckCp2, points.neck) + .length() + ) // Paths - paths.cb = new Path().move(points.cbNeck); - if (options.centerBackDart > 0) - paths.cb._curve(points.cbChestCp1, points.cbChest); - else paths.cb.line(points.cbChest); + paths.cb = new Path().move(points.cbNeck) + if (options.centerBackDart > 0) paths.cb._curve(points.cbChestCp1, points.cbChest) + else paths.cb.line(points.cbChest) paths.cb .curve(points.cbChestCp2, points.cbWaistCp1, points.cbWaist) .curve(points.cbWaistCp2, points.cbHipsCp1, points.cbHips) .line(points.cbHem) - .attr("class", "stroke-xl lining") + .attr('class', 'stroke-xl lining') paths.bss = new Path() .move(points.armholeHollow) .curve(points.bsArmholeHollowCp2, points.waistCp2, points.waist) .curve(points.waistCp1, points.hipsCp2, points.hips) .line(points.hem) - .attr("class", "stroke-xl lining") + .attr('class', 'stroke-xl lining') - return part; + return part } diff --git a/packages/jaeger/src/chestpocketbag.js b/packages/jaeger/src/chestpocketbag.js index f686d0aec2a..4018722e3ff 100644 --- a/packages/jaeger/src/chestpocketbag.js +++ b/packages/jaeger/src/chestpocketbag.js @@ -1,17 +1,28 @@ export default function(part) { - let { paperless, sa, store, complete, points, options, macro, Point, paths, Path } = part.shorthand(); + let { + paperless, + sa, + store, + complete, + points, + options, + macro, + Point, + paths, + Path + } = part.shorthand() - let width = store.get("chestPocketWidth"); - let welt = store.get("chestPocketWeltHeight"); - let height = width * options.chestPocketDepth; - let angle = options.chestPocketAngle; + let width = store.get('chestPocketWidth') + let welt = store.get('chestPocketWeltHeight') + let height = width * options.chestPocketDepth + let angle = options.chestPocketAngle - points.topLeft = new Point(0, 0); - points.topRight = points.topLeft.shift(angle, width); - points.foldLeft = points.topLeft.shift(-90, height); - points.foldRight = new Point(points.topRight.x, points.foldLeft.y); - points.bottomLeft = points.topLeft.shift(-90, height*2 + welt); - points.bottomRight = points.bottomLeft.shift(-1 * angle, width); + points.topLeft = new Point(0, 0) + points.topRight = points.topLeft.shift(angle, width) + points.foldLeft = points.topLeft.shift(-90, height) + points.foldRight = new Point(points.topRight.x, points.foldLeft.y) + points.bottomLeft = points.topLeft.shift(-90, height * 2 + welt) + points.bottomRight = points.bottomLeft.shift(-1 * angle, width) // Paths paths.seam = new Path() @@ -21,68 +32,66 @@ export default function(part) { .line(points.topRight) .line(points.topLeft) .close() - .attr("class", "lining"); + .attr('class', 'lining') paths.fold = new Path() .move(points.foldLeft) .line(points.foldRight) - .attr("class", "stroke-sm dashed lining"); + .attr('class', 'stroke-sm dashed lining') if (complete) { points.title = points.topLeft.shiftFractionTowards(points.foldRight, 0.5) // Title - macro("title", { + macro('title', { at: points.title, nr: 12, - title: "chestPocketBag" - }); + title: 'chestPocketBag' + }) // Grainline - macro("grainline", { + macro('grainline', { from: points.bottomLeft.shift(0, 10), to: points.topLeft.shift(0, 10) - }); + }) // Instructions - paths.fold - .attr("data-text", "foldAlongThisLine") - .attr("data-text-class", "center"); + paths.fold.attr('data-text', 'foldAlongThisLine').attr('data-text-class', 'center') - if (sa) paths.sa = paths.seam.offset(sa).attr("class", "lining sa"); + if (sa) paths.sa = paths.seam.offset(sa).attr('class', 'lining sa') if (paperless) { - macro("hd", { + macro('hd', { from: points.topLeft, to: points.topRight, y: points.topRight.y - sa - 15 - }); - macro("vd", { + }) + macro('vd', { from: points.bottomRight, to: points.foldRight, x: points.topRight.x + sa + 15 - }); - macro("vd", { + }) + macro('vd', { from: points.foldRight, to: points.topRight, x: points.topRight.x + sa + 15 - }); - macro("vd", { + }) + macro('vd', { from: points.bottomRight, to: points.topRight, x: points.topRight.x + sa + 30 - }); - macro("vd", { + }) + macro('vd', { from: points.bottomLeft, to: points.foldLeft, x: points.topLeft.x - sa - 15 - }); - macro("vd", { + }) + macro('vd', { from: points.foldLeft, to: points.topLeft, x: points.topLeft.x - sa - 15 - }); + }) } } - return part; + return part } diff --git a/packages/jaeger/src/chestpocketwelt.js b/packages/jaeger/src/chestpocketwelt.js index 2dd569b9b32..0830560c22f 100644 --- a/packages/jaeger/src/chestpocketwelt.js +++ b/packages/jaeger/src/chestpocketwelt.js @@ -1,19 +1,30 @@ export default function(part) { - let { paperless, sa, store, complete, points, options, macro, Point, paths, Path } = part.shorthand(); + let { + paperless, + sa, + store, + complete, + points, + options, + macro, + Point, + paths, + Path + } = part.shorthand() - let width = store.get("chestPocketWidth"); - let height = store.get("chestPocketWeltHeight"); - let angle = options.chestPocketAngle; + let width = store.get('chestPocketWidth') + let height = store.get('chestPocketWeltHeight') + let angle = options.chestPocketAngle - points.anchor = new Point(0, 0); - points.top = points.anchor.shift(90 - angle, height/2); - points.bottom = points.anchor.shift(-90 - angle, height/2); - points.topLeft = points.top.shift(180, width/2); - points.topRight = points.topLeft.rotate(180, points.top); - points.bottomLeft = points.bottom.shift(180, width/2); - points.bottomRight = points.bottomLeft.rotate(180, points.bottom); - points.foldLeft = points.bottomLeft.flipY(points.topLeft); - points.foldRight = points.bottomRight.flipY(points.topLeft); + points.anchor = new Point(0, 0) + points.top = points.anchor.shift(90 - angle, height / 2) + points.bottom = points.anchor.shift(-90 - angle, height / 2) + points.topLeft = points.top.shift(180, width / 2) + points.topRight = points.topLeft.rotate(180, points.top) + points.bottomLeft = points.bottom.shift(180, width / 2) + points.bottomRight = points.bottomLeft.rotate(180, points.bottom) + points.foldLeft = points.bottomLeft.flipY(points.topLeft) + points.foldRight = points.bottomRight.flipY(points.topLeft) // Paths paths.seam = new Path() @@ -25,43 +36,42 @@ export default function(part) { .line(points.foldRight) .line(points.foldLeft) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') paths.fold = new Path() .move(points.topLeft) .line(points.topRight) - .attr("class", "stroke-sm dashed"); + .attr('class', 'stroke-sm dashed') if (complete) { // Title - macro("title", { + macro('title', { at: points.top, nr: 11, - title: "chestPocketWelt" - }); + title: 'chestPocketWelt' + }) // Grainline - macro("grainline", { + macro('grainline', { from: points.bottomLeft.shift(0, 10), to: points.bottomLeft.shiftFractionTowards(points.topLeft, 2).shift(0, 10) - }); + }) - if (sa) paths.sa = paths.seam.offset(sa).attr("class", "fabric sa"); + if (sa) paths.sa = paths.seam.offset(sa).attr('class', 'fabric sa') if (paperless) { - macro("hd", { + macro('hd', { from: points.foldLeft, to: points.foldRight, y: points.foldLeft.y - sa - 15 - }); - macro("vd", { + }) + macro('vd', { from: points.bottomRight, to: points.foldRight, x: points.bottomRight.x + sa + 15 - }); + }) } - } - return part; + return part } diff --git a/packages/jaeger/src/collar.js b/packages/jaeger/src/collar.js index b366db12892..ac686528027 100644 --- a/packages/jaeger/src/collar.js +++ b/packages/jaeger/src/collar.js @@ -6,28 +6,28 @@ */ export default function(part) { - let { paperless, sa, snippets, complete, points, options, macro, paths, Path } = part.shorthand(); + let { paperless, sa, snippets, complete, points, options, macro, paths, Path } = part.shorthand() // Add extra fabric for collar roll - points.collarCbTopRoll = points.collarCbTop.shift(-90, options.collarRoll); - points.collarCbTopCpRoll = points.collarCbTopCp.shift(-90, options.collarRoll); - points.notchTipRoll = points.notch.shiftOutwards(points.notchTip, options.collarRoll); + points.collarCbTopRoll = points.collarCbTop.shift(-90, options.collarRoll) + points.collarCbTopCpRoll = points.collarCbTopCp.shift(-90, options.collarRoll) + points.notchTipRoll = points.notch.shiftOutwards(points.notchTip, options.collarRoll) // Mirror to create left half let mirror = [ - "collarstandCbTopCp", - "collarstandTip", - "notch", - "notchTip", - "collarCbTopCp", - "notchTipRoll", - "collarCbTopCpRoll", - ]; - for (let i of mirror) points[i+"Left"] = points[i].flipX(points.collarCbTop); + 'collarstandCbTopCp', + 'collarstandTip', + 'notch', + 'notchTip', + 'collarCbTopCp', + 'notchTipRoll', + 'collarCbTopCpRoll' + ] + for (let i of mirror) points[i + 'Left'] = points[i].flipX(points.collarCbTop) // Clean up - for (let i of Object.keys(paths)) delete paths[i]; - for (let i of Object.keys(snippets)) delete snippets[i]; + for (let i of Object.keys(paths)) delete paths[i] + for (let i of Object.keys(snippets)) delete snippets[i] // Paths paths.seam = new Path() @@ -41,90 +41,84 @@ export default function(part) { .line(points.collarstandTip) ._curve(points.collarstandCbTopCp, points.collarstandCbTop) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') paths.roll = new Path() .move(points.notchTip) ._curve(points.collarCbTopCp, points.collarCbTop) .curve_(points.collarCbTopCpLeft, points.notchTipLeft) - .attr("class", "stroke-sm dashed"); - + .attr('class', 'stroke-sm dashed') if (complete) { // Notches - macro("sprinkle", { - snippet: "notch", - on: [ - "collarstandCbTop", - "notchTip", - "notchTipLeft", - ] - }); + macro('sprinkle', { + snippet: 'notch', + on: ['collarstandCbTop', 'notchTip', 'notchTipLeft'] + }) // Title - points.title = points.collarstandCbTopCp.shiftFractionTowards(points.collarCbTopCpRoll, 0.5); - macro("title", { + points.title = points.collarstandCbTopCp.shiftFractionTowards(points.collarCbTopCpRoll, 0.5) + macro('title', { at: points.title, nr: 7, - title: "collar" - }); + title: 'collar' + }) // Grainline - macro("grainline", { + macro('grainline', { from: points.collarCbTopRoll, to: points.collarstandCbTop - }); + }) - if (sa) paths.sa = paths.seam.offset(sa).attr("class", "fabric sa"); + if (sa) paths.sa = paths.seam.offset(sa).attr('class', 'fabric sa') if (paperless) { - macro("hd", { + macro('hd', { from: points.collarstandTipLeft, to: points.collarstandTip, y: points.collarstandCbTop.y - sa - 15 - }); - macro("hd", { + }) + macro('hd', { from: points.notchLeft, to: points.notch, y: points.collarstandCbTop.y - sa - 30 - }); - macro("hd", { + }) + macro('hd', { from: points.notchTipRollLeft, to: points.notchTipRoll, y: points.notchTipRoll.y + sa + 15 - }); - macro("hd", { + }) + macro('hd', { from: points.notchTipLeft, to: points.notchTip, y: points.notchTipRoll.y + sa + 30 - }); - macro("vd", { + }) + macro('vd', { from: points.collarCbTopRoll, to: points.collarstandCbTop, x: points.collarCbTopRoll.x + 15 - }); - macro("ld", { + }) + macro('ld', { from: points.collarstandTip, to: points.notch, d: sa + 15 - }); - macro("ld", { + }) + macro('ld', { from: points.notchTip, to: points.notch, d: -15 - sa - }); - macro("ld", { + }) + macro('ld', { from: points.notchTipRoll, to: points.notch, d: -30 - sa - }); - macro("vd", { + }) + macro('vd', { from: points.notchTipRoll, to: points.collarstandCbTop, x: points.notch.x + sa + 40 - }); - + }) } } - return part; + return part } diff --git a/packages/jaeger/src/collarstand.js b/packages/jaeger/src/collarstand.js index daacddd88c2..57699998746 100644 --- a/packages/jaeger/src/collarstand.js +++ b/packages/jaeger/src/collarstand.js @@ -1,4 +1,3 @@ - /* * This collar would benefit from a redesign * but I find collar design to be rather tricky business and @@ -7,7 +6,19 @@ */ export default function(part) { - let { paperless, sa, store, complete, points, measurements, options, macro, snippets, paths, Path } = part.shorthand(); + let { + paperless, + sa, + store, + complete, + points, + measurements, + options, + macro, + snippets, + paths, + Path + } = part.shorthand() // Only keep what's relevant from the front part let collarPoints = [ @@ -17,16 +28,15 @@ export default function(part) { 'neck', 'shoulderRoll', 'shoulderRollCb', - "collarCbTop", + 'collarCbTop', 'collarCbHelp', - "collarCbBottom", + 'collarCbBottom', 'lapelBreakPoint' - ]; + ] for (let i of Object.keys(points)) { - if(collarPoints.indexOf(i) === -1) delete points[i]; + if (collarPoints.indexOf(i) === -1) delete points[i] } - for (let i of Object.keys(paths)) delete paths[i]; - + for (let i of Object.keys(paths)) delete paths[i] /** * Locate collarstand center back bottom point @@ -36,53 +46,52 @@ export default function(part) { * split this curve. We can use the control point as is. */ points.collarstandCbBottom = points.collarCorner - .shiftOutwards(points.neck, store.get("backCollarLength")*1.1) // * 1.1 = 10% too far - .rotate(store.get("shoulderSlope"), points.neck); + .shiftOutwards(points.neck, store.get('backCollarLength') * 1.1) // * 1.1 = 10% too far + .rotate(store.get('shoulderSlope'), points.neck) // Adjust curve to correct length points.collarstandCbBottom = new Path() .move(points.collarCorner) ._curve(points.neck, points.collarstandCbBottom) - .shiftAlong(store.get("backCollarLength") + points.collarCorner.dist(points.neck)); // now it's correct + .shiftAlong(store.get('backCollarLength') + points.collarCorner.dist(points.neck)) // now it's correct // Locate collarstand center back top point - points.collarCbTopDirection = points.neck.rotate(-90, points.collarstandCbBottom); // right direction, but too far + points.collarCbTopDirection = points.neck.rotate(-90, points.collarstandCbBottom) // right direction, but too far points.collarCbTop = points.collarstandCbBottom.shiftTowards( points.collarCbTopDirection, measurements.neckCircumference * options.collarHeight * 2 - ); - + ) // Rotate points - let angle = -1 * points.collarstandCbBottom.angle(points.neck); - for (let i of Object.keys(points)) points[i] = points[i].rotate(angle, points.neck); + let angle = -1 * points.collarstandCbBottom.angle(points.neck) + for (let i of Object.keys(points)) points[i] = points[i].rotate(angle, points.neck) // Collarstand center back top point - points.collarstandCbTop = points.collarstandCbBottom.shiftFractionTowards(points.collarCbTop, 0.3); + points.collarstandCbTop = points.collarstandCbBottom.shiftFractionTowards(points.collarCbTop, 0.3) points.collarstandCbTopCp = points.collarstandCbTop.shift( points.collarstandCbBottom.angle(points.neck), points.collarstandCbBottom.dist(points.neck) - ); + ) // Spread collar - points.notch = points.notch.rotate(options.collarSpread, points.collarCorner); - points.notchTip = points.notchTip.rotate(options.collarSpread, points.collarCorner); - points.shoulderRoll = points.shoulderRoll.rotate(options.collarSpread, points.collarCorner); + points.notch = points.notch.rotate(options.collarSpread, points.collarCorner) + points.notchTip = points.notchTip.rotate(options.collarSpread, points.collarCorner) + points.shoulderRoll = points.shoulderRoll.rotate(options.collarSpread, points.collarCorner) // Collarstand tip - points.collarstandTip = points.collarCorner.shiftFractionTowards(points.shoulderRoll, 0.6); + points.collarstandTip = points.collarCorner.shiftFractionTowards(points.shoulderRoll, 0.6) // Collar control points - points.collarCbTopCp = points.collarCbTop.shift(0, points.collarCbTop.dx(points.notchTip)*0.6); + points.collarCbTopCp = points.collarCbTop.shift(0, points.collarCbTop.dx(points.notchTip) * 0.6) // Now draft the collarstand - points.leftCollarCorner = points.collarCorner.flipX(points.collarCbTop); - points.leftCollarstandTip = points.collarstandTip.flipX(points.collarCbTop); - points.leftNeck = points.neck.flipX(points.collarCbTop); - points.leftCollarstandCbTopCp = points.collarstandCbTopCp.flipX(points.collarCbTop); + points.leftCollarCorner = points.collarCorner.flipX(points.collarCbTop) + points.leftCollarstandTip = points.collarstandTip.flipX(points.collarCbTop) + points.leftNeck = points.neck.flipX(points.collarCbTop) + points.leftCollarstandCbTopCp = points.collarstandCbTopCp.flipX(points.collarCbTop) // Clean up - for (let i of Object.keys(paths)) delete paths[i]; - for (let i of Object.keys(snippets)) delete snippets[i]; + for (let i of Object.keys(paths)) delete paths[i] + for (let i of Object.keys(snippets)) delete snippets[i] // Paths paths.seam = new Path() @@ -94,7 +103,7 @@ export default function(part) { .curve_(points.collarstandCbTopCp, points.collarstandTip) .line(points.collarCorner) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') /* paths.foo = new Path() @@ -110,52 +119,49 @@ export default function(part) { if (complete) { // Notches - macro("sprinkle", { - snippet: "notch", - on: [ - "collarstandCbBottom", - "collarstandCbTop", - ] - }); + macro('sprinkle', { + snippet: 'notch', + on: ['collarstandCbBottom', 'collarstandCbTop'] + }) // Title - points.title = points.collarstandCbTop.shiftFractionTowards(points.collarCbBottom, 0.5); - macro("title", { + points.title = points.collarstandCbTop.shiftFractionTowards(points.collarCbBottom, 0.5) + macro('title', { at: points.title, nr: 8, - title: "collarstand" - }); + title: 'collarstand' + }) // Grainline - macro("grainline", { + macro('grainline', { from: points.collarstandCbTop, to: points.collarstandCbBottom - }); + }) - if (sa) paths.sa = paths.seam.offset(sa).attr("class", "fabric sa"); + if (sa) paths.sa = paths.seam.offset(sa).attr('class', 'fabric sa') if (paperless) { - macro("hd", { + macro('hd', { from: points.leftCollarCorner, to: points.collarCorner, y: points.collarstandCbBottom.y - sa - 15 - }); - macro("hd", { + }) + macro('hd', { from: points.leftCollarstandTip, to: points.collarstandTip, y: points.collarstandTip.y + sa + 15 - }); - macro("vd", { + }) + macro('vd', { from: points.collarstandTip, to: points.collarCorner, x: points.collarstandTip.x + sa + 15 - }); - macro("vd", { + }) + macro('vd', { from: points.collarstandCbTop, to: points.collarstandCbBottom, x: points.collarstandCbTop.x + 15 - }); + }) } } - return part; + return part } diff --git a/packages/jaeger/src/front.js b/packages/jaeger/src/front.js index 05042861d08..0d2afcefb13 100644 --- a/packages/jaeger/src/front.js +++ b/packages/jaeger/src/front.js @@ -1,237 +1,256 @@ export default function(part) { - let { paperless, sa, snippets, Snippet, utils, store, complete, points, measurements, options, macro, Point, paths, Path } = part.shorthand(); + let { + paperless, + sa, + snippets, + Snippet, + utils, + store, + complete, + points, + measurements, + options, + macro, + Point, + paths, + Path + } = part.shorthand() // Front closure overlap - points.neckEdge = points.cfNeck.shift(180, measurements.chestCircumference * options.frontOverlap); - points.hemEdge = new Point( - points.neckEdge.x, - points.cfHem.y - ); + points.neckEdge = points.cfNeck.shift(180, measurements.chestCircumference * options.frontOverlap) + points.hemEdge = new Point(points.neckEdge.x, points.cfHem.y) // Chest pocket points.chestPocketAnchor = new Point( points.split.x * options.chestPocketPlacement, points.armholePitchCp1.y - ); - let width = points.split.x * options.chestPocketWidth; - let height = width * options.chestPocketWeltSize; + ) + let width = points.split.x * options.chestPocketWidth + let height = width * options.chestPocketWeltSize - points.chestPocketTop = points.chestPocketAnchor.shift(90, height/2); - points.chestPocketBottom = points.chestPocketAnchor.shift(-90, height/2); - points.chestPocketTopLeft = points.chestPocketTop.shift(180 + options.chestPocketAngle, width/2); - points.chestPocketTopRight = points.chestPocketTopLeft.rotate(180, points.chestPocketTop); - points.chestPocketBottomLeft = points.chestPocketBottom.shift(180 + options.chestPocketAngle, width/2); - points.chestPocketBottomRight = points.chestPocketBottomLeft.rotate(180, points.chestPocketBottom); - store.set("chestPocketWidth", width); - store.set("chestPocketWeltHeight", height); + points.chestPocketTop = points.chestPocketAnchor.shift(90, height / 2) + points.chestPocketBottom = points.chestPocketAnchor.shift(-90, height / 2) + points.chestPocketTopLeft = points.chestPocketTop.shift(180 + options.chestPocketAngle, width / 2) + points.chestPocketTopRight = points.chestPocketTopLeft.rotate(180, points.chestPocketTop) + points.chestPocketBottomLeft = points.chestPocketBottom.shift( + 180 + options.chestPocketAngle, + width / 2 + ) + points.chestPocketBottomRight = points.chestPocketBottomLeft.rotate(180, points.chestPocketBottom) + store.set('chestPocketWidth', width) + store.set('chestPocketWeltHeight', height) // Inner pocket points.innerPocketAnchor = new Point( points.hips.x * options.innerPocketPlacement, points.dartTop.y - ); - width = points.hips.x * options.innerPocketWidth; - let weltHeight = width * options.innerPocketWeltHeight; - points.innerPocketTop = points.innerPocketAnchor.shift(90, weltHeight); - points.innerPocketBottom = points.innerPocketAnchor.shift(-90, weltHeight); - points.innerPocketLeft = points.innerPocketAnchor.shift(180, width/2); - points.innerPocketRight = points.innerPocketLeft.flipX(points.innerPocketAnchor); - points.innerPocketTopLeft = points.innerPocketLeft.shift(90, weltHeight); - points.innerPocketTopRight = points.innerPocketTopLeft.flipX(points.innerPocketAnchor); - points.innerPocketBottomLeft = points.innerPocketLeft.shift(-90, weltHeight); - points.innerPocketBottomRight = points.innerPocketBottomLeft.flipX(points.innerPocketAnchor); - store.set("innerPocketWeltHeight", weltHeight); - store.set("innerPocketWidth", width); + ) + width = points.hips.x * options.innerPocketWidth + let weltHeight = width * options.innerPocketWeltHeight + points.innerPocketTop = points.innerPocketAnchor.shift(90, weltHeight) + points.innerPocketBottom = points.innerPocketAnchor.shift(-90, weltHeight) + points.innerPocketLeft = points.innerPocketAnchor.shift(180, width / 2) + points.innerPocketRight = points.innerPocketLeft.flipX(points.innerPocketAnchor) + points.innerPocketTopLeft = points.innerPocketLeft.shift(90, weltHeight) + points.innerPocketTopRight = points.innerPocketTopLeft.flipX(points.innerPocketAnchor) + points.innerPocketBottomLeft = points.innerPocketLeft.shift(-90, weltHeight) + points.innerPocketBottomRight = points.innerPocketBottomLeft.flipX(points.innerPocketAnchor) + store.set('innerPocketWeltHeight', weltHeight) + store.set('innerPocketWidth', width) // Slash & spread chest. This is one of those things that's simpler on paper - points.splitEdge = new Point( - points.neckEdge.x, - points.split.y - ); + points.splitEdge = new Point(points.neckEdge.x, points.split.y) let rotate = [ - "splitEdge", - "neckEdge", - "cfNeck", - "cfNeckCp1", - "neckCp2Front", - "neck", - "shoulder", - "shoulderCp1", - "armholePitchCp2", - "armholePitch", - "armholePitchCp1", - "armholeHollowCp2", - "armholeHollow", - "armholeHollowCp1", - "splitCp2", - "frontNeckCpEdge" - ]; + 'splitEdge', + 'neckEdge', + 'cfNeck', + 'cfNeckCp1', + 'neckCp2Front', + 'neck', + 'shoulder', + 'shoulderCp1', + 'armholePitchCp2', + 'armholePitch', + 'armholePitchCp1', + 'armholeHollowCp2', + 'armholeHollow', + 'armholeHollowCp1', + 'splitCp2', + 'frontNeckCpEdge' + ] for (let p of rotate) { - points[p] = points[p].rotate(options.chestShapingMax * options.chestShaping * -1, points.split); + points[p] = points[p].rotate(options.chestShapingMax * options.chestShaping * -1, points.split) } // Lapel break point and cutaway point - points.lapelBreakPoint = new Point( - points.hemEdge.x, - points.dartTop.y * (1 + options.lapelStart) - ); + points.lapelBreakPoint = new Point(points.hemEdge.x, points.dartTop.y * (1 + options.lapelStart)) points.cutawayPoint = points.lapelBreakPoint.shift( -90, points.lapelBreakPoint.dy(points.hemEdge) * options.buttonLength - ); + ) // Lapel roll line - let rollHeight = measurements.neckCircumference * options.rollLineCollarHeight; - points.shoulderRoll = points.shoulder.shiftOutwards(points.neck, rollHeight); - let collarHeight = measurements.neckCircumference * options.collarHeight; - points.shoulderRollCb = points.lapelBreakPoint.shiftOutwards(points.shoulderRoll, store.get("backCollarLength")); - let angle = points.shoulderRoll.angle(points.shoulderRollCb); - points.collarCbHelp = points.shoulderRollCb.shift(angle-90, rollHeight); - points.collarCbBottom = points.collarCbHelp.shift(angle-90, rollHeight); - points.collarCbTop = points.collarCbHelp.shift(angle+90, collarHeight * 2 - rollHeight); + let rollHeight = measurements.neckCircumference * options.rollLineCollarHeight + points.shoulderRoll = points.shoulder.shiftOutwards(points.neck, rollHeight) + let collarHeight = measurements.neckCircumference * options.collarHeight + points.shoulderRollCb = points.lapelBreakPoint.shiftOutwards( + points.shoulderRoll, + store.get('backCollarLength') + ) + let angle = points.shoulderRoll.angle(points.shoulderRollCb) + points.collarCbHelp = points.shoulderRollCb.shift(angle - 90, rollHeight) + points.collarCbBottom = points.collarCbHelp.shift(angle - 90, rollHeight) + points.collarCbTop = points.collarCbHelp.shift(angle + 90, collarHeight * 2 - rollHeight) // Notch points.notchMax = utils.beamsIntersect( - points.lapelBreakPoint, points.shoulderRoll, - points.neckEdge, points.frontNeckCpEdge - ); - points.lapelTip = utils.beamsIntersect( // Keeps lapel straight despite chest shaping - points.hemEdge, points.lapelBreakPoint, - points.notchMax, points.cfNeckCp1 - ); - points.notchEdge = points.lapelTip.shiftFractionTowards(points.notchMax, options.lapelReduction); - points.notch = points.cfNeck.shiftFractionTowards(points.notchMax, options.collarNotchDepth); - points.notchTip = points.neckEdge.rotate(options.collarNotchAngle * -1, points.notch); - points.notchTip = points.notch.shiftFractionTowards(points.notchTip, options.collarNotchReturn); - points.notchTipCp = points.notchTip.shift(points.notch.angle(points.notchTip)-90, points.notchTip.dist(points.collarCbTop)/4); - points.collarCbTopCp = points.collarCbTop.shift(points.collarCbBottom.angle(points.collarCbTop)+90, points.notchTip.dist(points.collarCbTop)/4); + points.lapelBreakPoint, + points.shoulderRoll, + points.neckEdge, + points.frontNeckCpEdge + ) + points.lapelTip = utils.beamsIntersect( + // Keeps lapel straight despite chest shaping + points.hemEdge, + points.lapelBreakPoint, + points.notchMax, + points.cfNeckCp1 + ) + points.notchEdge = points.lapelTip.shiftFractionTowards(points.notchMax, options.lapelReduction) + points.notch = points.cfNeck.shiftFractionTowards(points.notchMax, options.collarNotchDepth) + points.notchTip = points.neckEdge.rotate(options.collarNotchAngle * -1, points.notch) + points.notchTip = points.notch.shiftFractionTowards(points.notchTip, options.collarNotchReturn) + points.notchTipCp = points.notchTip.shift( + points.notch.angle(points.notchTip) - 90, + points.notchTip.dist(points.collarCbTop) / 4 + ) + points.collarCbTopCp = points.collarCbTop.shift( + points.collarCbBottom.angle(points.collarCbTop) + 90, + points.notchTip.dist(points.collarCbTop) / 4 + ) // Redraw front neck line - points.lapelStraightEnd = new Point( - points.lapelBreakPoint.x, - points.splitEdge.y - ); - points.lapelStraightEndCp1 = points.lapelStraightEnd.shift(90, points.neckEdge.dy(points.lapelStraightEnd) * 0.7); - angle = points.notch.angle(points.neck); - points._dir1 = points.notch.shift(angle/2, 50); - points._dir2 = points.neck.shift(angle * 1.5 + 180, 50); + points.lapelStraightEnd = new Point(points.lapelBreakPoint.x, points.splitEdge.y) + points.lapelStraightEndCp1 = points.lapelStraightEnd.shift( + 90, + points.neckEdge.dy(points.lapelStraightEnd) * 0.7 + ) + angle = points.notch.angle(points.neck) + points._dir1 = points.notch.shift(angle / 2, 50) + points._dir2 = points.neck.shift(angle * 1.5 + 180, 50) points.collarCorner = points.notch.shiftFractionTowards(points.notchMax, 1.6) // Cut rollline back to collar line let shoulderRoll = utils.linesIntersect( - points.shoulderRoll, points.lapelBreakPoint, - points.notch, points.collarCorner - ); + points.shoulderRoll, + points.lapelBreakPoint, + points.notch, + points.collarCorner + ) // FIXME: Does this ever happen? - if(!shoulderRoll) throw new Error("Roll line does not intersect with notch/collarCorner line"); - else points.shoulderRoll = shoulderRoll; + if (!shoulderRoll) throw new Error('Roll line does not intersect with notch/collarCorner line') + else points.shoulderRoll = shoulderRoll // Round the hem - points.hemRoundTarget = new Point( - points.hem.x, - points.cfHem.y - ); + points.hemRoundTarget = new Point(points.hem.x, points.cfHem.y) points.roundStart = points.cutawayPoint .shiftFractionTowards(points.hemEdge, options.frontCutawayStart) - .rotate(options.frontCutawayAngle, points.cutawayPoint); - points.roundEnd = points.hemDropEnd.shiftFractionTowards(points.cfHem, 1 - options.frontCutawayEnd); + .rotate(options.frontCutawayAngle, points.cutawayPoint) + points.roundEnd = points.hemDropEnd.shiftFractionTowards( + points.cfHem, + 1 - options.frontCutawayEnd + ) points.roundVia = utils.beamsIntersect( - points.cutawayPoint, points.roundStart, - points.hemDropEnd, points.cfHem - ); - points.roundCp1 = points.roundStart.shiftFractionTowards(points.roundVia, options.hemRadius); - points.roundCp2 = points.roundEnd.shiftFractionTowards(points.roundVia, options.hemRadius); - let cpDist = points.cutawayPoint.dy(points.roundStart)/3; - points.cutawayPointCp2 = points.cutawayPoint.shift(-90, cpDist); - points.roundStartCp1 = points.roundCp1.shiftOutwards(points.roundStart, cpDist); + points.cutawayPoint, + points.roundStart, + points.hemDropEnd, + points.cfHem + ) + points.roundCp1 = points.roundStart.shiftFractionTowards(points.roundVia, options.hemRadius) + points.roundCp2 = points.roundEnd.shiftFractionTowards(points.roundVia, options.hemRadius) + let cpDist = points.cutawayPoint.dy(points.roundStart) / 3 + points.cutawayPointCp2 = points.cutawayPoint.shift(-90, cpDist) + points.roundStartCp1 = points.roundCp1.shiftOutwards(points.roundStart, cpDist) // Facing/lining boundary - points.facingTop = points.neck.shiftFractionTowards(points.shoulder, 0.2); + points.facingTop = points.neck.shiftFractionTowards(points.shoulder, 0.2) points.facingBottom = new Path() .move(points.roundStart) .curve(points.roundCp1, points.roundCp2, points.roundEnd) .line(points.hem) .intersectsX(points.dartLeft.x * 0.7) - .pop(); + .pop() // Inner pocket facing extension (ipfe) points.ipfeAnchor = utils.beamsIntersect( - points.facingTop, points.facingBottom, - points.innerPocketLeft, points.innerPocketRight - ); - let ipfeHeight = points.innerPocketTopRight.dy(points.innerPocketBottomRight) * 5; - points.ipfeTopRight = points.innerPocketRight.shift(90, ipfeHeight/2); - points.ipfeBottomRight = points.ipfeTopRight.flipY(points.innerPocketRight); - points.ipfeEdge = points.innerPocketRight.shift(0, ipfeHeight/2); - points.ipfeViaTopRight = new Point( - points.ipfeEdge.x, - points.ipfeTopRight.y - ); - points.ipfeViaBottomRight = points.ipfeViaTopRight.flipY(points.innerPocketRight); - macro("round", { + points.facingTop, + points.facingBottom, + points.innerPocketLeft, + points.innerPocketRight + ) + let ipfeHeight = points.innerPocketTopRight.dy(points.innerPocketBottomRight) * 5 + points.ipfeTopRight = points.innerPocketRight.shift(90, ipfeHeight / 2) + points.ipfeBottomRight = points.ipfeTopRight.flipY(points.innerPocketRight) + points.ipfeEdge = points.innerPocketRight.shift(0, ipfeHeight / 2) + points.ipfeViaTopRight = new Point(points.ipfeEdge.x, points.ipfeTopRight.y) + points.ipfeViaBottomRight = points.ipfeViaTopRight.flipY(points.innerPocketRight) + macro('round', { from: points.ipfeBottomRight, to: points.ipfeEdge, via: points.ipfeViaBottomRight, - radius: ipfeHeight/2, - prefix: "ipfeBottomRight", - }); - macro("round", { + radius: ipfeHeight / 2, + prefix: 'ipfeBottomRight' + }) + macro('round', { from: points.ipfeTopRight, to: points.ipfeEdge, via: points.ipfeViaTopRight, - radius: ipfeHeight/2, - prefix: "ipfeTopRight", - }); + radius: ipfeHeight / 2, + prefix: 'ipfeTopRight' + }) points.ipfeStart = utils.beamIntersectsY( points.facingTop, points.facingBottom, points.innerPocketAnchor.y - ipfeHeight - ); + ) points.ipfeEnd = utils.beamIntersectsY( points.facingTop, points.facingBottom, points.innerPocketAnchor.y + ipfeHeight - ); + ) points.ipfeStartEnd = new Point( - points.ipfeStart.x + ipfeHeight/2, - points.innerPocketAnchor.y - ipfeHeight/2 - ); - points.ipfeStartVia = new Point( - points.ipfeStart.x, - points.ipfeStartEnd.y - ); + points.ipfeStart.x + ipfeHeight / 2, + points.innerPocketAnchor.y - ipfeHeight / 2 + ) + points.ipfeStartVia = new Point(points.ipfeStart.x, points.ipfeStartEnd.y) points.ipfeEndEnd = new Point( - points.ipfeEnd.x + ipfeHeight/2, - points.innerPocketAnchor.y + ipfeHeight/2 - ); - points.ipfeEndVia = new Point( - points.ipfeEnd.x, - points.ipfeEndEnd.y - ); - macro("round", { + points.ipfeEnd.x + ipfeHeight / 2, + points.innerPocketAnchor.y + ipfeHeight / 2 + ) + points.ipfeEndVia = new Point(points.ipfeEnd.x, points.ipfeEndEnd.y) + macro('round', { from: points.ipfeStart, to: points.ipfeStartEnd, via: points.ipfeStartVia, - radius: ipfeHeight/2, - prefix: "ipfeStart", - }); - macro("round", { + radius: ipfeHeight / 2, + prefix: 'ipfeStart' + }) + macro('round', { from: points.ipfeEnd, to: points.ipfeEndEnd, via: points.ipfeEndVia, - radius: ipfeHeight/2, - prefix: "ipfeEnd", - }); + radius: ipfeHeight / 2, + prefix: 'ipfeEnd' + }) // Rotate control points to smooth out curve - angle = points.facingTop.angle(points.facingBottom) + 90; - points.ipfeStartCp1 = points.ipfeStartCp1.rotate(angle, points.ipfeStart); - points.ipfeEndCp1 = points.ipfeEndCp1.rotate(angle, points.ipfeEnd); - + angle = points.facingTop.angle(points.facingBottom) + 90 + points.ipfeStartCp1 = points.ipfeStartCp1.rotate(angle, points.ipfeStart) + points.ipfeEndCp1 = points.ipfeEndCp1.rotate(angle, points.ipfeEnd) // Clean up - Remove this and uncomment paths below to understand what's going on - for (let i of Object.keys(paths)) delete paths[i]; - for (let i of Object.keys(snippets)) delete snippets[i]; + for (let i of Object.keys(paths)) delete paths[i] + for (let i of Object.keys(snippets)) delete snippets[i] /* paths.edge = new Path() @@ -286,18 +305,16 @@ export default function(part) { ._curve(points.lapelStraightEndCp1, points.lapelStraightEnd) .line(points.cutawayPoint) .curve(points.cutawayPointCp2, points.roundStartCp1, points.roundStart) - .curve(points.roundCp1, points.roundCp2, points.roundEnd); - paths.saBase.render = false; + .curve(points.roundCp1, points.roundCp2, points.roundEnd) + paths.saBase.render = false - paths.hemBase = new Path() - .move(points.roundEnd) - .line(points.hem); - paths.hemBase.render = false; + paths.hemBase = new Path().move(points.roundEnd).line(points.hem) + paths.hemBase.render = false paths.seam = paths.saBase .clone() .join(paths.hemBase) - .attr("class", "fabric"); + .attr('class', 'fabric') paths.flb = new Path() .move(points.facingTop) @@ -309,7 +326,7 @@ export default function(part) { .line(points.ipfeEndEnd) .curve(points.ipfeEndCp2, points.ipfeEndCp1, points.ipfeEnd) .line(points.facingBottom) - .attr("class", "fabric") + .attr('class', 'fabric') paths.chestPocket = new Path() .move(points.chestPocketTopRight) @@ -318,7 +335,7 @@ export default function(part) { .line(points.chestPocketBottomRight) .line(points.chestPocketTopRight) .close() - .attr("class", "fabric dashed"); + .attr('class', 'fabric dashed') paths.innerPocket = new Path() .move(points.innerPocketTopRight) @@ -329,12 +346,12 @@ export default function(part) { .move(points.innerPocketLeft) .line(points.innerPocketRight) .close() - .attr("class", "fabric dashed"); + .attr('class', 'fabric dashed') paths.breakLine = new Path() .move(points.lapelBreakPoint) .line(points.shoulderRoll) - .attr("class", "canvas lashed"); + .attr('class', 'canvas lashed') paths.dart = new Path() .move(points.dartBottom) @@ -343,289 +360,270 @@ export default function(part) { ._curve(points.dartLeftCpTop, points.dartLeft) .curve_(points.dartLeftCpBottom, points.dartBottom) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') paths.frontPocket = new Path() .move(points.frontPocketTopEnd) .line(points.frontPocketTopLeft) .line(points.frontPocketBottomLeft) .line(points.frontPocketBottomEnd) - .attr("class", "help"); + .attr('class', 'help') paths.chestPiece = new Path() .move(points.lapelBreakPoint) - .curve( - points.cutawayPoint, - points.waist, - points.fsArmhole - ) - .attr("class", "canvas lashed") - .attr("data-text", "chestPiece") - .attr("data-text-class", "center") - + .curve(points.cutawayPoint, points.waist, points.fsArmhole) + .attr('class', 'canvas lashed') + .attr('data-text', 'chestPiece') + .attr('data-text-class', 'center') if (complete) { // Logo - points.logo = new Point( - points.dartBottom.x, - points.hips.y - ); - snippets.logo = new Snippet("logo", points.logo); + points.logo = new Point(points.dartBottom.x, points.hips.y) + snippets.logo = new Snippet('logo', points.logo) // Notches - macro("sprinkle", { - snippet: "notch", + macro('sprinkle', { + snippet: 'notch', on: [ - "neck", - "shoulder", - "armholePitch", - "chestPocketBottomLeft", - "chestPocketBottomRight", - "lapelBreakPoint", - "notchMax", - "notch", - "innerPocketLeft", - "innerPocketRight", - "frontPocketTopLeft", - "frontPocketBottomLeft", - "armholeHollow", - "waist" + 'neck', + 'shoulder', + 'armholePitch', + 'chestPocketBottomLeft', + 'chestPocketBottomRight', + 'lapelBreakPoint', + 'notchMax', + 'notch', + 'innerPocketLeft', + 'innerPocketRight', + 'frontPocketTopLeft', + 'frontPocketBottomLeft', + 'armholeHollow', + 'waist' ] - }); + }) // Buttons - points.button1 = new Point( - points.cfWaist.x, - points.lapelBreakPoint.y - ); - let buttons = ["button1"]; + points.button1 = new Point(points.cfWaist.x, points.lapelBreakPoint.y) + let buttons = ['button1'] if (options.buttons > 1) { - points.button2 = new Point( - points.cfWaist.x, - points.cutawayPoint.y - ); - buttons.push("button2"); - + points.button2 = new Point(points.cfWaist.x, points.cutawayPoint.y) + buttons.push('button2') } - for (let button of buttons) snippets[button] = new Snippet("button", points[button]).attr("data-scale", 2); + for (let button of buttons) + snippets[button] = new Snippet('button', points[button]).attr('data-scale', 2) // Instructions - paths.breakLine - .attr("data-text", "breakLine") - .attr("data-text-class", "center"); + paths.breakLine.attr('data-text', 'breakLine').attr('data-text-class', 'center') paths.flb - .attr("data-text-xml:space", "preserve") - .attr("data-text", " ") - .attr("data-text", "facingLiningBoundary") + .attr('data-text-xml:space', 'preserve') + .attr('data-text', ' ') + .attr('data-text', 'facingLiningBoundary') // Grainline - macro("grainline", { + macro('grainline', { from: points.cfHips, to: new Point(points.cfArmhole.x, points.collarCorner.y) - }); + }) if (sa) { paths.sa = paths.saBase .offset(sa) .join(paths.hemBase.offset(sa * 3)) .close() - .attr("class", "fabric sa"); + .attr('class', 'fabric sa') } if (paperless) { - macro("vd", { + macro('vd', { from: points.notchEdge, - to:points.neck, + to: points.neck, x: points.lapelBreakPoint.x - 15 - sa - }); - macro("vd", { + }) + macro('vd', { from: points.lapelBreakPoint, - to:points.notchEdge, + to: points.notchEdge, x: points.lapelBreakPoint.x - 15 - sa - }); - macro("vd", { + }) + macro('vd', { from: points.cutawayPoint, to: points.lapelBreakPoint, x: points.lapelBreakPoint.x - 15 - sa - }); - macro("vd", { + }) + macro('vd', { from: points.facingBottom, to: points.cutawayPoint, x: points.lapelBreakPoint.x - 15 - sa - }); - macro("vd", { + }) + macro('vd', { from: points.facingBottom, to: points.notchEdge, x: points.lapelBreakPoint.x - 30 - sa - }); - macro("vd", { + }) + macro('vd', { from: points.facingBottom, to: points.neck, x: points.lapelBreakPoint.x - 45 - sa - }); - macro("hd", { + }) + macro('hd', { from: points.notchEdge, to: points.notchMax, y: points.notchEdge.y - 15 - sa - }); - macro("hd", { + }) + macro('hd', { from: points.notchEdge, to: points.collarCorner, y: points.notchEdge.y - 30 - sa - }); - macro("hd", { + }) + macro('hd', { from: points.notchEdge, to: points.neck, y: points.neck.y - 15 - sa - }); - macro("hd", { + }) + macro('hd', { from: points.lapelStraightEnd, to: points.neck, y: points.neck.y - 30 - sa - }); - macro("hd", { + }) + macro('hd', { from: points.lapelStraightEnd, to: points.armholePitch, y: points.neck.y - 45 - sa - }); - macro("hd", { + }) + macro('hd', { from: points.lapelStraightEnd, to: points.shoulder, y: points.neck.y - 60 - sa - }); - macro("hd", { + }) + macro('hd', { from: points.lapelStraightEnd, to: points.fsArmhole, y: points.neck.y - 75 - sa - }); - macro("ld", { + }) + macro('ld', { from: points.neck, to: points.shoulder, d: -15 - }); - macro("ld", { + }) + macro('ld', { from: points.collarCorner, to: points.neck, d: -15 - }); - macro("ld", { + }) + macro('ld', { from: points.lapelBreakPoint, to: points.button1, d: -15 - }); - macro("hd", { + }) + macro('hd', { from: points.lapelBreakPoint, to: points.innerPocketTopLeft, - y: points.innerPocketTopLeft.y - 35, - }); - macro("hd", { + y: points.innerPocketTopLeft.y - 35 + }) + macro('hd', { from: points.innerPocketTopLeft, to: points.innerPocketTopRight, - y: points.innerPocketTopLeft.y - 35, - }); - macro("hd", { + y: points.innerPocketTopLeft.y - 35 + }) + macro('hd', { from: points.lapelBreakPoint, to: points.ipfeTopRightEnd, - y: points.innerPocketTopLeft.y - 50, - }); - macro("vd", { + y: points.innerPocketTopLeft.y - 50 + }) + macro('vd', { from: points.ipfeBottomRightStart, to: points.ipfeTopRightStart, - x: points.ipfeTopRightEnd.x + 15, - }); - macro("vd", { + x: points.ipfeTopRightEnd.x + 15 + }) + macro('vd', { from: points.innerPocketBottomRight, to: points.innerPocketTopRight, - x: points.innerPocketTopRight.x - 15, - }); - macro("hd", { + x: points.innerPocketTopRight.x - 15 + }) + macro('hd', { from: points.lapelBreakPoint, to: points.dartTop, - y: points.dartTop.y + 15, - }); - macro("ld", { + y: points.dartTop.y + 15 + }) + macro('ld', { from: points.dartLeft, - to: points.dartRight, - }); - macro("vd", { + to: points.dartRight + }) + macro('vd', { from: points.dartBottom, to: points.dartTop, - x: points.dartRight.x + 15, - }); - macro("hd", { + x: points.dartRight.x + 15 + }) + macro('hd', { from: points.lapelBreakPoint, to: points.facingBottom, - y: points.facingBottom.y + 15 + sa, - }); - macro("hd", { + y: points.facingBottom.y + 15 + sa + }) + macro('hd', { from: points.lapelBreakPoint, to: points.roundEnd, - y: points.facingBottom.y + 15 + 3*sa, - }); - macro("hd", { + y: points.facingBottom.y + 15 + 3 * sa + }) + macro('hd', { from: points.lapelBreakPoint, to: points.hem, - y: points.facingBottom.y + 30 + 3*sa, - }); - macro("vd", { + y: points.facingBottom.y + 30 + 3 * sa + }) + macro('vd', { from: points.hem, to: points.hips, - x: points.hem.x + 15 + sa, - }); - macro("vd", { + x: points.hem.x + 15 + sa + }) + macro('vd', { from: points.hem, to: points.dartBottom, - x: points.hem.x + 30 + sa, - }); - macro("vd", { + x: points.hem.x + 30 + sa + }) + macro('vd', { from: points.hem, to: points.waist, - x: points.hem.x + 45 + sa, - }); - macro("vd", { + x: points.hem.x + 45 + sa + }) + macro('vd', { from: points.hem, to: points.innerPocketRight, - x: points.hem.x + 60 + sa, - }); - macro("vd", { + x: points.hem.x + 60 + sa + }) + macro('vd', { from: points.hem, to: points.fsArmhole, - x: points.hem.x + 75 + sa, - }); - macro("vd", { + x: points.hem.x + 75 + sa + }) + macro('vd', { from: points.fsArmhole, to: points.armholePitch, - x: points.fsArmhole.x + 15 + sa, - }); - macro("vd", { + x: points.fsArmhole.x + 15 + sa + }) + macro('vd', { from: points.fsArmhole, to: points.shoulder, - x: points.fsArmhole.x + 30 + sa, - }); - macro("vd", { + x: points.fsArmhole.x + 30 + sa + }) + macro('vd', { from: points.fsArmhole, to: points.neck, - x: points.fsArmhole.x + 45 + sa, - }); - macro("hd", { + x: points.fsArmhole.x + 45 + sa + }) + macro('hd', { from: points.cutawayPoint, to: points.frontPocketTopLeft, y: points.frontPocketTopLeft.y - 15 - }); - macro("vd", { + }) + macro('vd', { from: points.frontPocketBottomLeft, to: points.frontPocketTopLeft, x: points.frontPocketTopLeft.x - 15 - }); - macro("vd", { + }) + macro('vd', { from: points.fsArmhole, to: points.chestPocketBottomLeft, x: points.chestPocketBottomLeft.x - 15 - }); - points.cfWaist = new Point( - points.button1.x, - points.waist.y - ); - macro("ld", { from: points.cfWaist, to: points.dartLeft }); - macro("ld", { from: points.dartRight, to: points.waist }); + }) + points.cfWaist = new Point(points.button1.x, points.waist.y) + macro('ld', { from: points.cfWaist, to: points.dartLeft }) + macro('ld', { from: points.dartRight, to: points.waist }) } } - return part; + return part } diff --git a/packages/jaeger/src/frontbase.js b/packages/jaeger/src/frontbase.js index 4ee85215cce..5ea4fda8d91 100644 --- a/packages/jaeger/src/frontbase.js +++ b/packages/jaeger/src/frontbase.js @@ -1,37 +1,34 @@ -import { backSideBoundary } from "./shared"; +import { backSideBoundary } from './shared' export default function(part) { - let { store, points, utils, options, Point, paths, Path } = part.shorthand(); + let { store, points, utils, options, Point, paths, Path } = part.shorthand() /** * Add side part from back to front, draw front style line */ - backSideBoundary(part, true); + backSideBoundary(part, true) paths.pathToSplit = new Path() .move(points.armhole) .curve(points.armholeCp2, points.armholeHollowCp1, points.armholeHollow) - .attr("class", "lining stroke-xl"); - points.split = paths.pathToSplit.shiftFractionAlong(0.5); - let halves = paths.pathToSplit.split(points.split); - paths.split1 = halves.pop().attr("class", "lining stroke-xxl"); - paths.split2 = halves.pop().attr("class", "canvas stroke-xxl"); + .attr('class', 'lining stroke-xl') + points.split = paths.pathToSplit.shiftFractionAlong(0.5) + let halves = paths.pathToSplit.split(points.split) + paths.split1 = halves.pop().attr('class', 'lining stroke-xxl') + paths.split2 = halves.pop().attr('class', 'canvas stroke-xxl') // We need to add these control points as we'll rotate them later // The path.ops property is where it's at - points.splitCp2 = paths.split1.ops[1].cp1; - points.armholeHollowCp1 = paths.split1.ops[1].cp2; + points.splitCp2 = paths.split1.ops[1].cp1 + points.armholeHollowCp1 = paths.split1.ops[1].cp2 // We need to add these control points for the side - points.sideArmholeCp2 = paths.split2.ops[1].cp1; - points.sideSplitCp1 = paths.split2.ops[1].cp2; + points.sideArmholeCp2 = paths.split2.ops[1].cp1 + points.sideSplitCp1 = paths.split2.ops[1].cp2 - points.fsArmhole = points.split.clone(); - points.fsWaist = new Point( - points.waist.x * options.sideFrontPlacement, - points.waist.y - ); - points.fsWaistCp2 = points.fsWaist.shift(90, points.split.dy(points.waist)/2); - points.fsHips = new Point(points.fsWaist.x, points.hips.y); - points.fsHem = new Point(points.fsWaist.x, points.hem.y); + points.fsArmhole = points.split.clone() + points.fsWaist = new Point(points.waist.x * options.sideFrontPlacement, points.waist.y) + points.fsWaistCp2 = points.fsWaist.shift(90, points.split.dy(points.waist) / 2) + points.fsHips = new Point(points.fsWaist.x, points.hips.y) + points.fsHem = new Point(points.fsWaist.x, points.hem.y) /** Uncomment this to see the style line without shaping */ @@ -39,28 +36,30 @@ export default function(part) { .move(points.fsHem) .line(points.fsWaist) .curve_(points.fsWaistCp2, points.fsArmhole) - .attr("class", "stroke-xl lining lashed") - + .attr('class', 'stroke-xl lining lashed') /** * Shape the front/side seam */ - points.waist = points.fsWaist.shift(180, store.get("waistReduction") * options.reduceWaistStandardFraction); - points.waistCp2 = new Point( - points.waist.x, - points.fsWaistCp2.y - ); - points.hips = points.fsHips.shift(180, store.get("hipsReduction") * options.reduceHipsStandardFraction); - points.waistCp1 = points.waist.shift(-90, points.waist.dy(points.hips)/3); - points.hipsCp2 = points.hips.shift(90, points.waist.dy(points.hips)/3); - points.hem = new Point(points.hips.x, points.hem.y); + points.waist = points.fsWaist.shift( + 180, + store.get('waistReduction') * options.reduceWaistStandardFraction + ) + points.waistCp2 = new Point(points.waist.x, points.fsWaistCp2.y) + points.hips = points.fsHips.shift( + 180, + store.get('hipsReduction') * options.reduceHipsStandardFraction + ) + points.waistCp1 = points.waist.shift(-90, points.waist.dy(points.hips) / 3) + points.hipsCp2 = points.hips.shift(90, points.waist.dy(points.hips) / 3) + points.hem = new Point(points.hips.x, points.hem.y) - points.sideHips = points.hips.flipX(points.fsWaist); - points.sideHem = points.hem.flipX(points.fsWaist); - points.sideWaist = points.waist.flipX(points.fsWaist); - points.sideWaistCp1 = points.waistCp1.flipX(points.fsWaist); - points.sideWaistCp2 = points.waistCp2.flipX(points.fsWaist); - points.sideHipsCp2 = points.hipsCp2.flipX(points.fsWaist); + points.sideHips = points.hips.flipX(points.fsWaist) + points.sideHem = points.hem.flipX(points.fsWaist) + points.sideWaist = points.waist.flipX(points.fsWaist) + points.sideWaistCp1 = points.waistCp1.flipX(points.fsWaist) + points.sideWaistCp2 = points.waistCp2.flipX(points.fsWaist) + points.sideHipsCp2 = points.hipsCp2.flipX(points.fsWaist) // Match side seam length by shifting armhole upwards let frontLength = new Path() @@ -68,68 +67,71 @@ export default function(part) { .line(points.hips) .curve(points.hipsCp2, points.waistCp1, points.waist) .curve_(points.waistCp2, points.split) - .length(); + .length() let sideLength = new Path() .move(points.sideHem) .line(points.sideHips) .curve(points.sideHipsCp2, points.sideWaistCp1, points.sideWaist) .curve_(points.sideWaistCp2, points.split) - .length(); - points.sideArmhole = points.armhole.shift(90, frontLength - sideLength); - points.sideArmholeCp2 = points.sideArmholeCp2.shift(90, frontLength - sideLength); - points.bsArmholeCp2 = points.bsArmholeCp2.shift(90, frontLength - sideLength); + .length() + points.sideArmhole = points.armhole.shift(90, frontLength - sideLength) + points.sideArmholeCp2 = points.sideArmholeCp2.shift(90, frontLength - sideLength) + points.bsArmholeCp2 = points.bsArmholeCp2.shift(90, frontLength - sideLength) /** * Shape the side/back seam (15% of reduction x 2) */ - points.bsWaist = points.bsWaist.shift(180, store.get("waistReduction") * options.reduceWaistStandardFraction); - points.bsWaistCp2 = new Point(points.bsWaist.x, points.sideWaistCp2.y); - points.bsWaistCp1 = new Point(points.bsWaist.x, points.sideWaistCp1.y); - points.bsHips = points.bsHips.shift(180, store.get("hipsReduction") * options.reduceHipsStandardFraction); - points.bsHipsCp2 = new Point(points.bsHips.x, points.sideHipsCp2.y); - points.bsHem = new Point(points.bsHips.x, points.sideHem.y); + points.bsWaist = points.bsWaist.shift( + 180, + store.get('waistReduction') * options.reduceWaistStandardFraction + ) + points.bsWaistCp2 = new Point(points.bsWaist.x, points.sideWaistCp2.y) + points.bsWaistCp1 = new Point(points.bsWaist.x, points.sideWaistCp1.y) + points.bsHips = points.bsHips.shift( + 180, + store.get('hipsReduction') * options.reduceHipsStandardFraction + ) + points.bsHipsCp2 = new Point(points.bsHips.x, points.sideHipsCp2.y) + points.bsHem = new Point(points.bsHips.x, points.sideHem.y) /** * Drop hem center front */ - points.cfHem = points.cfHem.shift(-90, points.cfHem.y * options.centerFrontHemDrop); + points.cfHem = points.cfHem.shift(-90, points.cfHem.y * options.centerFrontHemDrop) // When the hem slope would end of side and front were sewn together - points.hemDropEnd = points.hem.shift(0, points.sideHem.dx(points.bsHem)); - points.hem = utils.beamsIntersect( - points.cfHem, points.hemDropEnd, - points.hips, points.hem - ); - points.sideHem = points.hem.flipX(points.fsHem); + points.hemDropEnd = points.hem.shift(0, points.sideHem.dx(points.bsHem)) + points.hem = utils.beamsIntersect(points.cfHem, points.hemDropEnd, points.hips, points.hem) + points.sideHem = points.hem.flipX(points.fsHem) /** * Front dart (12.5% of reduction x 2) */ - points.dart = new Point( - points.waist.x * options.frontDartPlacement, - points.waist.y - ); - points.dartTop = points.dart.shift(90, points.armhole.dy(points.waist) / 1.5); - points.dartBottom = points.dart.shift(-90, points.waist.dy(points.hips) / 1.5); - points.dartRight = points.dart.shift(0, store.get("waistReduction") * options.reduceWaistDartFraction); - points.dartLeft = points.dartRight.flipX(points.dart); - points.dartRightCpTop = points.dartRight.shift(90, points.dartTop.dy(points.dart)/3); - points.dartLeftCpTop = points.dartRightCpTop.flipX(points.dart); - points.dartRightCpBottom = points.dartRight.shift(-90, points.dart.dy(points.dartBottom)/3); - points.dartLeftCpBottom = points.dartRightCpBottom.flipX(points.dart); + points.dart = new Point(points.waist.x * options.frontDartPlacement, points.waist.y) + points.dartTop = points.dart.shift(90, points.armhole.dy(points.waist) / 1.5) + points.dartBottom = points.dart.shift(-90, points.waist.dy(points.hips) / 1.5) + points.dartRight = points.dart.shift( + 0, + store.get('waistReduction') * options.reduceWaistDartFraction + ) + points.dartLeft = points.dartRight.flipX(points.dart) + points.dartRightCpTop = points.dartRight.shift(90, points.dartTop.dy(points.dart) / 3) + points.dartLeftCpTop = points.dartRightCpTop.flipX(points.dart) + points.dartRightCpBottom = points.dartRight.shift(-90, points.dart.dy(points.dartBottom) / 3) + points.dartLeftCpBottom = points.dartRightCpBottom.flipX(points.dart) // Front pocket points.frontPocketAnchor = new Point( points.hips.x * options.frontPocketPlacement, points.dartRightCpBottom.y - ); - let width = points.hips.x * options.frontPocketWidth; - let depth = width * options.frontPocketDepth; - points.frontPocketTopLeft = points.frontPocketAnchor.shift(180, width/2); - points.frontPocketTopRight = points.frontPocketTopLeft.flipX(points.frontPocketAnchor); - points.frontPocketBottomLeft = points.frontPocketTopLeft.shift(-90, depth); - points.frontPocketBottomRight = points.frontPocketBottomLeft.flipX(points.frontPocketAnchor); - store.set("pocketWidth", width); - store.set("pocketDepth", depth); + ) + let width = points.hips.x * options.frontPocketWidth + let depth = width * options.frontPocketDepth + points.frontPocketTopLeft = points.frontPocketAnchor.shift(180, width / 2) + points.frontPocketTopRight = points.frontPocketTopLeft.flipX(points.frontPocketAnchor) + points.frontPocketBottomLeft = points.frontPocketTopLeft.shift(-90, depth) + points.frontPocketBottomRight = points.frontPocketBottomLeft.flipX(points.frontPocketAnchor) + store.set('pocketWidth', width) + store.set('pocketDepth', depth) points.frontPocketTopEnd = utils.curveIntersectsY( points.waist, @@ -137,12 +139,12 @@ export default function(part) { points.hipsCp2, points.hips, points.frontPocketTopLeft.y - ); + ) points.frontPocketBottomEnd = utils.beamIntersectsY( points.hips, points.hem, points.frontPocketBottomLeft.y - ); + ) paths.dart = new Path() .move(points.dartRight) @@ -150,7 +152,7 @@ export default function(part) { ._curve(points.dartLeftCpTop, points.dartLeft) .curve_(points.dartLeftCpBottom, points.dartBottom) ._curve(points.dartRightCpBottom, points.dartRight) - .close(); + .close() paths.frontShaping = new Path() .move(points.hem) @@ -160,14 +162,14 @@ export default function(part) { ._curve(points.sideWaistCp2, points.sideWaist) .curve(points.sideWaistCp1, points.sideHipsCp2, points.sideHips) .line(points.sideHem) - .attr("class", "stroke-xxl various lashed"); + .attr('class', 'stroke-xxl various lashed') paths.sideShaping = new Path() .move(points.bsHem) .line(points.bsHips) .curve(points.bsHipsCp2, points.bsWaistCp1, points.bsWaist) .curve_(points.bsWaistCp2, points.bsArmholeHollow) - .attr("class", "stroke-xl facing lashed"); + .attr('class', 'stroke-xl facing lashed') - return part; + return part } diff --git a/packages/jaeger/src/index.js b/packages/jaeger/src/index.js index 179bf6f9f5b..7ca3acadfc9 100644 --- a/packages/jaeger/src/index.js +++ b/packages/jaeger/src/index.js @@ -1,65 +1,65 @@ -import freesewing from "@freesewing/core"; -import plugins from "@freesewing/plugin-bundle"; -import buttons from "@freesewing/plugin-buttons"; -import Bent from "@freesewing/bent"; -import config from "../config"; +import freesewing from '@freesewing/core' +import plugins from '@freesewing/plugin-bundle' +import buttons from '@freesewing/plugin-buttons' +import Bent from '@freesewing/bent' +import config from '../config' // Parts -import draftBackBase from "./backbase"; -import draftFrontBase from "./frontbase"; -import draftFront from "./front"; -import draftBack from "./back"; -import draftSide from "./side"; -import draftCollarStand from "./collarstand"; -import draftCollar from "./collar"; -import draftUnderCollar from "./undercollar"; -import draftPocket from "./pocket"; -import draftPocketLining from "./pocketlining"; -import draftChestPocketWelt from "./chestpocketwelt"; -import draftChestPocketBag from "./chestpocketbag"; -import draftInnerPocketWelt from "./innerpocketwelt"; -import draftInnerPocketBag from "./innerpocketbag"; -import draftTopSleeve from "./topsleeve"; -import draftUnderSleeve from "./undersleeve"; +import draftBackBase from './backbase' +import draftFrontBase from './frontbase' +import draftFront from './front' +import draftBack from './back' +import draftSide from './side' +import draftCollarStand from './collarstand' +import draftCollar from './collar' +import draftUnderCollar from './undercollar' +import draftPocket from './pocket' +import draftPocketLining from './pocketlining' +import draftChestPocketWelt from './chestpocketwelt' +import draftChestPocketBag from './chestpocketbag' +import draftInnerPocketWelt from './innerpocketwelt' +import draftInnerPocketBag from './innerpocketbag' +import draftTopSleeve from './topsleeve' +import draftUnderSleeve from './undersleeve' // Create new design -const Pattern = new freesewing.Design(config, [plugins, buttons]); +const Pattern = new freesewing.Design(config, [plugins, buttons]) // Attach draft methods from Bent to prototype Pattern.prototype.draftBentBase = function(part) { - return new Bent(this.settings).draftBase(part); -}; + return new Bent(this.settings).draftBase(part) +} Pattern.prototype.draftBentFront = function(part) { - return new Bent(this.settings).draftFront(part); -}; + return new Bent(this.settings).draftFront(part) +} Pattern.prototype.draftBentBack = function(part) { - return new Bent(this.settings).draftBack(part); -}; + return new Bent(this.settings).draftBack(part) +} Pattern.prototype.draftBentSleeve = function(part) { - return new Bent(this.settings).draftSleeve(part); -}; + return new Bent(this.settings).draftSleeve(part) +} Pattern.prototype.draftBentTopSleeve = function(part) { - return new Bent(this.settings).draftTopSleeve(part); -}; + return new Bent(this.settings).draftTopSleeve(part) +} Pattern.prototype.draftBentUnderSleeve = function(part) { - return new Bent(this.settings).draftUnderSleeve(part); -}; + return new Bent(this.settings).draftUnderSleeve(part) +} // Attach own draft methods to prototype -Pattern.prototype.draftBackBase = draftBackBase; -Pattern.prototype.draftFrontBase = draftFrontBase; -Pattern.prototype.draftFront = draftFront; -Pattern.prototype.draftBack = draftBack; -Pattern.prototype.draftSide = draftSide; -Pattern.prototype.draftCollarStand = draftCollarStand; -Pattern.prototype.draftCollar = draftCollar; -Pattern.prototype.draftUnderCollar = draftUnderCollar; -Pattern.prototype.draftPocket = draftPocket; -Pattern.prototype.draftPocketLining = draftPocketLining; -Pattern.prototype.draftChestPocketWelt = draftChestPocketWelt; -Pattern.prototype.draftChestPocketBag = draftChestPocketBag; -Pattern.prototype.draftInnerPocketWelt = draftInnerPocketWelt; -Pattern.prototype.draftInnerPocketBag = draftInnerPocketBag; -Pattern.prototype.draftTopSleeve = draftTopSleeve; -Pattern.prototype.draftUnderSleeve = draftUnderSleeve; +Pattern.prototype.draftBackBase = draftBackBase +Pattern.prototype.draftFrontBase = draftFrontBase +Pattern.prototype.draftFront = draftFront +Pattern.prototype.draftBack = draftBack +Pattern.prototype.draftSide = draftSide +Pattern.prototype.draftCollarStand = draftCollarStand +Pattern.prototype.draftCollar = draftCollar +Pattern.prototype.draftUnderCollar = draftUnderCollar +Pattern.prototype.draftPocket = draftPocket +Pattern.prototype.draftPocketLining = draftPocketLining +Pattern.prototype.draftChestPocketWelt = draftChestPocketWelt +Pattern.prototype.draftChestPocketBag = draftChestPocketBag +Pattern.prototype.draftInnerPocketWelt = draftInnerPocketWelt +Pattern.prototype.draftInnerPocketBag = draftInnerPocketBag +Pattern.prototype.draftTopSleeve = draftTopSleeve +Pattern.prototype.draftUnderSleeve = draftUnderSleeve -export default Pattern; +export default Pattern diff --git a/packages/jaeger/src/innerpocketbag.js b/packages/jaeger/src/innerpocketbag.js index fddc17569d8..28ebf30b30c 100644 --- a/packages/jaeger/src/innerpocketbag.js +++ b/packages/jaeger/src/innerpocketbag.js @@ -1,16 +1,27 @@ export default function(part) { - let { paperless, sa, store, complete, points, options, macro, Point, paths, Path } = part.shorthand(); + let { + paperless, + sa, + store, + complete, + points, + options, + macro, + Point, + paths, + Path + } = part.shorthand() - let width = store.get("innerPocketWidth"); - let welt = store.get("innerPocketWeltHeight"); - let height = width * options.innerPocketDepth; + let width = store.get('innerPocketWidth') + let welt = store.get('innerPocketWeltHeight') + let height = width * options.innerPocketDepth - points.topLeft = new Point(0, 0); - points.topRight = new Point(width, 0); - points.foldLeft = new Point(0, height); - points.foldRight = new Point(width, height); - points.bottomLeft = new Point(0, height*2 + welt*2); - points.bottomRight = new Point(width, height*2 + welt*2); + points.topLeft = new Point(0, 0) + points.topRight = new Point(width, 0) + points.foldLeft = new Point(0, height) + points.foldRight = new Point(width, height) + points.bottomLeft = new Point(0, height * 2 + welt * 2) + points.bottomRight = new Point(width, height * 2 + welt * 2) // Paths paths.seam = new Path() @@ -20,68 +31,66 @@ export default function(part) { .line(points.topRight) .line(points.topLeft) .close() - .attr("class", "lining"); + .attr('class', 'lining') paths.fold = new Path() .move(points.foldLeft) .line(points.foldRight) - .attr("class", "stroke-sm lining dashed"); + .attr('class', 'stroke-sm lining dashed') if (complete) { points.title = points.topLeft.shiftFractionTowards(points.foldRight, 0.5) // Title - macro("title", { + macro('title', { at: points.title, nr: 14, - title: "innerPocketBag" - }); + title: 'innerPocketBag' + }) // Grainline - macro("grainline", { + macro('grainline', { from: points.bottomLeft.shift(0, 10), to: points.topLeft.shift(0, 10) - }); + }) // Instructions - paths.fold - .attr("data-text", "foldAlongThisLine") - .attr("data-text-class", "center"); + paths.fold.attr('data-text', 'foldAlongThisLine').attr('data-text-class', 'center') - if (sa) paths.sa = paths.seam.offset(sa).attr("class", "lining sa"); + if (sa) paths.sa = paths.seam.offset(sa).attr('class', 'lining sa') if (paperless) { - macro("hd", { + macro('hd', { from: points.topLeft, to: points.topRight, y: points.topRight.y - sa - 15 - }); - macro("vd", { + }) + macro('vd', { from: points.bottomRight, to: points.foldRight, x: points.topRight.x + sa + 15 - }); - macro("vd", { + }) + macro('vd', { from: points.foldRight, to: points.topRight, x: points.topRight.x + sa + 15 - }); - macro("vd", { + }) + macro('vd', { from: points.bottomRight, to: points.topRight, x: points.topRight.x + sa + 30 - }); - macro("vd", { + }) + macro('vd', { from: points.bottomLeft, to: points.foldLeft, x: points.topLeft.x - sa - 15 - }); - macro("vd", { + }) + macro('vd', { from: points.foldLeft, to: points.topLeft, x: points.topLeft.x - sa - 15 - }); + }) } } - return part; + return part } diff --git a/packages/jaeger/src/innerpocketwelt.js b/packages/jaeger/src/innerpocketwelt.js index 0fba6cc266c..99bab668c24 100644 --- a/packages/jaeger/src/innerpocketwelt.js +++ b/packages/jaeger/src/innerpocketwelt.js @@ -1,15 +1,15 @@ export default function(part) { - let { paperless, sa, store, complete, points, macro, Point, paths, Path } = part.shorthand(); + let { paperless, sa, store, complete, points, macro, Point, paths, Path } = part.shorthand() - let width = store.get("innerPocketWidth"); - let height = store.get("innerPocketWeltHeight"); + let width = store.get('innerPocketWidth') + let height = store.get('innerPocketWeltHeight') - points.topLeft = new Point(0, 0); - points.topRight = new Point(width, 0); - points.foldLeft = new Point(0, height); - points.foldRight = new Point(width, height); - points.bottomLeft = new Point(0, height*2); - points.bottomRight = new Point(width, height*2); + points.topLeft = new Point(0, 0) + points.topRight = new Point(width, 0) + points.foldLeft = new Point(0, height) + points.foldRight = new Point(width, height) + points.bottomLeft = new Point(0, height * 2) + points.bottomRight = new Point(width, height * 2) // Paths paths.seam = new Path() @@ -19,37 +19,37 @@ export default function(part) { .line(points.topRight) .line(points.topLeft) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') paths.fold = new Path() .move(points.foldLeft) .line(points.foldRight) - .attr("class", "stroke-sm dashed"); + .attr('class', 'stroke-sm dashed') if (complete) { - points.title = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5); + points.title = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5) // Title - macro("title", { + macro('title', { at: points.title, nr: 13, - title: "innerPocketWelt" - }); + title: 'innerPocketWelt' + }) - if (sa) paths.sa = paths.seam.offset(sa).attr("class", "fabric sa"); + if (sa) paths.sa = paths.seam.offset(sa).attr('class', 'fabric sa') if (paperless) { - macro("hd", { + macro('hd', { from: points.topLeft, to: points.topRight, y: points.topRight.y - sa - 15 - }); - macro("vd", { + }) + macro('vd', { from: points.bottomRight, to: points.topRight, x: points.topRight.x + sa + 15 - }); + }) } } - return part; + return part } diff --git a/packages/jaeger/src/pocket.js b/packages/jaeger/src/pocket.js index 11e9048395c..566c456f7a8 100644 --- a/packages/jaeger/src/pocket.js +++ b/packages/jaeger/src/pocket.js @@ -1,39 +1,47 @@ export default function(part) { - let { paperless, sa, store, complete, points, options, macro, Point, paths, Path } = part.shorthand(); + let { + paperless, + sa, + store, + complete, + points, + options, + macro, + Point, + paths, + Path + } = part.shorthand() - let width = store.get("pocketWidth"); - let depth = store.get("pocketDepth"); + let width = store.get('pocketWidth') + let depth = store.get('pocketDepth') - points.topLeft = new Point(0, 0); - points.topRight = new Point(width, 0); - points.bottomLeft = new Point(0, depth); - points.bottomRight = new Point(width, depth); + points.topLeft = new Point(0, 0) + points.topRight = new Point(width, 0) + points.bottomLeft = new Point(0, depth) + points.bottomRight = new Point(width, depth) // Add foldover points points.edgeLeft = points.bottomLeft.shiftFractionTowards( points.topLeft, 1 + options.pocketFoldover - ); - points.edgeRight = new Point( - points.topRight.x, - points.edgeLeft.y - ); + ) + points.edgeRight = new Point(points.topRight.x, points.edgeLeft.y) // Round the pocket if (options.frontPocketRadius > 0) { - macro("round", { + macro('round', { from: points.topLeft, to: points.bottomRight, via: points.bottomLeft, radius: width * options.frontPocketRadius, - prefix: "left" - }); - macro("round", { + prefix: 'left' + }) + macro('round', { from: points.bottomLeft, to: points.topRight, via: points.bottomRight, radius: width * options.frontPocketRadius, - prefix: "right" - }); + prefix: 'right' + }) } // Paths @@ -47,7 +55,7 @@ export default function(part) { .line(points.edgeRight) .line(points.edgeLeft) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') } else { paths.seam = new Path() .move(points.edgeLeft) @@ -56,55 +64,53 @@ export default function(part) { .line(points.edgeRight) .line(points.edgeLeft) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') } paths.fold = new Path() .move(points.topLeft) .line(points.topRight) - .attr("class", "fabric dashed"); + .attr('class', 'fabric dashed') if (complete) { // Title - points.title = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5); - macro("title", { + points.title = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5) + macro('title', { at: points.title, nr: 9, - title: "pocket" - }); + title: 'pocket' + }) // Instructions - paths.fold - .attr("data-text", "foldAlongThisLine") - .attr("data-text-class", "center"); + paths.fold.attr('data-text', 'foldAlongThisLine').attr('data-text-class', 'center') // Grainline - macro("grainline", { - from: points.bottomLeft.shift(0 ,10), - to: points.edgeLeft.shift(0 ,10) - }); + macro('grainline', { + from: points.bottomLeft.shift(0, 10), + to: points.edgeLeft.shift(0, 10) + }) - if (sa) paths.sa = paths.seam.offset(sa).attr("class", "fabric sa"); + if (sa) paths.sa = paths.seam.offset(sa).attr('class', 'fabric sa') if (paperless) { - macro("hd", { + macro('hd', { from: points.edgeLeft, to: points.edgeRight, y: points.edgeLeft.y - sa - 15 - }); + }) let corner = points.bottomRight - if (options.frontPocketRadius > 0) corner = points.rightStart; - macro("vd", { + if (options.frontPocketRadius > 0) corner = points.rightStart + macro('vd', { from: corner, to: points.topRight, x: points.edgeRight.x + sa + 15 - }); - macro("vd", { + }) + macro('vd', { from: corner, to: points.edgeRight, x: points.edgeRight.x + sa + 30 - }); + }) } } - return part; + return part } diff --git a/packages/jaeger/src/pocketlining.js b/packages/jaeger/src/pocketlining.js index 04b147ba053..7de0acf461a 100644 --- a/packages/jaeger/src/pocketlining.js +++ b/packages/jaeger/src/pocketlining.js @@ -1,13 +1,13 @@ export default function(part) { - let { paperless, sa, snippets, complete, points, options, macro, paths, Path } = part.shorthand(); + let { paperless, sa, snippets, complete, points, options, macro, paths, Path } = part.shorthand() // Adapt length - points.topLeft = points.edgeLeft.flipY(points.topLeft); - points.topRight = points.edgeRight.flipY(points.topRight); + points.topLeft = points.edgeLeft.flipY(points.topLeft) + points.topRight = points.edgeRight.flipY(points.topRight) // Clean up - for (let i of Object.keys(paths)) delete paths[i]; - for (let i of Object.keys(snippets)) delete snippets[i]; + for (let i of Object.keys(paths)) delete paths[i] + for (let i of Object.keys(snippets)) delete snippets[i] // Paths if (options.frontPocketRadius > 0) { @@ -20,7 +20,7 @@ export default function(part) { .line(points.topRight) .line(points.topLeft) .close() - .attr("class", "lining"); + .attr('class', 'lining') } else { paths.seam = new Path() .move(points.topLeft) @@ -29,41 +29,41 @@ export default function(part) { .line(points.topRight) .line(points.topLeft) .close() - .attr("class", "lining"); + .attr('class', 'lining') } if (complete) { // Title - points.title = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5); - macro("title", { + points.title = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5) + macro('title', { at: points.title, nr: 10, - title: "pocketLining" - }); + title: 'pocketLining' + }) // Grainline - macro("grainline", { - from: points.bottomLeft.shift(0 ,10), - to: points.topLeft.shift(0 ,10) - }); + macro('grainline', { + from: points.bottomLeft.shift(0, 10), + to: points.topLeft.shift(0, 10) + }) - if (sa) paths.sa = paths.seam.offset(sa).attr("class", "lining sa"); + if (sa) paths.sa = paths.seam.offset(sa).attr('class', 'lining sa') if (paperless) { - macro("hd", { + macro('hd', { from: points.topLeft, to: points.topRight, y: points.topLeft.y - sa - 15 - }); + }) let corner = points.bottomRight - if (options.frontPocketRadius > 0) corner = points.rightStart; - macro("vd", { + if (options.frontPocketRadius > 0) corner = points.rightStart + macro('vd', { from: corner, to: points.topRight, x: points.topRight.x + sa + 15 - }); + }) } } - return part; + return part } diff --git a/packages/jaeger/src/shared.js b/packages/jaeger/src/shared.js index 832149b30e2..073995d0527 100644 --- a/packages/jaeger/src/shared.js +++ b/packages/jaeger/src/shared.js @@ -2,19 +2,20 @@ * This calculates a bunch of helper variables and stores them */ export const calculateRatios = part => { - let { store, measurements, options } = part.shorthand(); + let { store, measurements, options } = part.shorthand() // Make sure collar height makes sense - if (options.collarHeight * 2 < options.rollLineCollarHeight) options.rollLineCollarHeight = options.collarHeight * 2; + if (options.collarHeight * 2 < options.rollLineCollarHeight) + options.rollLineCollarHeight = options.collarHeight * 2 // Calculate different values for reducing from chest to hips via waist - store.set("chest", measurements.chestCircumference * (1 + options.chestEase)); - store.set("waist", measurements.naturalWaist * (1 + options.waistEase)); - store.set("hips", measurements.hipsCircumference * (1 + options.hipsEase)); + store.set('chest', measurements.chestCircumference * (1 + options.chestEase)) + store.set('waist', measurements.naturalWaist * (1 + options.waistEase)) + store.set('hips', measurements.hipsCircumference * (1 + options.hipsEase)) - store.set("waistReduction", store.get("chest") - store.get("waist")); - store.set("hipsReduction", store.get("chest") - store.get("hips")); -}; + store.set('waistReduction', store.get('chest') - store.get('waist')) + store.set('hipsReduction', store.get('chest') - store.get('hips')) +} /** * Draws the line seperating side panel (back-side boundary, aka bs) @@ -27,32 +28,28 @@ export const calculateRatios = part => { * * The optional flip parameter mirrors this for the front part */ -export const backSideBoundary = (part, flip=false) => { +export const backSideBoundary = (part, flip = false) => { + let { points, Point, paths, Path } = part.shorthand() - let { points, Point, paths, Path } = part.shorthand(); - - points.bsArmholeHollow = points.armholeHollow.clone(); - points.bsArmholeHollowCp2 = points.armholeHollowCp2.rotate(90, points.armholeHollow); - points.bsWaist = new Point( - points.bsArmholeHollowCp2.x, - points.waist.y - ); - points.bsHips = new Point(points.bsWaist.x, points.hips.y); - points.bsHem = new Point(points.bsWaist.x, points.hem.y); + points.bsArmholeHollow = points.armholeHollow.clone() + points.bsArmholeHollowCp2 = points.armholeHollowCp2.rotate(90, points.armholeHollow) + points.bsWaist = new Point(points.bsArmholeHollowCp2.x, points.waist.y) + points.bsHips = new Point(points.bsWaist.x, points.hips.y) + points.bsHem = new Point(points.bsWaist.x, points.hem.y) if (flip) { - points.bsArmholeHollowCp1 = points.armholeHollowCp1.clone(); - points.bsArmholeCp2 = points.armholeCp2.clone(); + points.bsArmholeHollowCp1 = points.armholeHollowCp1.clone() + points.bsArmholeCp2 = points.armholeCp2.clone() for (let p of [ - "bsArmholeHollow", - "bsArmholeHollowCp2", - "bsWaist", - "bsHips", - "bsHem", - "bsArmholeHollowCp1", - "bsArmholeCp2" + 'bsArmholeHollow', + 'bsArmholeHollowCp2', + 'bsWaist', + 'bsHips', + 'bsHem', + 'bsArmholeHollowCp1', + 'bsArmholeCp2' ]) { - points[p] = points[p].flipX(points.armhole); + points[p] = points[p].flipX(points.armhole) } } @@ -62,6 +59,6 @@ export const backSideBoundary = (part, flip=false) => { .move(points.bsHem) .line(points.bsWaist) ._curve(points.bsArmholeHollowCp2, points.bsArmholeHollow) - .attr("class", "stroke-xl lining lashed") - if (flip) paths.bs.curve(points.bsArmholeHollowCp1, points.bsArmholeCp2, points.armhole); + .attr('class', 'stroke-xl lining lashed') + if (flip) paths.bs.curve(points.bsArmholeHollowCp1, points.bsArmholeCp2, points.armhole) } diff --git a/packages/jaeger/src/side.js b/packages/jaeger/src/side.js index b56a0ab74fb..3c843c86fc2 100644 --- a/packages/jaeger/src/side.js +++ b/packages/jaeger/src/side.js @@ -1,9 +1,22 @@ export default function(part) { - let { paperless, sa, snippets, Snippet, utils, complete, points, measurements, options, macro, paths, Path } = part.shorthand(); + let { + paperless, + sa, + snippets, + Snippet, + utils, + complete, + points, + measurements, + options, + macro, + paths, + Path + } = part.shorthand() // Double back vent if (options.backVent === 2) { - let ventY = points.bsHips.y - points.bsWaistCp2.dy(points.bsHips) * options.backVentLength; + let ventY = points.bsHips.y - points.bsWaistCp2.dy(points.bsHips) * options.backVentLength // Vent tip points.ventStart = utils.curveIntersectsY( points.bsHips, @@ -11,14 +24,14 @@ export default function(part) { points.bsWaistCp1, points.bsWaist, ventY - ); + ) paths.ventBase = new Path() .move(points.bsWaist) .curve(points.bsWaistCp1, points.bsHipsCp2, points.bsHips) .split(points.ventStart) .pop() - .line(points.bsHem); - paths.vent = paths.ventBase.offset(measurements.neckCircumference / -10); + .line(points.bsHem) + paths.vent = paths.ventBase.offset(measurements.neckCircumference / -10) //paths.vent.render = false; points.ventSlopeStart = utils.lineIntersectsCurve( paths.vent.start(), @@ -27,42 +40,37 @@ export default function(part) { points.bsHipsCp2, points.bsWaistCp1, points.bsWaist - ); + ) // Mirror slope on vent - points.ventHem = utils.beamIntersectsX( - points.sideHem, - paths.vent.end(), - paths.vent.end().flipX(points.bsHem).x - ).flipX(points.bsHem); + points.ventHem = utils + .beamIntersectsX(points.sideHem, paths.vent.end(), paths.vent.end().flipX(points.bsHem).x) + .flipX(points.bsHem) } // Clean up - Remove this to understand what's going on - for (let i of Object.keys(paths)) - if(i !== "vent") delete paths[i]; - for (let i of Object.keys(snippets)) delete snippets[i]; + for (let i of Object.keys(paths)) if (i !== 'vent') delete paths[i] + for (let i of Object.keys(snippets)) delete snippets[i] // Paths - paths.hemBase = new Path() - .move(points.sideHem) - .line(points.bsHem); + paths.hemBase = new Path().move(points.sideHem).line(points.bsHem) if (options.backVent === 2) { - paths.hemBase - .line(points.ventHem) - .line(paths.vent.end()); - paths.saBase = paths.vent.clone() + paths.hemBase.line(points.ventHem).line(paths.vent.end()) + paths.saBase = paths.vent + .clone() .reverse() .line(points.ventSlopeStart) - .join(new Path() - .move(points.bsHips) - .curve(points.bsHipsCp2, points.bsWaistCp1, points.bsWaist) - .split(points.ventSlopeStart) - .pop() - ); + .join( + new Path() + .move(points.bsHips) + .curve(points.bsHipsCp2, points.bsWaistCp1, points.bsWaist) + .split(points.ventSlopeStart) + .pop() + ) } else { paths.saBase = new Path() .move(points.bsHem) .line(points.bsHips) - .curve(points.bsHipsCp2, points.bsWaistCp1, points.bsWaist); + .curve(points.bsHipsCp2, points.bsWaistCp1, points.bsWaist) } paths.saBase = paths.saBase .curve_(points.bsWaistCp2, points.bsArmholeHollow) @@ -76,83 +84,80 @@ export default function(part) { .clone() .join(paths.hemBase) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') if (complete) { // Logo - points.logo = points.sideHips.shiftFractionTowards(points.bsHips, 0.5); - snippets.logo = new Snippet("logo", points.logo); + points.logo = points.sideHips.shiftFractionTowards(points.bsHips, 0.5) + snippets.logo = new Snippet('logo', points.logo) // Notches - macro("sprinkle", { - snippet: "notch", - on: [ - "sideWaist", - "bsWaist", - ] - }); - points.title = points.sideWaistCp2.shiftFractionTowards(points.bsWaistCp2, 0.5); - macro("title", { + macro('sprinkle', { + snippet: 'notch', + on: ['sideWaist', 'bsWaist'] + }) + points.title = points.sideWaistCp2.shiftFractionTowards(points.bsWaistCp2, 0.5) + macro('title', { at: points.title, nr: 3, - title: "side" - }); + title: 'side' + }) if (sa) { paths.sa = paths.saBase .clone() .offset(sa) - .join(paths.hemBase.offset(sa*3)) + .join(paths.hemBase.offset(sa * 3)) .close() - .attr("class", "fabric sa"); + .attr('class', 'fabric sa') } if (paperless) { - macro("ld", { + macro('ld', { from: points.sideWaist, - to:points.bsWaist - }); - macro("hd", { + to: points.bsWaist + }) + macro('hd', { from: points.sideHem, - to:points.bsHem, - y: points.sideHem.y + 3*sa + 15 - }); - macro("hd", { + to: points.bsHem, + y: points.sideHem.y + 3 * sa + 15 + }) + macro('hd', { from: points.fsArmhole, - to:points.bsArmholeHollow, + to: points.bsArmholeHollow, y: points.bsArmholeHollow.y - sa - 15 - }); - macro("vd", { + }) + macro('vd', { from: points.bsHem, - to:points.bsHips, + to: points.bsHips, x: points.bsHips.x + sa + 15 - }); - macro("vd", { + }) + macro('vd', { from: points.bsHem, - to:points.bsWaist, + to: points.bsWaist, x: points.bsHips.x + sa + 30 - }); - macro("vd", { + }) + macro('vd', { from: points.bsHem, - to:points.bsArmholeHollow, + to: points.bsArmholeHollow, x: points.bsHips.x + sa + 45 - }); - macro("vd", { + }) + macro('vd', { from: points.sideHem, - to:points.bsArmholeHollow, + to: points.bsArmholeHollow, x: points.bsHips.x + sa + 60 - }); - macro("vd", { + }) + macro('vd', { from: points.sideHem, - to:points.sideWaist, + to: points.sideWaist, x: points.sideHem.x - sa - 15 - }); - macro("vd", { + }) + macro('vd', { from: points.sideWaist, - to:points.fsArmhole, + to: points.fsArmhole, x: points.sideHem.x - sa - 15 - }); + }) } } - return part; + return part } diff --git a/packages/jaeger/src/topsleeve.js b/packages/jaeger/src/topsleeve.js index 900ff545824..a2acd255bb4 100644 --- a/packages/jaeger/src/topsleeve.js +++ b/packages/jaeger/src/topsleeve.js @@ -1,49 +1,76 @@ export default function(part) { - let { paperless, sa, utils, complete, points, measurements, options, macro, paths, Path } = part.shorthand(); + let { + paperless, + sa, + utils, + complete, + points, + measurements, + options, + macro, + paths, + Path + } = part.shorthand() // Vent - let slope = 15; - let width = measurements.wristCircumference * (1 + options.cuffEase) * options.sleeveVentWidth; - points.ventFoldRight = points.tsWristLeft.shiftOutwards(points.tsWristRight, width); - points.ventHelper = points.tsWristRight.shiftFractionTowards(points.elbowRight, options.sleeveVentLength); + let slope = 15 + let width = measurements.wristCircumference * (1 + options.cuffEase) * options.sleeveVentWidth + points.ventFoldRight = points.tsWristLeft.shiftOutwards(points.tsWristRight, width) + points.ventHelper = points.tsWristRight.shiftFractionTowards( + points.elbowRight, + options.sleeveVentLength + ) points.ventSlopeEnd = points.ventHelper .shiftTowards(points.tsWristRight, width) - .rotate(90, points.ventHelper); + .rotate(90, points.ventHelper) points.ventSlopeStart = utils.beamsIntersect( - points.tsWristRight, points.elbowRight, - points.ventSlopeEnd, points.ventHelper.rotate(-1 * slope, points.ventSlopeEnd) - ); + points.tsWristRight, + points.elbowRight, + points.ventSlopeEnd, + points.ventHelper.rotate(-1 * slope, points.ventSlopeEnd) + ) // Hem - let hemSa = sa ? 3*sa : 30; + let hemSa = sa ? 3 * sa : 30 points.hemHelperLeft = points.tsWristLeft .shiftTowards(points.tsWristRight, hemSa) - .rotate(90, points.tsWristLeft); + .rotate(90, points.tsWristLeft) points.hemHelperRight = points.tsWristRight .shiftTowards(points.tsWristLeft, hemSa) - .rotate(-90, points.tsWristRight); + .rotate(-90, points.tsWristRight) points.hemLeftIntersection = utils.beamsIntersect( - points.hemHelperLeft, points.hemHelperRight, - points.tsWristLeft, points.tsElbowLeft - ); + points.hemHelperLeft, + points.hemHelperRight, + points.tsWristLeft, + points.tsElbowLeft + ) points.hemRightIntersection = utils.beamsIntersect( - points.hemHelperLeft, points.hemHelperRight, - points.tsWristRight, points.elbowRight - ); + points.hemHelperLeft, + points.hemHelperRight, + points.tsWristRight, + points.elbowRight + ) points.hemVentIntersection = utils.beamsIntersect( - points.hemHelperLeft, points.hemHelperRight, - points.ventFoldRight, points.ventSlopeEnd - ); - points.hemLeft = points.hemLeftIntersection - .rotate(points.tsWristLeft.angle(points.hemLeftIntersection) * -2, points.tsWristLeft); - points.hemRight = points.hemRightIntersection - .rotate(points.tsWristRight.angle(points.hemRightIntersection) * -2, points.tsWristRight); - points.ventRight = points.hemVentIntersection - .rotate(points.ventFoldRight.angle(points.hemVentIntersection) * -2, points.ventFoldRight); - + points.hemHelperLeft, + points.hemHelperRight, + points.ventFoldRight, + points.ventSlopeEnd + ) + points.hemLeft = points.hemLeftIntersection.rotate( + points.tsWristLeft.angle(points.hemLeftIntersection) * -2, + points.tsWristLeft + ) + points.hemRight = points.hemRightIntersection.rotate( + points.tsWristRight.angle(points.hemRightIntersection) * -2, + points.tsWristRight + ) + points.ventRight = points.hemVentIntersection.rotate( + points.ventFoldRight.angle(points.hemVentIntersection) * -2, + points.ventFoldRight + ) // Clean up - Remove this and uncomment paths below to understand what's going on - for (let i of Object.keys(paths)) delete paths[i]; + for (let i of Object.keys(paths)) delete paths[i] // Paths paths.seam = new Path() @@ -62,130 +89,126 @@ export default function(part) { .line(points.ventRight) .line(points.ventFoldRight) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') paths.ventHint = new Path() .move(points.ventSlopeStart) .line(points.tsWristRight) - .attr("class", "stroke-sm help"); + .attr('class', 'stroke-sm help') paths.hem = new Path() .move(points.tsWristLeft) .line(points.ventFoldRight) - .attr("class", "fabric lashed"); + .attr('class', 'fabric lashed') if (complete) { // Notches - macro("sprinkle", { - snippet: "notch", - on: [ - "top", - "tsElbowLeft", - "elbowRight", - ] - }); + macro('sprinkle', { + snippet: 'notch', + on: ['top', 'tsElbowLeft', 'elbowRight'] + }) // Title - points.title = points.tsLeftEdge.shiftFractionTowards(points.tsRightEdge, 0.5); - macro("title", { + points.title = points.tsLeftEdge.shiftFractionTowards(points.tsRightEdge, 0.5) + macro('title', { at: points.title, nr: 4, - title: "topSleeve" - }); + title: 'topSleeve' + }) // Grainline - macro("grainline", { + macro('grainline', { from: points.boxBottom, to: points.top - }); + }) - if (sa) paths.sa = paths.seam.offset(sa).attr("class", "fabric sa"); + if (sa) paths.sa = paths.seam.offset(sa).attr('class', 'fabric sa') if (paperless) { - macro("ld", { + macro('ld', { from: points.tsWristLeft, to: points.tsWristRight, d: 15 - }); - macro("ld", { + }) + macro('ld', { from: points.tsWristLeft, to: points.ventFoldRight, d: 30 - }); - macro("ld", { + }) + macro('ld', { from: points.hemLeft, to: points.ventRight, d: -15 - sa - }); - macro("ld", { + }) + macro('ld', { from: points.hemLeft, to: points.tsWristLeft, d: 15 + sa - }); - macro("ld", { + }) + macro('ld', { from: points.tsWristRight, to: points.ventSlopeStart, d: 15 - }); - macro("ld", { + }) + macro('ld', { from: points.ventFoldRight, to: points.ventSlopeEnd, d: 15 - }); - macro("ld", { + }) + macro('ld', { from: points.tsWristRight, to: points.ventFoldRight, d: -15 - }); - macro("vd", { + }) + macro('vd', { from: points.ventRight, to: points.top, x: points.ventSlopeEnd.x + sa + 15 - }); - macro("vd", { + }) + macro('vd', { from: points.tsWristLeft, to: points.tsElbowLeft, x: points.tsLeftEdge.x - sa - 15 - }); - macro("vd", { + }) + macro('vd', { from: points.tsWristLeft, to: points.tsLeftEdge, x: points.tsLeftEdge.x - sa - 30 - }); - macro("vd", { + }) + macro('vd', { from: points.tsLeftEdge, to: points.top, x: points.tsLeftEdge.x - sa - 30 - }); - macro("vd", { + }) + macro('vd', { from: points.tsWristLeft, to: points.top, x: points.tsLeftEdge.x - sa - 45 - }); - macro("ld", { + }) + macro('ld', { from: points.tsLeftEdge, - to: points.tsRightEdge, - }); - macro("ld", { + to: points.tsRightEdge + }) + macro('ld', { from: points.tsElbowLeft, - to: points.elbowRight, - }); - macro("hd", { + to: points.elbowRight + }) + macro('hd', { from: points.tsLeftEdge, to: points.top, y: points.top.y - sa - 15 - }); - macro("hd", { + }) + macro('hd', { from: points.tsLeftEdge, to: points.backPitchPoint, y: points.top.y - sa - 30 - }); - macro("hd", { + }) + macro('hd', { from: points.tsLeftEdge, to: points.tsRightEdge, y: points.top.y - sa - 45 - }); + }) } } - return part; + return part } diff --git a/packages/jaeger/src/undercollar.js b/packages/jaeger/src/undercollar.js index 4a676083888..f4cef200724 100644 --- a/packages/jaeger/src/undercollar.js +++ b/packages/jaeger/src/undercollar.js @@ -6,11 +6,11 @@ */ export default function(part) { - let { paperless, sa, snippets, complete, points, macro, paths, Path } = part.shorthand(); + let { paperless, sa, snippets, complete, points, macro, paths, Path } = part.shorthand() // Clean up - for (let i of Object.keys(paths)) delete paths[i]; - for (let i of Object.keys(snippets)) delete snippets[i]; + for (let i of Object.keys(paths)) delete paths[i] + for (let i of Object.keys(snippets)) delete snippets[i] paths.seam = new Path() .move(points.collarCbTop) @@ -20,27 +20,27 @@ export default function(part) { ._curve(points.collarstandCbTopCp, points.collarstandCbTop) .line(points.collarCbTop) .close() - .attr("class", "various"); + .attr('class', 'various') if (complete) { // Title - points.title = points.collarCbTopCp.shiftFractionTowards(points.collarstandCbTopCp, 0.5); - macro("title", { + points.title = points.collarCbTopCp.shiftFractionTowards(points.collarstandCbTopCp, 0.5) + macro('title', { at: points.title, nr: 6, - title: "underCollar" - }); + title: 'underCollar' + }) if (sa) { paths.sa1 = new Path() .move(points.collarstandCbTop) .line(points.collarCbTop) - .offset(sa); + .offset(sa) paths.sa2 = new Path() .move(points.collarstandTip) .line(points.notch) .line(points.notchTip) - .offset(-1 * sa); + .offset(-1 * sa) paths.sa = new Path() .move(points.collarstandTip) .line(paths.sa2.start()) @@ -50,49 +50,49 @@ export default function(part) { .line(paths.sa1.start()) .line(paths.sa1.end()) .line(points.collarCbTop) - .attr("class", "various sa"); - paths.sa1.render = false; - paths.sa2.render = false; + .attr('class', 'various sa') + paths.sa1.render = false + paths.sa2.render = false } if (paperless) { - macro("hd", { + macro('hd', { from: points.collarstandCbTop, to: points.collarstandTip, y: points.collarstandCbTop.y - 15 - }); - macro("hd", { + }) + macro('hd', { from: points.collarstandCbTop, to: points.notch, y: points.collarstandCbTop.y - 30 - }); - macro("hd", { + }) + macro('hd', { from: points.collarCbTop, to: points.notchTip, y: points.notchTip.y + 15 - }); - macro("vd", { + }) + macro('vd', { from: points.collarCbTop, to: points.collarstandCbTop, x: points.collarCbTop.x - sa - 15 - }); - macro("ld", { + }) + macro('ld', { from: points.collarstandTip, to: points.notch, d: sa + 15 - }); - macro("ld", { + }) + macro('ld', { from: points.notchTip, to: points.notch, d: -15 - sa - }); - macro("vd", { + }) + macro('vd', { from: points.notchTip, to: points.collarstandCbTop, x: points.notch.x + sa + 40 - }); + }) } } - return part; + return part } diff --git a/packages/jaeger/src/undersleeve.js b/packages/jaeger/src/undersleeve.js index 468569a0ed6..a5cd2640f2a 100644 --- a/packages/jaeger/src/undersleeve.js +++ b/packages/jaeger/src/undersleeve.js @@ -1,48 +1,76 @@ export default function(part) { - let { paperless, sa, utils, complete, points, measurements, options, macro, paths, Path } = part.shorthand(); + let { + paperless, + sa, + utils, + complete, + points, + measurements, + options, + macro, + paths, + Path + } = part.shorthand() // Vent - let slope = 15; - let width = measurements.wristCircumference * (1 + options.cuffEase) * options.sleeveVentWidth; - points.ventFoldRight = points.usWristLeft.shiftOutwards(points.usWristRight, width); - points.ventHelper = points.usWristRight.shiftFractionTowards(points.elbowRight, options.sleeveVentLength); + let slope = 15 + let width = measurements.wristCircumference * (1 + options.cuffEase) * options.sleeveVentWidth + points.ventFoldRight = points.usWristLeft.shiftOutwards(points.usWristRight, width) + points.ventHelper = points.usWristRight.shiftFractionTowards( + points.elbowRight, + options.sleeveVentLength + ) points.ventSlopeEnd = points.ventHelper .shiftTowards(points.usWristRight, width) - .rotate(90, points.ventHelper); + .rotate(90, points.ventHelper) points.ventSlopeStart = utils.beamsIntersect( - points.usWristRight, points.elbowRight, - points.ventSlopeEnd, points.ventHelper.rotate(-1 * slope, points.ventSlopeEnd) - ); + points.usWristRight, + points.elbowRight, + points.ventSlopeEnd, + points.ventHelper.rotate(-1 * slope, points.ventSlopeEnd) + ) // Hem - let hemSa = sa ? 3*sa : 30; + let hemSa = sa ? 3 * sa : 30 points.hemHelperLeft = points.usWristLeft .shiftTowards(points.usWristRight, hemSa) - .rotate(90, points.usWristLeft); + .rotate(90, points.usWristLeft) points.hemHelperRight = points.usWristRight .shiftTowards(points.usWristLeft, hemSa) - .rotate(-90, points.usWristRight); + .rotate(-90, points.usWristRight) points.hemLeftIntersection = utils.beamsIntersect( - points.hemHelperLeft, points.hemHelperRight, - points.usWristLeft, points.usElbowLeft - ); + points.hemHelperLeft, + points.hemHelperRight, + points.usWristLeft, + points.usElbowLeft + ) points.hemRightIntersection = utils.beamsIntersect( - points.hemHelperLeft, points.hemHelperRight, - points.usWristRight, points.elbowRight - ); + points.hemHelperLeft, + points.hemHelperRight, + points.usWristRight, + points.elbowRight + ) points.hemVentIntersection = utils.beamsIntersect( - points.hemHelperLeft, points.hemHelperRight, - points.ventFoldRight, points.ventSlopeEnd - ); - points.hemLeft = points.hemLeftIntersection - .rotate(points.usWristLeft.angle(points.hemLeftIntersection) * -2, points.usWristLeft); - points.hemRight = points.hemRightIntersection - .rotate(points.usWristRight.angle(points.hemRightIntersection) * -2, points.usWristRight); - points.ventRight = points.hemVentIntersection - .rotate(points.ventFoldRight.angle(points.hemVentIntersection) * -2, points.ventFoldRight); + points.hemHelperLeft, + points.hemHelperRight, + points.ventFoldRight, + points.ventSlopeEnd + ) + points.hemLeft = points.hemLeftIntersection.rotate( + points.usWristLeft.angle(points.hemLeftIntersection) * -2, + points.usWristLeft + ) + points.hemRight = points.hemRightIntersection.rotate( + points.usWristRight.angle(points.hemRightIntersection) * -2, + points.usWristRight + ) + points.ventRight = points.hemVentIntersection.rotate( + points.ventFoldRight.angle(points.hemVentIntersection) * -2, + points.ventFoldRight + ) // Clean up - Remove this and uncomment paths below to understand what's going on - for (let i of Object.keys(paths)) delete paths[i]; + for (let i of Object.keys(paths)) delete paths[i] // Paths paths.seam = new Path() @@ -60,116 +88,112 @@ export default function(part) { .line(points.ventRight) .line(points.ventFoldRight) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') paths.ventHint = new Path() .move(points.ventSlopeStart) .line(points.usWristRight) - .attr("class", "stroke-sm help"); + .attr('class', 'stroke-sm help') paths.hem = new Path() .move(points.usWristLeft) .line(points.ventFoldRight) - .attr("class", "fabric lashed"); + .attr('class', 'fabric lashed') if (complete) { // Notches - macro("sprinkle", { - snippet: "notch", - on: [ - "top", - "usElbowLeft", - "elbowRight", - ] - }); + macro('sprinkle', { + snippet: 'notch', + on: ['top', 'usElbowLeft', 'elbowRight'] + }) // Title - points.title = points.tsLeftEdge.shiftFractionTowards(points.tsRightEdge, 0.5); - macro("title", { + points.title = points.tsLeftEdge.shiftFractionTowards(points.tsRightEdge, 0.5) + macro('title', { at: points.title, nr: 5, - title: "underSleeve" - }); + title: 'underSleeve' + }) // Grainline - macro("grainline", { + macro('grainline', { from: points.boxBottom, to: points.armCenter - }); + }) - if (sa) paths.sa = paths.seam.offset(sa).attr("class", "fabric sa"); + if (sa) paths.sa = paths.seam.offset(sa).attr('class', 'fabric sa') if (paperless) { - macro("ld", { + macro('ld', { from: points.usWristLeft, to: points.usWristRight, d: 15 - }); - macro("ld", { + }) + macro('ld', { from: points.usWristLeft, to: points.ventFoldRight, d: 30 - }); - macro("ld", { + }) + macro('ld', { from: points.hemLeft, to: points.ventRight, d: -15 - sa - }); - macro("ld", { + }) + macro('ld', { from: points.hemLeft, to: points.usWristLeft, d: 15 + sa - }); - macro("ld", { + }) + macro('ld', { from: points.usWristRight, to: points.ventSlopeStart, d: 15 - }); - macro("ld", { + }) + macro('ld', { from: points.ventFoldRight, to: points.ventSlopeEnd, d: 15 - }); - macro("ld", { + }) + macro('ld', { from: points.usWristRight, to: points.ventFoldRight, d: -15 - }); - macro("vd", { + }) + macro('vd', { from: points.usWristLeft, to: points.usElbowLeft, x: points.usLeftEdge.x - sa - 15 - }); - macro("vd", { + }) + macro('vd', { from: points.usWristLeft, to: points.usLeftEdge, x: points.usLeftEdge.x - sa - 30 - }); - macro("vd", { + }) + macro('vd', { from: points.usLeftEdge, to: points.usTip, x: points.usLeftEdge.x - sa - 30 - }); - macro("vd", { + }) + macro('vd', { from: points.usWristLeft, to: points.usTip, x: points.usLeftEdge.x - sa - 45 - }); - macro("ld", { + }) + macro('ld', { from: points.usElbowLeft, - to: points.elbowRight, - }); - macro("hd", { + to: points.elbowRight + }) + macro('hd', { from: points.usLeftEdge, to: points.usTip, y: points.usTip.y - sa - 15 - }); - macro("hd", { + }) + macro('hd', { from: points.usLeftEdge, to: points.elbowRight, y: points.usTip.y - sa - 30 - }); + }) } } - return part; + return part } diff --git a/packages/models/src/index.js b/packages/models/src/index.js index c84c4a1f67b..036ef309893 100644 --- a/packages/models/src/index.js +++ b/packages/models/src/index.js @@ -1,58 +1,58 @@ export const measurements = { menswear: [ - "ankleCircumference", - "bicepsCircumference", - "centerBackNeckToWaist", - "chestCircumference", - "headCircumference", - "hipsCircumference", - "hipsToUpperLeg", - "inseam", - "kneeCircumference", - "naturalWaist", - "naturalWaistToFloor", - "naturalWaistToHip", - "naturalWaistToKnee", - "naturalWaistToSeat", - "neckCircumference", - "seatDepth", - "shoulderSlope", - "shoulderToElbow", - "shoulderToShoulder", - "shoulderToWrist", - "upperLegCircumference", - "wristCircumference" + 'ankleCircumference', + 'bicepsCircumference', + 'centerBackNeckToWaist', + 'chestCircumference', + 'headCircumference', + 'hipsCircumference', + 'hipsToUpperLeg', + 'inseam', + 'kneeCircumference', + 'naturalWaist', + 'naturalWaistToFloor', + 'naturalWaistToHip', + 'naturalWaistToKnee', + 'naturalWaistToSeat', + 'neckCircumference', + 'seatDepth', + 'shoulderSlope', + 'shoulderToElbow', + 'shoulderToShoulder', + 'shoulderToWrist', + 'upperLegCircumference', + 'wristCircumference' ], womenswear: [ - "ankleCircumference", - "bicepsCircumference", - "bustSpan", - "centerBackNeckToWaist", - "chestCircumference", - "headCircumference", - "highBust", - "highPointShoulderToBust", - "hipsCircumference", - "hipsToUpperLeg", - "inseam", - "kneeCircumference", - "naturalWaist", - "naturalWaistToFloor", - "naturalWaistToHip", - "naturalWaistToKnee", - "naturalWaistToUnderbust", - "naturalWaistToSeat", - "neckCircumference", - "seatDepth", - "shoulderSlope", - "shoulderToElbow", - "shoulderToShoulder", - "shoulderToWrist", - "underbust", - "upperLegCircumference", - "wristCircumference" + 'ankleCircumference', + 'bicepsCircumference', + 'bustSpan', + 'centerBackNeckToWaist', + 'chestCircumference', + 'headCircumference', + 'highBust', + 'highPointShoulderToBust', + 'hipsCircumference', + 'hipsToUpperLeg', + 'inseam', + 'kneeCircumference', + 'naturalWaist', + 'naturalWaistToFloor', + 'naturalWaistToHip', + 'naturalWaistToKnee', + 'naturalWaistToUnderbust', + 'naturalWaistToSeat', + 'neckCircumference', + 'seatDepth', + 'shoulderSlope', + 'shoulderToElbow', + 'shoulderToShoulder', + 'shoulderToWrist', + 'underbust', + 'upperLegCircumference', + 'wristCircumference' ] -}; +} export const withoutBreasts = { size34: { @@ -147,8 +147,8 @@ export const withoutBreasts = { upperLegCircumference: 646, wristCircumference: 200 } -}; +} export const withBreasts = { // FIXME -}; +} diff --git a/packages/mui-theme/src/index.js b/packages/mui-theme/src/index.js index 7f230f7c8f1..7bf4d92fa3f 100644 --- a/packages/mui-theme/src/index.js +++ b/packages/mui-theme/src/index.js @@ -1,32 +1,32 @@ -const darkBg = "#212529"; -const lightBg = "#ffffff"; +const darkBg = '#212529' +const lightBg = '#ffffff' const colors = { light: { primary: darkBg, secondary: lightBg, - link: "#74c0fc", - paper: "#FFF" + link: '#74c0fc', + paper: '#FFF' }, dark: { primary: lightBg, secondary: darkBg, - link: "#74c0fc", - paper: "#000" + link: '#74c0fc', + paper: '#000' } -}; +} const asTitle = { - fontFamily: "Roboto Condensed", - fontWeight: "bold" -}; -const important = "!important"; + fontFamily: 'Roboto Condensed', + fontWeight: 'bold' +} +const important = '!important' const getTheme = mode => { - let c = colors[mode]; + let c = colors[mode] let forceColor = { root: { color: c.primary + important } - }; + } return { overrides: { MuiButton: { root: asTitle }, @@ -35,9 +35,9 @@ const getTheme = mode => { MuiRadio: forceColor, MuiCheckbox: forceColor, MuiSlider: { - container: { padding: "25px 0" }, - track: { height: "4px" }, - thumb: { width: "16px", height: "16px" } + container: { padding: '25px 0' }, + track: { height: '4px' }, + thumb: { width: '16px', height: '16px' } } }, palette: { @@ -55,21 +55,21 @@ const getTheme = mode => { }, typography: { fontFamily: [ - "-apple-system", - "BlinkMacSystemFont", + '-apple-system', + 'BlinkMacSystemFont', '"Segoe UI"', - "Roboto", + 'Roboto', '"Helvetica Neue"', - "Arial", - "sans-serif", + 'Arial', + 'sans-serif', '"Apple Color Emoji"', '"Segoe UI Emoji"', '"Segoe UI Symbol"' - ].join(",") + ].join(',') }, themeName: mode - }; -}; + } +} -export const light = getTheme("light"); -export const dark = getTheme("dark"); +export const light = getTheme('light') +export const dark = getTheme('dark') diff --git a/packages/pattern-info/src/index.js b/packages/pattern-info/src/index.js index 7fe96265c46..1c79bdf179e 100644 --- a/packages/pattern-info/src/index.js +++ b/packages/pattern-info/src/index.js @@ -1,52 +1,52 @@ -export { default as options } from "./prebuild/options"; -export { default as optionGroups } from "./prebuild/option-groups"; -export { default as parts } from "./prebuild/parts"; -export { default as measurements } from "./prebuild/measurements"; -export { default as versions } from "./prebuild/versions"; -export { default as info } from "./prebuild/info"; +export { default as options } from './prebuild/options' +export { default as optionGroups } from './prebuild/option-groups' +export { default as parts } from './prebuild/parts' +export { default as measurements } from './prebuild/measurements' +export { default as versions } from './prebuild/versions' +export { default as info } from './prebuild/info' export const list = [ - "aaron", - "benjamin", - "bent", - "brian", - "bruce", - "carlita", - "carlton", - "cathrin", - "florent", - "huey", - "hugo", - "jaeger", - "sandy", - "shin", - "simon", - "sven", - "tamiko", - "theo", - "trayvon", - "wahid" -]; + 'aaron', + 'benjamin', + 'bent', + 'brian', + 'bruce', + 'carlita', + 'carlton', + 'cathrin', + 'florent', + 'huey', + 'hugo', + 'jaeger', + 'sandy', + 'shin', + 'simon', + 'sven', + 'tamiko', + 'theo', + 'trayvon', + 'wahid' +] export const withoutBreasts = [ - "aaron", - "benjamin", - "bent", - "brian", - "bruce", - "carlton", - "florent", - "huey", - "hugo", - "jaeger", - "sandy", - "shin", - "simon", - "sven", - "tamiko", - "theo", - "trayvon", - "wahid" -]; + 'aaron', + 'benjamin', + 'bent', + 'brian', + 'bruce', + 'carlton', + 'florent', + 'huey', + 'hugo', + 'jaeger', + 'sandy', + 'shin', + 'simon', + 'sven', + 'tamiko', + 'theo', + 'trayvon', + 'wahid' +] -export const withBreasts = ["cathrin", "carlita"]; +export const withBreasts = ['cathrin', 'carlita'] diff --git a/packages/pattern-info/src/prebuild.js b/packages/pattern-info/src/prebuild.js index 63f929c6dd0..ce7fdfcd2a7 100644 --- a/packages/pattern-info/src/prebuild.js +++ b/packages/pattern-info/src/prebuild.js @@ -1,66 +1,66 @@ -const path = require("path"); -const fse = require("fs-extra"); -const patterns = require("@freesewing/patterns"); +const path = require('path') +const fse = require('fs-extra') +const patterns = require('@freesewing/patterns') const patternOptions = config => { - let all = []; - let groups = config.optionGroups; + let all = [] + let groups = config.optionGroups for (let group of Object.keys(groups)) { for (let option of groups[group]) { - if (typeof option === "string") all.push(option); + if (typeof option === 'string') all.push(option) else { for (let subgroup of Object.keys(option)) { - for (let suboption of option[subgroup]) all.push(suboption); + for (let suboption of option[subgroup]) all.push(suboption) } } } } - return all; -}; + return all +} const patternParts = config => { - let parts = {}; + let parts = {} if (config.parts) { - for (let p of config.parts) parts[p] = p; + for (let p of config.parts) parts[p] = p } if (config.dependencies) { for (let p of Object.keys(config.dependencies)) { - parts[p] = p; - if (typeof config.dependencies[p] === "string") { - parts[config.dependencies[p]] = config.dependencies[p]; + parts[p] = p + if (typeof config.dependencies[p] === 'string') { + parts[config.dependencies[p]] = config.dependencies[p] } else { - for (let d of config.dependencies[p]) parts[d] = d; + for (let d of config.dependencies[p]) parts[d] = d } } } if (config.inject) { for (let p of Object.keys(config.inject)) { - parts[p] = p; - parts[config.inject[p]] = config.inject[p]; + parts[p] = p + parts[config.inject[p]] = config.inject[p] } } if (config.hide) { - for (let p of config.hide) delete parts[p]; + for (let p of config.hide) delete parts[p] } - return Object.keys(parts); -}; + return Object.keys(parts) +} -let options = {}; -let optionGroups = {}; -let parts = {}; -let measurements = {}; -let versions = {}; -let info = {}; +let options = {} +let optionGroups = {} +let parts = {} +let measurements = {} +let versions = {} +let info = {} for (let pattern of Object.keys(patterns)) { - let instance = new patterns[pattern](); - let p = pattern.toLowerCase(); - options[p] = patternOptions(instance.config); - optionGroups[p] = instance.config.optionGroups; - parts[p] = patternParts(instance.config); - measurements[p] = instance.config.measurements; - versions[p] = instance.config.version; + let instance = new patterns[pattern]() + let p = pattern.toLowerCase() + options[p] = patternOptions(instance.config) + optionGroups[p] = instance.config.optionGroups + parts[p] = patternParts(instance.config) + measurements[p] = instance.config.measurements + versions[p] = instance.config.version info[p] = { design: instance.config.design, code: instance.config.code, @@ -68,31 +68,31 @@ for (let pattern of Object.keys(patterns)) { type: instance.config.type, difficulty: instance.config.difficulty, tags: instance.config.tags - }; + } } -fse.mkdirSync(path.join(".", "src", "prebuild"), { recursive: true }); +fse.mkdirSync(path.join('.', 'src', 'prebuild'), { recursive: true }) fse.writeFileSync( - path.join(".", "src", "prebuild", "options.js"), - "module.exports = " + JSON.stringify(options) + "\n" -); + path.join('.', 'src', 'prebuild', 'options.js'), + 'module.exports = ' + JSON.stringify(options) + '\n' +) fse.writeFileSync( - path.join(".", "src", "prebuild", "option-groups.js"), - "module.exports = " + JSON.stringify(optionGroups) + "\n" -); + path.join('.', 'src', 'prebuild', 'option-groups.js'), + 'module.exports = ' + JSON.stringify(optionGroups) + '\n' +) fse.writeFileSync( - path.join(".", "src", "prebuild", "parts.js"), - "module.exports = " + JSON.stringify(parts) + "\n" -); + path.join('.', 'src', 'prebuild', 'parts.js'), + 'module.exports = ' + JSON.stringify(parts) + '\n' +) fse.writeFileSync( - path.join(".", "src", "prebuild", "measurements.js"), - "module.exports = " + JSON.stringify(measurements) + "\n" -); + path.join('.', 'src', 'prebuild', 'measurements.js'), + 'module.exports = ' + JSON.stringify(measurements) + '\n' +) fse.writeFileSync( - path.join(".", "src", "prebuild", "versions.js"), - "module.exports = " + JSON.stringify(versions) + "\n" -); + path.join('.', 'src', 'prebuild', 'versions.js'), + 'module.exports = ' + JSON.stringify(versions) + '\n' +) fse.writeFileSync( - path.join(".", "src", "prebuild", "info.js"), - "module.exports = " + JSON.stringify(info) + "\n" -); + path.join('.', 'src', 'prebuild', 'info.js'), + 'module.exports = ' + JSON.stringify(info) + '\n' +) diff --git a/packages/patterns/src/index.js b/packages/patterns/src/index.js index 1e618a2ad31..a6a90bf1e78 100644 --- a/packages/patterns/src/index.js +++ b/packages/patterns/src/index.js @@ -1,20 +1,20 @@ -export { default as Aaron } from "@freesewing/aaron"; -export { default as Benjamin } from "@freesewing/benjamin"; -export { default as Bent } from "@freesewing/bent"; -export { default as Brian } from "@freesewing/brian"; -export { default as Bruce } from "@freesewing/bruce"; -export { default as Carlita } from "@freesewing/carlita"; -export { default as Carlton } from "@freesewing/carlton"; -export { default as Cathrin } from "@freesewing/cathrin"; -export { default as Florent } from "@freesewing/florent"; -export { default as Huey } from "@freesewing/huey"; -export { default as Hugo } from "@freesewing/hugo"; -export { default as Jaeger } from "@freesewing/jaeger"; -export { default as Sandy } from "@freesewing/sandy"; -export { default as Shin } from "@freesewing/shin"; -export { default as Simon } from "@freesewing/simon"; -export { default as Sven } from "@freesewing/sven"; -export { default as Tamiko } from "@freesewing/tamiko"; -export { default as Theo } from "@freesewing/theo"; -export { default as Trayvon } from "@freesewing/trayvon"; -export { default as Wahid } from "@freesewing/wahid"; +export { default as Aaron } from '@freesewing/aaron' +export { default as Benjamin } from '@freesewing/benjamin' +export { default as Bent } from '@freesewing/bent' +export { default as Brian } from '@freesewing/brian' +export { default as Bruce } from '@freesewing/bruce' +export { default as Carlita } from '@freesewing/carlita' +export { default as Carlton } from '@freesewing/carlton' +export { default as Cathrin } from '@freesewing/cathrin' +export { default as Florent } from '@freesewing/florent' +export { default as Huey } from '@freesewing/huey' +export { default as Hugo } from '@freesewing/hugo' +export { default as Jaeger } from '@freesewing/jaeger' +export { default as Sandy } from '@freesewing/sandy' +export { default as Shin } from '@freesewing/shin' +export { default as Simon } from '@freesewing/simon' +export { default as Sven } from '@freesewing/sven' +export { default as Tamiko } from '@freesewing/tamiko' +export { default as Theo } from '@freesewing/theo' +export { default as Trayvon } from '@freesewing/trayvon' +export { default as Wahid } from '@freesewing/wahid' diff --git a/packages/plugin-banner/src/index.js b/packages/plugin-banner/src/index.js index 09a26d26791..bf4a778b1fe 100644 --- a/packages/plugin-banner/src/index.js +++ b/packages/plugin-banner/src/index.js @@ -1,25 +1,23 @@ -import { name, version } from "../package.json"; +import { name, version } from '../package.json' export default { name: name, version: version, hooks: { preRender: function(svg) { - if (svg.attributes.get("freesewing:plugin-banner") === false) - svg.attributes.set("freesewing:plugin-banner", version); + if (svg.attributes.get('freesewing:plugin-banner') === false) + svg.attributes.set('freesewing:plugin-banner', version) } }, macros: { banner: function(so) { - let defaults = { text: [], dy: -1, spaces: 8, repeat: 25 }; - so = { ...defaults, ...so }; - this.paths[so.path] - .attr("data-text-dy", so.dy) - .attr("data-text-class", "center"); - for(let i=0; i'; +export default '' diff --git a/packages/plugin-buttons/src/buttonhole.js b/packages/plugin-buttons/src/buttonhole.js index 462c67470ec..1cde0bbf15d 100644 --- a/packages/plugin-buttons/src/buttonhole.js +++ b/packages/plugin-buttons/src/buttonhole.js @@ -1 +1 @@ -export default ''; +export default '' diff --git a/packages/plugin-buttons/src/index.js b/packages/plugin-buttons/src/index.js index 2405c0ee427..cf49396747d 100644 --- a/packages/plugin-buttons/src/index.js +++ b/packages/plugin-buttons/src/index.js @@ -1,16 +1,16 @@ -import button from "./button"; -import buttonhole from "./buttonhole"; -import snaps from "./snaps"; -import { name, version } from "../package.json"; +import button from './button' +import buttonhole from './buttonhole' +import snaps from './snaps' +import { name, version } from '../package.json' export default { name: name, version: version, hooks: { preRender: function(svg) { - if (svg.attributes.get("freesewing:plugin-buttons") === false) - svg.attributes.set("freesewing:plugin-buttons", version); - svg.defs += button + buttonhole + snaps; + if (svg.attributes.get('freesewing:plugin-buttons') === false) + svg.attributes.set('freesewing:plugin-buttons', version) + svg.defs += button + buttonhole + snaps } } -}; +} diff --git a/packages/plugin-buttons/src/snaps.js b/packages/plugin-buttons/src/snaps.js index a0f97499db2..12ed90480d5 100644 --- a/packages/plugin-buttons/src/snaps.js +++ b/packages/plugin-buttons/src/snaps.js @@ -1 +1 @@ -export default ''; +export default '' diff --git a/packages/plugin-cutonfold/src/index.js b/packages/plugin-cutonfold/src/index.js index b69d2f1cc6f..24d3d8215ad 100644 --- a/packages/plugin-cutonfold/src/index.js +++ b/packages/plugin-cutonfold/src/index.js @@ -1,59 +1,53 @@ -import markers from "./lib/markers"; -import { version, name } from "../package.json"; +import markers from './lib/markers' +import { version, name } from '../package.json' export default { name: name, version: version, hooks: { preRender: function(svg) { - if (svg.attributes.get("freesewing:plugin-cutonfold") === false) { - svg.attributes.set("freesewing:plugin-cutonfold", version); - svg.defs += markers; + if (svg.attributes.get('freesewing:plugin-cutonfold') === false) { + svg.attributes.set('freesewing:plugin-cutonfold', version) + svg.defs += markers } } }, macros: { cutonfold: function(so) { if (so === false) { - delete this.points.cutonfoldFrom; - delete this.points.cutonfoldTo; - delete this.points.cutonfoldVia1; - delete this.points.cutonfoldVia2; - delete this.paths.cutonfold; - return true; + delete this.points.cutonfoldFrom + delete this.points.cutonfoldTo + delete this.points.cutonfoldVia1 + delete this.points.cutonfoldVia2 + delete this.paths.cutonfold + return true } - let points = this.points; + let points = this.points so = { offset: 50, margin: 5, - prefix: "", + prefix: '', ...so - }; - points["cutonfoldFrom" + so.prefix] = so.to.shiftFractionTowards( - so.from, - so.margin / 100 - ); - points["cutonfoldTo" + so.prefix] = so.from.shiftFractionTowards( - so.to, - so.margin / 100 - ); - points["cutonfoldVia1" + so.prefix] = so.to + } + points['cutonfoldFrom' + so.prefix] = so.to.shiftFractionTowards(so.from, so.margin / 100) + points['cutonfoldTo' + so.prefix] = so.from.shiftFractionTowards(so.to, so.margin / 100) + points['cutonfoldVia1' + so.prefix] = so.to .shiftTowards(so.from, so.offset) - .rotate(-90, points["cutonfoldFrom" + so.prefix]); - points["cutonfoldVia2" + so.prefix] = so.from + .rotate(-90, points['cutonfoldFrom' + so.prefix]) + points['cutonfoldVia2' + so.prefix] = so.from .shiftTowards(so.to, so.offset) - .rotate(90, points["cutonfoldTo" + so.prefix]); - let text = so.grainline ? "cutOnFoldAndGrainline" : "cutOnFold"; - this.paths["cutonfold" + so.prefix] = new this.Path() - .move(points["cutonfoldFrom" + so.prefix]) - .line(points["cutonfoldVia1" + so.prefix]) - .line(points["cutonfoldVia2" + so.prefix]) - .line(points["cutonfoldTo" + so.prefix]) - .attr("class", "note") - .attr("marker-start", "url(#cutonfoldFrom)") - .attr("marker-end", "url(#cutonfoldTo)") - .attr("data-text", text) - .attr("data-text-class", "center fill-note"); + .rotate(90, points['cutonfoldTo' + so.prefix]) + let text = so.grainline ? 'cutOnFoldAndGrainline' : 'cutOnFold' + this.paths['cutonfold' + so.prefix] = new this.Path() + .move(points['cutonfoldFrom' + so.prefix]) + .line(points['cutonfoldVia1' + so.prefix]) + .line(points['cutonfoldVia2' + so.prefix]) + .line(points['cutonfoldTo' + so.prefix]) + .attr('class', 'note') + .attr('marker-start', 'url(#cutonfoldFrom)') + .attr('marker-end', 'url(#cutonfoldTo)') + .attr('data-text', text) + .attr('data-text-class', 'center fill-note') } } -}; +} diff --git a/packages/plugin-debug/src/index.js b/packages/plugin-debug/src/index.js index 36f19f76d6a..2d89c838b68 100644 --- a/packages/plugin-debug/src/index.js +++ b/packages/plugin-debug/src/index.js @@ -1,47 +1,48 @@ -import { version, name } from "../package.json"; +import { version, name } from '../package.json' const colors = { - info: "RoyalBlue", - warning: "Tomato", - error: "Red", - success: "OliveDrab", - debug: "Magenta" -}; + info: 'RoyalBlue', + warning: 'Tomato', + error: 'Red', + success: 'OliveDrab', + debug: 'Magenta' +} var debug = { name, version -}; +} -debug.log = function(label="", style="", data="") { +debug.log = function(label = '', style = '', data = '') { // This allows us to stub console.log() // in unit tests without side-effects - console.log(label, style, data); -}; + console.log(label, style, data) +} debug.style = function(type) { - return `font-weight: bold; padding: 0 5px; color: ${colors[type]};`; + return `font-weight: bold; padding: 0 5px; color: ${colors[type]};` } debug.hooks = { preRender: function(svg) { - if(svg.attributes.get("freesewing:plugin-debug") === false) { - svg.attributes.set("freesewing:plugin-debug", version); + if (svg.attributes.get('freesewing:plugin-debug') === false) { + svg.attributes.set('freesewing:plugin-debug', version) } }, debug: function(data, more) { - if( - typeof data === "object" && - typeof data.type === "string" && - typeof data.label === "string" && - typeof data.msg !== "undefined" && - Object.keys(data).length === 3) { + if ( + typeof data === 'object' && + typeof data.type === 'string' && + typeof data.label === 'string' && + typeof data.msg !== 'undefined' && + Object.keys(data).length === 3 + ) { // Make it pretty - debug.log("%c"+data.label, debug.style(data.type), data.msg); + debug.log('%c' + data.label, debug.style(data.type), data.msg) } else { - debug.log("%cdebug", debug.style('debug'), data); + debug.log('%cdebug', debug.style('debug'), data) } } -}; +} -export default debug; +export default debug diff --git a/packages/plugin-designer/src/decorate.js b/packages/plugin-designer/src/decorate.js index 38ab594414a..0e66c353b19 100644 --- a/packages/plugin-designer/src/decorate.js +++ b/packages/plugin-designer/src/decorate.js @@ -1,18 +1,18 @@ -const decorate = {}; +const decorate = {} /** Decorares points with extra info */ decorate.points = function(svg, pointHover) { for (let partId in svg.pattern.parts) { - let part = svg.pattern.parts[partId]; + let part = svg.pattern.parts[partId] if (part.render) { for (let pointId in part.points) { - let point = part.points[pointId]; - let type = pointId.substr(0, 1) === "_" ? "point-hidden" : "point"; - let id = "snippet-" + pointId; - part.snippets[id] = new svg.pattern.Snippet(type, point); - part.snippets[id].attributes.set("onmouseover", function() { - pointHover("test", "data"); - }); + let point = part.points[pointId] + let type = pointId.substr(0, 1) === '_' ? 'point-hidden' : 'point' + let id = 'snippet-' + pointId + part.snippets[id] = new svg.pattern.Snippet(type, point) + part.snippets[id].attributes.set('onmouseover', function() { + pointHover('test', 'data') + }) // raiseEvent('pointHover', { // type: "point", // pointId, @@ -23,49 +23,37 @@ decorate.points = function(svg, pointHover) { } } } -}; +} /** Decorares path points with extra info */ -decorate.pathPoint = function( - id, - Snippet, - snippets, - point, - type, - pathId, - partId -) { - snippets[id] = new Snippet( - `path-${type}-point`, - point, - `Path ${pathId}: ${type}` - ); - snippets[id].attributes.set("id", id); - snippets[id].attributes.add("data-path", pathId); - snippets[id].attributes.add("data-part", partId); -}; +decorate.pathPoint = function(id, Snippet, snippets, point, type, pathId, partId) { + snippets[id] = new Snippet(`path-${type}-point`, point, `Path ${pathId}: ${type}`) + snippets[id].attributes.set('id', id) + snippets[id].attributes.add('data-path', pathId) + snippets[id].attributes.add('data-part', partId) +} /** Draws curve control handles */ decorate.curveHandles = function(id, Path, paths, from, to, pathId, partId) { - let path = new Path().move(from).line(to); - path.attributes.add("class", "curve-control various dotted"); - path.attributes.add("id", id); - path.attributes.add("data-path", pathId); - path.attributes.add("data-part", partId); - paths[id] = path; -}; + let path = new Path().move(from).line(to) + path.attributes.add('class', 'curve-control various dotted') + path.attributes.add('id', id) + path.attributes.add('data-path', pathId) + path.attributes.add('data-part', partId) + paths[id] = path +} /** Decorares paths with extra info */ decorate.paths = function(svg) { for (let partId in svg.pattern.parts) { - let part = svg.pattern.parts[partId]; + let part = svg.pattern.parts[partId] if (part.render) { for (let pathId in part.paths) { - let path = part.paths[pathId]; + let path = part.paths[pathId] if (path.render) { - let current; + let current for (let op of path.ops) { - if (op.type !== "close") { + if (op.type !== 'close') { decorate.pathPoint( svg.getId(), svg.pattern.Snippet, @@ -74,27 +62,27 @@ decorate.paths = function(svg) { op.type, pathId, partId - ); + ) } - if (op.type === "curve") { + if (op.type === 'curve') { decorate.pathPoint( svg.getId(), svg.pattern.Snippet, part.snippets, op.cp1, - "handle", + 'handle', pathId, partId - ); + ) decorate.pathPoint( svg.getId(), svg.pattern.Snippet, part.snippets, op.cp2, - "handle", + 'handle', pathId, partId - ); + ) decorate.curveHandles( svg.getId(), svg.pattern.Path, @@ -104,7 +92,7 @@ decorate.paths = function(svg) { pathId, partId, part - ); + ) decorate.curveHandles( svg.getId(), svg.pattern.Path, @@ -114,14 +102,14 @@ decorate.paths = function(svg) { pathId, partId, part - ); + ) } - current = op.to; + current = op.to } } } } } -}; +} -export default decorate; +export default decorate diff --git a/packages/plugin-designer/src/index.js b/packages/plugin-designer/src/index.js index 26c1e92c443..c785bce5437 100644 --- a/packages/plugin-designer/src/index.js +++ b/packages/plugin-designer/src/index.js @@ -1,46 +1,45 @@ -import snippets from "./lib/snippets"; -import { version, name } from "../package.json"; -import decorate from "./decorate"; +import snippets from './lib/snippets' +import { version, name } from '../package.json' +import decorate from './decorate' export default { name: name, version: version, hooks: { preRender: function(svg, raiseEvent) { - raiseEvent("preRender", { data: "foo" }); + raiseEvent('preRender', { data: 'foo' }) //const pointHover = raiseEvent.bind(svg); //function(evt) { // raiseEvent.bind(svg)('plugin-designer-pointHover', evt); //} - if (svg.attributes.get("freesewing:plugin-designer") === false) { + if (svg.attributes.get('freesewing:plugin-designer') === false) { // Add snippets - svg.defs += snippets; + svg.defs += snippets // Add SVG attributes - svg.attributes.add("freesewing:plugin-designer", version); + svg.attributes.add('freesewing:plugin-designer', version) // Decorate pattern //decorate.points(svg, raiseEvent); for (let partId in svg.pattern.parts) { - let part = svg.pattern.parts[partId]; + let part = svg.pattern.parts[partId] if (part.render) { for (let pointId in part.points) { - let point = part.points[pointId]; - let type = - pointId.substr(0, 1) === "_" ? "point-hidden" : "point"; - let id = "snippet-" + pointId; - part.snippets[id] = new svg.pattern.Snippet(type, point); - part.snippets[id].attributes.set("onmouseover", raiseEvent); //(function(){pointHover('test', 'data')})); + let point = part.points[pointId] + let type = pointId.substr(0, 1) === '_' ? 'point-hidden' : 'point' + let id = 'snippet-' + pointId + part.snippets[id] = new svg.pattern.Snippet(type, point) + part.snippets[id].attributes.set('onmouseover', raiseEvent) //(function(){pointHover('test', 'data')})); } } } - decorate.paths(svg); + decorate.paths(svg) svg.debug( - { style: "info", label: "🚛 Pattern object" }, - "(dumped by designer plugin)", + { style: 'info', label: '🚛 Pattern object' }, + '(dumped by designer plugin)', svg.pattern - ); + ) } } } -}; +} diff --git a/packages/plugin-dimension/src/index.js b/packages/plugin-dimension/src/index.js index c2dce8d150b..e7ef5544856 100644 --- a/packages/plugin-dimension/src/index.js +++ b/packages/plugin-dimension/src/index.js @@ -1,69 +1,67 @@ -import markers from "./lib/markers"; -import { version, name } from "../package.json"; +import markers from './lib/markers' +import { version, name } from '../package.json' function drawDimension(from, to, so, self) { let dimension = new self.Path() .move(from) .line(to) - .attr("class", "mark") - .attr("data-text", so.text || self.units(from.dist(to))) - .attr("data-text-class", "fill-mark center"); - if (!so.noStartMarker) - dimension.attributes.set("marker-start", "url(#dimensionFrom)"); - if (!so.noEndMarker) - dimension.attributes.set("marker-end", "url(#dimensionTo)"); + .attr('class', 'mark') + .attr('data-text', so.text || self.units(from.dist(to))) + .attr('data-text-class', 'fill-mark center') + if (!so.noStartMarker) dimension.attributes.set('marker-start', 'url(#dimensionFrom)') + if (!so.noEndMarker) dimension.attributes.set('marker-end', 'url(#dimensionTo)') - return dimension; + return dimension } function drawLeader(self, from, to, id) { self.paths[id] = new self.Path() .move(from) .line(to) - .attr("class", "mark dotted"); + .attr('class', 'mark dotted') } function hleader(so, type, self, id) { - let point; - if (typeof so.y === "undefined" || so[type].y === so.y) { - point = so[type]; + let point + if (typeof so.y === 'undefined' || so[type].y === so.y) { + point = so[type] } else { - point = new self.Point(so[type].x, so.y); - drawLeader(self, so[type], point, id); + point = new self.Point(so[type].x, so.y) + drawLeader(self, so[type], point, id) } - return point; + return point } function vleader(so, type, self, id) { - let point; - if (typeof so.x === "undefined" || so[type].x === so.x) { - point = so[type]; + let point + if (typeof so.x === 'undefined' || so[type].x === so.x) { + point = so[type] } else { - point = new self.Point(so.x, so[type].y); - drawLeader(self, so[type], point, id); + point = new self.Point(so.x, so[type].y) + drawLeader(self, so[type], point, id) } - return point; + return point } function lleader(so, type, self, id) { - let point, rot, other; - if (type === "from") { - rot = 1; - other = "to"; + let point, rot, other + if (type === 'from') { + rot = 1 + other = 'to' } else { - rot = -1; - other = "from"; + rot = -1 + other = 'from' } - if (typeof so.d === "undefined") { - point = so[type]; + if (typeof so.d === 'undefined') { + point = so[type] } else { - point = so[type].shiftTowards(so[other], so.d).rotate(90 * rot, so[type]); - drawLeader(self, so[type], point, id); + point = so[type].shiftTowards(so[other], so.d).rotate(90 * rot, so[type]) + drawLeader(self, so[type], point, id) } - return point; + return point } export default { @@ -71,47 +69,47 @@ export default { version: version, hooks: { preRender: function(svg) { - if (svg.attributes.get("freesewing:plugin-dimension") === false) { - svg.attributes.set("freesewing:plugin-dimension", version); - svg.defs += markers; + if (svg.attributes.get('freesewing:plugin-dimension') === false) { + svg.attributes.set('freesewing:plugin-dimension', version) + svg.defs += markers } } }, macros: { // horizontal hd: function(so) { - let id = this.getId(); - let from = hleader(so, "from", this, id + "_ls"); - let to = hleader(so, "to", this, id + "_le"); - this.paths[id] = drawDimension(from, to, so, this); + let id = this.getId() + let from = hleader(so, 'from', this, id + '_ls') + let to = hleader(so, 'to', this, id + '_le') + this.paths[id] = drawDimension(from, to, so, this) }, // vertical vd: function(so) { - let id = this.getId(); - let from = vleader(so, "from", this, id + "_ls"); - let to = vleader(so, "to", this, id + "_le"); - this.paths[id] = drawDimension(from, to, so, this); + let id = this.getId() + let from = vleader(so, 'from', this, id + '_ls') + let to = vleader(so, 'to', this, id + '_le') + this.paths[id] = drawDimension(from, to, so, this) }, // linear ld: function(so) { - let id = this.getId(); - let from = lleader(so, "from", this, id + "_ls"); - let to = lleader(so, "to", this, id + "_le"); - this.paths[id] = drawDimension(from, to, so, this); + let id = this.getId() + let from = lleader(so, 'from', this, id + '_ls') + let to = lleader(so, 'to', this, id + '_le') + this.paths[id] = drawDimension(from, to, so, this) }, // path pd: function(so) { let dimension = so.path .offset(so.d) - .attr("class", "mark") - .attr("marker-start", "url(#dimensionFrom)") - .attr("marker-end", "url(#dimensionTo)") - .attr("data-text", so.text || this.units(so.path.length())) - .attr("data-text-class", "fill-mark center"); - let id = this.getId(); - drawLeader(this, so.path.start(), dimension.start(), id + "_ls"); - drawLeader(this, so.path.end(), dimension.end(), id + "_le"); - this.paths[id] = dimension; + .attr('class', 'mark') + .attr('marker-start', 'url(#dimensionFrom)') + .attr('marker-end', 'url(#dimensionTo)') + .attr('data-text', so.text || this.units(so.path.length())) + .attr('data-text-class', 'fill-mark center') + let id = this.getId() + drawLeader(this, so.path.start(), dimension.start(), id + '_ls') + drawLeader(this, so.path.end(), dimension.end(), id + '_le') + this.paths[id] = dimension } } -}; +} diff --git a/packages/plugin-flip/src/index.js b/packages/plugin-flip/src/index.js index 7df7b81c64b..3f2cae9ce9e 100644 --- a/packages/plugin-flip/src/index.js +++ b/packages/plugin-flip/src/index.js @@ -1,42 +1,39 @@ -import { name, version } from "../package.json"; +import { name, version } from '../package.json' export default { name: name, version: version, hooks: { preRender: function(svg) { - if (svg.attributes.get("freesewing:plugin-flip") === false) - svg.attributes.set("freesewing:plugin-flip", version); + if (svg.attributes.get('freesewing:plugin-flip') === false) + svg.attributes.set('freesewing:plugin-flip', version) } }, macros: { flip: function() { - let flipped = null; - let ops = ["from", "to", "cp1", "cp2"]; + let flipped = null + let ops = ['from', 'to', 'cp1', 'cp2'] for (let id in this.points) { // Keep track of the amount of flips (needed to allow flipping twice, but also avoid double flips in paths below) if (flipped === null) { - flipped = this.points[id].attributes.get("flipped"); - if (flipped === false) flipped = 1; - else flipped += 1; + flipped = this.points[id].attributes.get('flipped') + if (flipped === false) flipped = 1 + else flipped += 1 } - this.points[id].x = this.points[id].x * -1; - this.points[id].attributes.set("flipped", flipped); + this.points[id].x = this.points[id].x * -1 + this.points[id].attributes.set('flipped', flipped) } for (let id of Object.keys(this.paths)) { for (let op in this.paths[id].ops) { for (let type of ops) { - if (typeof this.paths[id].ops[op][type] !== "undefined") { + if (typeof this.paths[id].ops[op][type] !== 'undefined') { // Path ops can use points not listed in part.points. We should only flip those here // and not double flip the points flipped above - let wasFlipped = this.paths[id].ops[op][type].attributes.get( - "flipped" - ); - if (wasFlipped !== false) wasFlipped = parseInt(wasFlipped); + let wasFlipped = this.paths[id].ops[op][type].attributes.get('flipped') + if (wasFlipped !== false) wasFlipped = parseInt(wasFlipped) if (wasFlipped !== flipped) { - this.paths[id].ops[op][type].x = - this.paths[id].ops[op][type].x * -1; - this.paths[id].ops[op][type].attributes.set("flipped", flipped); + this.paths[id].ops[op][type].x = this.paths[id].ops[op][type].x * -1 + this.paths[id].ops[op][type].attributes.set('flipped', flipped) } } } @@ -45,11 +42,10 @@ export default { for (let id of Object.keys(this.snippets)) { // Snippets use points not listed in part.points. We should only flip those here // and not double flip the points flipped above - let wasFlipped = this.snippets[id].anchor.attributes.get("flipped"); - if (wasFlipped !== false) wasFlipped = parseInt(wasFlipped); - if (wasFlipped !== flipped) - this.snippets[id].anchor.x = this.snippets[id].anchor.x * -1; + let wasFlipped = this.snippets[id].anchor.attributes.get('flipped') + if (wasFlipped !== false) wasFlipped = parseInt(wasFlipped) + if (wasFlipped !== flipped) this.snippets[id].anchor.x = this.snippets[id].anchor.x * -1 } } } -}; +} diff --git a/packages/plugin-grainline/src/index.js b/packages/plugin-grainline/src/index.js index d54442aedc9..582512f863f 100644 --- a/packages/plugin-grainline/src/index.js +++ b/packages/plugin-grainline/src/index.js @@ -1,36 +1,36 @@ -import markers from "./markers"; -import { version, name } from "../package.json"; +import markers from './markers' +import { version, name } from '../package.json' export default { name: name, version: version, hooks: { preRender: function(svg) { - if (svg.attributes.get("freesewing:plugin-grainline") === false) { - svg.attributes.set("freesewing:plugin-grainline", version); - svg.defs += markers; + if (svg.attributes.get('freesewing:plugin-grainline') === false) { + svg.attributes.set('freesewing:plugin-grainline', version) + svg.defs += markers } } }, macros: { grainline: function(so) { if (so === false) { - delete this.points.grainlineFrom; - delete this.points.grainlineTo; - delete this.paths.grainline; - return true; + delete this.points.grainlineFrom + delete this.points.grainlineTo + delete this.paths.grainline + return true } - let points = this.points; - points.grainlineFrom = so.from.shiftFractionTowards(so.to, 0.05); - points.grainlineTo = so.to.shiftFractionTowards(so.from, 0.05); + let points = this.points + points.grainlineFrom = so.from.shiftFractionTowards(so.to, 0.05) + points.grainlineTo = so.to.shiftFractionTowards(so.from, 0.05) this.paths.grainline = new this.Path() .move(points.grainlineFrom) .line(points.grainlineTo) - .attr("class", "note") - .attr("marker-start", "url(#grainlineFrom)") - .attr("marker-end", "url(#grainlineTo)") - .attr("data-text", "grainline") - .attr("data-text-class", "center fill-note"); + .attr('class', 'note') + .attr('marker-start', 'url(#grainlineFrom)') + .attr('marker-end', 'url(#grainlineTo)') + .attr('data-text', 'grainline') + .attr('data-text-class', 'center fill-note') } } -}; +} diff --git a/packages/plugin-grainline/src/markers.js b/packages/plugin-grainline/src/markers.js index e7cf9708b91..28b09edb603 100644 --- a/packages/plugin-grainline/src/markers.js +++ b/packages/plugin-grainline/src/markers.js @@ -5,4 +5,4 @@ export default ` -`; +` diff --git a/packages/plugin-i18n/src/index.js b/packages/plugin-i18n/src/index.js index 73f6f3bc1b3..5fe64fb1dc2 100644 --- a/packages/plugin-i18n/src/index.js +++ b/packages/plugin-i18n/src/index.js @@ -1,22 +1,24 @@ -import { version, name } from "../package.json"; +import { version, name } from '../package.json' export default { name: name, version: version, hooks: { preRender: function(svg) { - if(svg.attributes.get('freesewing:plugin-i18n') === false) { - svg.attributes.set('freesewing:plugin-i18n', version); + if (svg.attributes.get('freesewing:plugin-i18n') === false) { + svg.attributes.set('freesewing:plugin-i18n', version) } }, insertText: function(locale, text, data) { - if(data === false) { - console.log("No data was passed to the i18n plugin. This plugin won't do much without injecting data into it"); - return text; + if (data === false) { + console.log( + "No data was passed to the i18n plugin. This plugin won't do much without injecting data into it" + ) + return text } - let prefix = data.prefix || ""; - if(typeof data.strings[locale][prefix+text] === "undefined") return text; - else return data.strings[locale][prefix+text]; + let prefix = data.prefix || '' + if (typeof data.strings[locale][prefix + text] === 'undefined') return text + else return data.strings[locale][prefix + text] } } -}; +} diff --git a/packages/plugin-logo/src/index.js b/packages/plugin-logo/src/index.js index 957299790cc..9bda34586af 100644 --- a/packages/plugin-logo/src/index.js +++ b/packages/plugin-logo/src/index.js @@ -1,16 +1,16 @@ -import logo from "./logo"; -import { name, version } from "../package.json"; +import logo from './logo' +import { name, version } from '../package.json' export default { name: name, version: version, hooks: { preRender: function(svg) { - if (svg.attributes.get("freesewing:plugin-logo") === false) { - svg.attributes.set("freesewing:plugin-logo", version); - svg.defs += logo; - svg.style += "path.logo{stroke:none;fill:#000;}"; + if (svg.attributes.get('freesewing:plugin-logo') === false) { + svg.attributes.set('freesewing:plugin-logo', version) + svg.defs += logo + svg.style += 'path.logo{stroke:none;fill:#000;}' } } } -}; +} diff --git a/packages/plugin-logo/src/logo.js b/packages/plugin-logo/src/logo.js index 9f03ce81d7c..8f456817bf0 100644 --- a/packages/plugin-logo/src/logo.js +++ b/packages/plugin-logo/src/logo.js @@ -1 +1 @@ -export default ''; +export default '' diff --git a/packages/plugin-round/src/index.js b/packages/plugin-round/src/index.js index c627cbcb4b8..1f32c5dff0f 100644 --- a/packages/plugin-round/src/index.js +++ b/packages/plugin-round/src/index.js @@ -1,48 +1,45 @@ -import { name, version } from "../package.json"; +import { name, version } from '../package.json' export default { name: name, version: version, hooks: { preRender: function(svg) { - if (svg.attributes.get("freesewing:plugin-round") === false) - svg.attributes.set("freesewing:plugin-round", version); + if (svg.attributes.get('freesewing:plugin-round') === false) + svg.attributes.set('freesewing:plugin-round', version) } }, macros: { round: function(so) { - const C = 0.55191502449; + const C = 0.55191502449 // Find angle between points - let from = so.from; - let to = so.to; - let via = so.via; - let radius = so.radius; - let prefix = so.prefix; - let angle1 = from.angle(via); - let angle2 = via.angle(to); + let from = so.from + let to = so.to + let via = so.via + let radius = so.radius + let prefix = so.prefix + let angle1 = from.angle(via) + let angle2 = via.angle(to) if ((Math.round(angle1) - Math.round(angle2)) % 90 !== 0) - console.log( - "Warning: The round macro only handles 90 degree angles correctly." - ); - let fd = from.dist(via); - let td = to.dist(via); - if (radius > fd || radius > td || typeof radius === "undefined") - radius = fd > td ? td : fd; - this.points[prefix + "Start"] = via.shiftTowards(from, radius); - this.points[prefix + "Cp1"] = via.shiftTowards(from, radius * (1 - C)); - this.points[prefix + "Cp2"] = via.shiftTowards(to, radius * (1 - C)); - this.points[prefix + "End"] = via.shiftTowards(to, radius); - this.paths[prefix + "Rounded"] = new this.Path() - .move(this.points[prefix + "Start"]) + console.log('Warning: The round macro only handles 90 degree angles correctly.') + let fd = from.dist(via) + let td = to.dist(via) + if (radius > fd || radius > td || typeof radius === 'undefined') radius = fd > td ? td : fd + this.points[prefix + 'Start'] = via.shiftTowards(from, radius) + this.points[prefix + 'Cp1'] = via.shiftTowards(from, radius * (1 - C)) + this.points[prefix + 'Cp2'] = via.shiftTowards(to, radius * (1 - C)) + this.points[prefix + 'End'] = via.shiftTowards(to, radius) + this.paths[prefix + 'Rounded'] = new this.Path() + .move(this.points[prefix + 'Start']) .curve( - this.points[prefix + "Cp1"], - this.points[prefix + "Cp2"], - this.points[prefix + "End"] + this.points[prefix + 'Cp1'], + this.points[prefix + 'Cp2'], + this.points[prefix + 'End'] ) - .attr("class", so.class ? so.class : ""); - if (typeof so.render !== "undefined" && so.render) - this.paths[prefix + "Rounded"].render = true; - else this.paths[prefix + "Rounded"].render = false; + .attr('class', so.class ? so.class : '') + if (typeof so.render !== 'undefined' && so.render) + this.paths[prefix + 'Rounded'].render = true + else this.paths[prefix + 'Rounded'].render = false } } -}; +} diff --git a/packages/plugin-scalebox/src/index.js b/packages/plugin-scalebox/src/index.js index c5a30b6fc20..805473d21fd 100644 --- a/packages/plugin-scalebox/src/index.js +++ b/packages/plugin-scalebox/src/index.js @@ -1,11 +1,11 @@ -import { version, name } from "../package.json"; +import { version, name } from '../package.json' export default { name: name, version: version, hooks: { preRender: function(svg) { - svg.attributes.set("freesewing:plugin-scalebox", version); + svg.attributes.set('freesewing:plugin-scalebox', version) } }, macros: { @@ -13,151 +13,120 @@ export default { // Passing `false` will remove the scalebox if (so === false) { for (let id of [ - "__scaleboxMetricTopLeft", - "__scaleboxMetricTopRight", - "__scaleboxMetricBottomRight", - "__scaleboxMetricBottomLeft", - "__scaleboxImperialTopLeft", - "__scaleboxImperialTopRight", - "__scaleboxImperialBottomRight", - "__scaleboxImperialBottomLeft", - "__scaleboxLead", - "__scaleboxTitle", - "__scaleboxText", - "__scaleboxLink", - "__scaleboxMetric", - "__scaleboxImperial" + '__scaleboxMetricTopLeft', + '__scaleboxMetricTopRight', + '__scaleboxMetricBottomRight', + '__scaleboxMetricBottomLeft', + '__scaleboxImperialTopLeft', + '__scaleboxImperialTopRight', + '__scaleboxImperialBottomRight', + '__scaleboxImperialBottomLeft', + '__scaleboxLead', + '__scaleboxTitle', + '__scaleboxText', + '__scaleboxLink', + '__scaleboxMetric', + '__scaleboxImperial' ]) - delete this.points[id]; - for (let id of ["__scaleboxMetric", "__scaleboxImperial"]) - delete this.paths[id]; - return true; + delete this.points[id] + for (let id of ['__scaleboxMetric', '__scaleboxImperial']) delete this.paths[id] + return true } // Box points - this.points.__scaleboxMetricTopLeft = new this.Point( - so.at.x - 50, - so.at.y - 25 - ); - this.points.__scaleboxMetricTopRight = new this.Point( - so.at.x + 50, - so.at.y - 25 - ); - this.points.__scaleboxMetricBottomLeft = new this.Point( - so.at.x - 50, - so.at.y + 25 - ); - this.points.__scaleboxMetricBottomRight = new this.Point( - so.at.x + 50, - so.at.y + 25 - ); - this.points.__scaleboxImperialTopLeft = new this.Point( - so.at.x - 50.8, - so.at.y - 25.4 - ); - this.points.__scaleboxImperialTopRight = new this.Point( - so.at.x + 50.8, - so.at.y - 25.4 - ); - this.points.__scaleboxImperialBottomLeft = new this.Point( - so.at.x - 50.8, - so.at.y + 25.4 - ); - this.points.__scaleboxImperialBottomRight = new this.Point( - so.at.x + 50.8, - so.at.y + 25.4 - ); + this.points.__scaleboxMetricTopLeft = new this.Point(so.at.x - 50, so.at.y - 25) + this.points.__scaleboxMetricTopRight = new this.Point(so.at.x + 50, so.at.y - 25) + this.points.__scaleboxMetricBottomLeft = new this.Point(so.at.x - 50, so.at.y + 25) + this.points.__scaleboxMetricBottomRight = new this.Point(so.at.x + 50, so.at.y + 25) + this.points.__scaleboxImperialTopLeft = new this.Point(so.at.x - 50.8, so.at.y - 25.4) + this.points.__scaleboxImperialTopRight = new this.Point(so.at.x + 50.8, so.at.y - 25.4) + this.points.__scaleboxImperialBottomLeft = new this.Point(so.at.x - 50.8, so.at.y + 25.4) + this.points.__scaleboxImperialBottomRight = new this.Point(so.at.x + 50.8, so.at.y + 25.4) // Text anchor points - this.points.__scaleboxLead = new this.Point(so.at.x - 45, so.at.y - 15); - this.points.__scaleboxTitle = this.points.__scaleboxLead.shift(-90, 10); - this.points.__scaleboxText = this.points.__scaleboxTitle.shift(-90, 8); - this.points.__scaleboxLink = this.points.__scaleboxText.shift(-90, 8); - this.points.__scaleboxMetric = new this.Point(so.at.x, so.at.y + 20); - this.points.__scaleboxImperial = new this.Point(so.at.x, so.at.y + 24); + this.points.__scaleboxLead = new this.Point(so.at.x - 45, so.at.y - 15) + this.points.__scaleboxTitle = this.points.__scaleboxLead.shift(-90, 10) + this.points.__scaleboxText = this.points.__scaleboxTitle.shift(-90, 8) + this.points.__scaleboxLink = this.points.__scaleboxText.shift(-90, 8) + this.points.__scaleboxMetric = new this.Point(so.at.x, so.at.y + 20) + this.points.__scaleboxImperial = new this.Point(so.at.x, so.at.y + 24) // Rotation if (so.rotate) { let points = [ - "__scaleboxMetricTopLeft", - "__scaleboxMetricTopRight", - "__scaleboxMetricBottomLeft", - "__scaleboxMetricBottomRight", - "__scaleboxImperialTopLeft", - "__scaleboxImperialTopRight", - "__scaleboxImperialBottomLeft", - "__scaleboxImperialBottomRight", - "__scaleboxLead", - "__scaleboxTitle", - "__scaleboxText", - "__scaleboxLink", - "__scaleboxMetric", - "__scaleboxImperial" - ]; - for (let pid of points) - this.points[pid] = this.points[pid].rotate(so.rotate, so.at); + '__scaleboxMetricTopLeft', + '__scaleboxMetricTopRight', + '__scaleboxMetricBottomLeft', + '__scaleboxMetricBottomRight', + '__scaleboxImperialTopLeft', + '__scaleboxImperialTopRight', + '__scaleboxImperialBottomLeft', + '__scaleboxImperialBottomRight', + '__scaleboxLead', + '__scaleboxTitle', + '__scaleboxText', + '__scaleboxLink', + '__scaleboxMetric', + '__scaleboxImperial' + ] + for (let pid of points) this.points[pid] = this.points[pid].rotate(so.rotate, so.at) for (let pid of points.slice(8)) { this.points[pid].attributes.set( - "data-text-transform", - `rotate(${so.rotate * -1}, ${this.points[pid].x}, ${ - this.points[pid].y - })` - ); + 'data-text-transform', + `rotate(${so.rotate * -1}, ${this.points[pid].x}, ${this.points[pid].y})` + ) } } // Paths this.paths.__scaleboxImperial = new this.Path() - .attr("class", "scalebox imperial") + .attr('class', 'scalebox imperial') .move(this.points.__scaleboxImperialTopLeft) .line(this.points.__scaleboxImperialBottomLeft) .line(this.points.__scaleboxImperialBottomRight) .line(this.points.__scaleboxImperialTopRight) - .close(); + .close() this.paths.__scaleboxMetric = new this.Path() - .attr("class", "scalebox metric") + .attr('class', 'scalebox metric') .move(this.points.__scaleboxMetricTopLeft) .line(this.points.__scaleboxMetricBottomLeft) .line(this.points.__scaleboxMetricBottomRight) .line(this.points.__scaleboxMetricTopRight) - .close(); + .close() // Lead this.points.__scaleboxLead = this.points.__scaleboxLead - .attr("data-text", so.lead || "freesewing") - .attr("data-text-class", "text-sm"); + .attr('data-text', so.lead || 'freesewing') + .attr('data-text-class', 'text-sm') // Title - if (so.title) - this.points.__scaleboxTitle.attributes.set("data-text", so.title); + if (so.title) this.points.__scaleboxTitle.attributes.set('data-text', so.title) else { this.points.__scaleboxTitle = this.points.__scaleboxTitle - .attr("data-text", this.context.config.name) - .attr("data-text", "v" + this.context.config.version); + .attr('data-text', this.context.config.name) + .attr('data-text', 'v' + this.context.config.version) } - this.points.__scaleboxTitle.attributes.add("data-text-class", "text-lg"); + this.points.__scaleboxTitle.attributes.add('data-text-class', 'text-lg') // Text - if (typeof so.text === "string") { - this.points.__scaleboxText.attr("data-text", so.text); + if (typeof so.text === 'string') { + this.points.__scaleboxText.attr('data-text', so.text) } else { this.points.__scaleboxText - .attr("data-text", "freesewingIsMadeByJoostDeCockAndContributors") - .attr("data-text", "\n") - .attr("data-text", "withTheFinancialSupportOfOurPatrons"); + .attr('data-text', 'freesewingIsMadeByJoostDeCockAndContributors') + .attr('data-text', '\n') + .attr('data-text', 'withTheFinancialSupportOfOurPatrons') this.points.__scaleboxLink = this.points.__scaleboxLink - .attr("data-text", "freesewing.org/patrons/join") - .attr("data-text-class", "text-xs fill-note"); + .attr('data-text', 'freesewing.org/patrons/join') + .attr('data-text-class', 'text-xs fill-note') } - this.points.__scaleboxText - .attr("data-text-class", "text-xs") - .attr("data-text-lineheight", 4); + this.points.__scaleboxText.attr('data-text-class', 'text-xs').attr('data-text-lineheight', 4) // Instructions this.points.__scaleboxMetric = this.points.__scaleboxMetric - .attr("data-text", "theWhiteInsideOfThisBoxShouldMeasure") - .attr("data-text", "10cm") - .attr("data-text", "x") - .attr("data-text", "5cm") - .attr("data-text-class", "text-xs center"); + .attr('data-text', 'theWhiteInsideOfThisBoxShouldMeasure') + .attr('data-text', '10cm') + .attr('data-text', 'x') + .attr('data-text', '5cm') + .attr('data-text-class', 'text-xs center') this.points.__scaleboxImperial = this.points.__scaleboxImperial - .attr("data-text", "theBlackOutsideOfThisBoxShouldMeasure") - .attr("data-text", '4"') - .attr("data-text", "x") - .attr("data-text", '2"') - .attr("data-text-class", "text-xs center "); + .attr('data-text', 'theBlackOutsideOfThisBoxShouldMeasure') + .attr('data-text', '4"') + .attr('data-text', 'x') + .attr('data-text', '2"') + .attr('data-text-class', 'text-xs center ') } } -}; +} diff --git a/packages/plugin-sprinkle/src/index.js b/packages/plugin-sprinkle/src/index.js index 90e022b682e..be34881b646 100644 --- a/packages/plugin-sprinkle/src/index.js +++ b/packages/plugin-sprinkle/src/index.js @@ -1,18 +1,18 @@ -import { name, version } from "../package.json"; +import { name, version } from '../package.json' export default { name: name, version: version, hooks: { preRender: function(svg) { - if (svg.attributes.get("freesewing:plugin-sprinkle") === false) - svg.attributes.set("freesewing:plugin-sprinkle", version); + if (svg.attributes.get('freesewing:plugin-sprinkle') === false) + svg.attributes.set('freesewing:plugin-sprinkle', version) } }, macros: { sprinkle: function(so) { for (let pid of so.on) - this.snippets[pid+"-"+so.snippet] = new this.Snippet(so.snippet, this.points[pid]); + this.snippets[pid + '-' + so.snippet] = new this.Snippet(so.snippet, this.points[pid]) } } -}; +} diff --git a/packages/plugin-svgattr/src/index.js b/packages/plugin-svgattr/src/index.js index 9396f01c8c2..355354e4b03 100644 --- a/packages/plugin-svgattr/src/index.js +++ b/packages/plugin-svgattr/src/index.js @@ -1,15 +1,14 @@ -import { version, name } from "../package.json"; +import { version, name } from '../package.json' export default { name: name, version: version, hooks: { preRender: function(svg, attributes) { - if (svg.attributes.get("freesewing:plugin-svgattr") === false) { - for (let key of Object.keys(attributes)) - svg.attributes.add(key, attributes[key]); - svg.attributes.add("freesewing:plugin-svgattr", version); + if (svg.attributes.get('freesewing:plugin-svgattr') === false) { + for (let key of Object.keys(attributes)) svg.attributes.add(key, attributes[key]) + svg.attributes.add('freesewing:plugin-svgattr', version) } } } -}; +} diff --git a/packages/plugin-theme/src/index.js b/packages/plugin-theme/src/index.js index 7d4480c0eeb..efcdffafce7 100644 --- a/packages/plugin-theme/src/index.js +++ b/packages/plugin-theme/src/index.js @@ -1,52 +1,50 @@ -import { version, name } from "../package.json"; -import notch from "./defs/notch"; -import gridMetric from "./defs/grid-metric"; -import gridImperial from "./defs/grid-imperial"; +import { version, name } from '../package.json' +import notch from './defs/notch' +import gridMetric from './defs/grid-metric' +import gridImperial from './defs/grid-imperial' // we don't use these vars, but they will trigger the // rollup sass plugin to compile a CSS bundle -import draftCss from "./scss/draft.scss"; -import sampleCss from "./scss/sample.scss"; -import paperlessCss from "./scss/paperless.scss"; +import draftCss from './scss/draft.scss' +import sampleCss from './scss/sample.scss' +import paperlessCss from './scss/paperless.scss' // This is the CSS bundle -import css from "./bundle.css.js"; +import css from './bundle.css.js' export default { name: name, version: version, hooks: { preRender: function(svg) { - if (svg.attributes.get("freesewing:plugin-theme") === false) { - svg.attributes.set("class", "freesewing"); - svg.defs += notch; - svg.style += css; + if (svg.attributes.get('freesewing:plugin-theme') === false) { + svg.attributes.set('class', 'freesewing') + svg.defs += notch + svg.style += css if (svg.pattern.settings.paperless) { - svg.pattern.settings.units === "imperial" + svg.pattern.settings.units === 'imperial' ? (svg.defs += gridImperial) - : (svg.defs += gridMetric); + : (svg.defs += gridMetric) for (let key in svg.pattern.parts) { - let part = svg.pattern.parts[key]; + let part = svg.pattern.parts[key] if (part.render && svg.pattern.needs(key)) { - let anchor = new svg.pattern.Point(0, 0); - if (typeof part.points.gridAnchor !== "undefined") - anchor = part.points.gridAnchor; - else if (typeof part.points.anchor !== "undefined") - anchor = part.points.anchor; - svg.defs += ``; - svg.defs += ""; + let anchor = new svg.pattern.Point(0, 0) + if (typeof part.points.gridAnchor !== 'undefined') anchor = part.points.gridAnchor + else if (typeof part.points.anchor !== 'undefined') anchor = part.points.anchor + svg.defs += `` + svg.defs += '' part.paths[part.getId()] = new svg.pattern.Path() .move(part.topLeft) .line(new svg.pattern.Point(part.topLeft.x, part.bottomRight.y)) .line(part.bottomRight) .line(new svg.pattern.Point(part.bottomRight.x, part.topLeft.y)) .close() - .attr("class", "grid") - .attr("style", `fill: url(#grid_${key})`); + .attr('class', 'grid') + .attr('style', `fill: url(#grid_${key})`) } } } - svg.attributes.add("freesewing:plugin-theme", version); + svg.attributes.add('freesewing:plugin-theme', version) } } } -}; +} diff --git a/packages/plugin-title/src/index.js b/packages/plugin-title/src/index.js index 3f20481bffc..85963182a2d 100644 --- a/packages/plugin-title/src/index.js +++ b/packages/plugin-title/src/index.js @@ -1,62 +1,54 @@ -import style from "./lib/style"; -import { version, name } from "../package.json"; +import style from './lib/style' +import { version, name } from '../package.json' export default { name: name, version: version, hooks: { preRender: function(svg) { - if (svg.attributes.get("freesewing:plugin-title") === false) { - svg.attributes.set("freesewing:plugin-title", version); - svg.style += style; + if (svg.attributes.get('freesewing:plugin-title') === false) { + svg.attributes.set('freesewing:plugin-title', version) + svg.style += style } } }, macros: { title: function(so) { const transform = function(anchor) { - let cx = anchor.x - so.scale * anchor.x; - let cy = anchor.y - so.scale * anchor.y; + let cx = anchor.x - so.scale * anchor.x + let cy = anchor.y - so.scale * anchor.y - return `matrix(${so.scale}, 0, 0, ${so.scale}, ${cx}, ${cy}) rotate(${ - so.rotation - } ${anchor.x} ${anchor.y})`; - }; + return `matrix(${so.scale}, 0, 0, ${so.scale}, ${cx}, ${cy}) rotate(${so.rotation} ${anchor.x} ${anchor.y})` + } let defaults = { scale: 1, rotation: 0 - }; - so = { ...defaults, ...so }; - let overwrite = true; - if (so.append) overwrite = false; - let prefix = ""; - if (so.prefix) prefix = so.prefix; + } + so = { ...defaults, ...so } + let overwrite = true + if (so.append) overwrite = false + let prefix = '' + if (so.prefix) prefix = so.prefix this.points[`_${prefix}_titleNr`] = so.at .clone() - .attr("data-text", so.nr, overwrite) - .attr("data-text-class", "title-nr note fill-note") - .attr("data-text-transform", transform(so.at)); - let shift = 10; + .attr('data-text', so.nr, overwrite) + .attr('data-text-class', 'title-nr note fill-note') + .attr('data-text-transform', transform(so.at)) + let shift = 10 if (so.title) { this.points[`_${prefix}_titleName`] = so.at .shift(-90 - so.rotation, 13 * so.scale) - .attr("data-text", so.title) - .attr("data-text-class", "title-name") - .attr( - "data-text-transform", - transform(so.at.shift(-90 - so.rotation, 13 * so.scale)) - ); - shift += 10; + .attr('data-text', so.title) + .attr('data-text-class', 'title-name') + .attr('data-text-transform', transform(so.at.shift(-90 - so.rotation, 13 * so.scale))) + shift += 10 } this.points[`_${prefix}_titlePattern`] = so.at .shift(-90 - so.rotation, shift * so.scale) - .attr("data-text", this.context.config.name) - .attr("data-text", "v" + this.context.config.version) - .attr("data-text-class", "title-pattern fill-note") - .attr( - "data-text-transform", - transform(so.at.shift(-90 - so.rotation, shift * so.scale)) - ); + .attr('data-text', this.context.config.name) + .attr('data-text', 'v' + this.context.config.version) + .attr('data-text-class', 'title-pattern fill-note') + .attr('data-text-transform', transform(so.at.shift(-90 - so.rotation, shift * so.scale))) } } -}; +} diff --git a/packages/plugin-validate/src/index.js b/packages/plugin-validate/src/index.js index 4e9867c838a..3326ec13079 100644 --- a/packages/plugin-validate/src/index.js +++ b/packages/plugin-validate/src/index.js @@ -1,57 +1,60 @@ -import { version, name } from "../package.json"; -import validate from "./validate"; +import { version, name } from '../package.json' +import validate from './validate' export default { name: name, version: version, hooks: { preDraft: function(pattern) { - if(typeof pattern.settings.measurements === "undefined") + if (typeof pattern.settings.measurements === 'undefined') return pattern.debug({ - type: "error", + type: 'error', label: '👕 No measurements provided', - msg: "You did not provide any measurements. Most, if not all, patterns require measurements, so this is most likely an issue." - }); - for(let measurement of pattern.config.measurements) { - if(!pattern.settings.measurements[measurement]) { + msg: + 'You did not provide any measurements. Most, if not all, patterns require measurements, so this is most likely an issue.' + }) + for (let measurement of pattern.config.measurements) { + if (!pattern.settings.measurements[measurement]) { pattern.debug({ - type: "error", + type: 'error', label: '👕 Missing measurement:', msg: measurement - }); + }) pattern.debug({ - type: "info", + type: 'info', label: '👕 All measurements:', msg: pattern.settings.measurements - }); - throw new Error(`Missing measurement: ${measurement}`); + }) + throw new Error(`Missing measurement: ${measurement}`) } else { pattern.debug({ - type: "success", - label: '👕 '+measurement+' is ok', + type: 'success', + label: '👕 ' + measurement + ' is ok', msg: pattern.settings.measurements[measurement] - }); + }) } } }, postDraft: function(pattern) { - for(let partId in pattern.parts) { - let part = pattern.parts[partId]; - let { debug } = part.shorthand(); - for(let pointId in part.points) { - validate.point(part.points[pointId], partId, pointId, debug); - validate.text('point', part.points[pointId], partId, pointId, debug); + for (let partId in pattern.parts) { + let part = pattern.parts[partId] + let { debug } = part.shorthand() + for (let pointId in part.points) { + validate.point(part.points[pointId], partId, pointId, debug) + validate.text('point', part.points[pointId], partId, pointId, debug) } - for(let pathId in part.paths) { - validate.path(part.paths[pathId], partId, pathId, debug); - validate.text('path', part.paths[pathId], partId, pathId, debug); + for (let pathId in part.paths) { + validate.path(part.paths[pathId], partId, pathId, debug) + validate.text('path', part.paths[pathId], partId, pathId, debug) } - for(let snippetId in part.snippets) { - if(!validate.snippet(part.snippets[snippetId], partId, snippetId, debug)) { - throw new Error(`pattern.parts.${partId}.snippets.${snippetId} is not a valid Snippet object`); + for (let snippetId in part.snippets) { + if (!validate.snippet(part.snippets[snippetId], partId, snippetId, debug)) { + throw new Error( + `pattern.parts.${partId}.snippets.${snippetId} is not a valid Snippet object` + ) } } } } } -}; +} diff --git a/packages/plugin-validate/src/validate.js b/packages/plugin-validate/src/validate.js index fbc255fb72c..72b9eb923b4 100644 --- a/packages/plugin-validate/src/validate.js +++ b/packages/plugin-validate/src/validate.js @@ -1,202 +1,186 @@ -const validate = {}; +const validate = {} validate.point = function(point, partId, pointId, debug) { - if (typeof point !== "object") { + if (typeof point !== 'object') { debug({ - type: "error", - label: "Problem with point", + type: 'error', + label: 'Problem with point', msg: points - }); - throw new Error( - `Point pattern.parts.${partId}.points.${pointId} is not an object` - ); - } else if (typeof point.x !== "number" || isNaN(point.x)) { + }) + throw new Error(`Point pattern.parts.${partId}.points.${pointId} is not an object`) + } else if (typeof point.x !== 'number' || isNaN(point.x)) { debug({ - type: "error", - label: "Problem with point X-value", + type: 'error', + label: 'Problem with point X-value', msg: points - }); - throw new Error( - `X-value of point pattern.parts.${partId}.points.${pointId} is not a number` - ); - } else if (typeof point.y !== "number" || isNaN(point.y)) { + }) + throw new Error(`X-value of point pattern.parts.${partId}.points.${pointId} is not a number`) + } else if (typeof point.y !== 'number' || isNaN(point.y)) { debug({ - type: "error", - label: "Problem with point Y-value", + type: 'error', + label: 'Problem with point Y-value', msg: points - }); - debug(dbg, "Problem with point Y-value:", point); - throw new Error( - `Y-value of point pattern.parts.${partId}.points.${pointId} is not a number` - ); + }) + debug(dbg, 'Problem with point Y-value:', point) + throw new Error(`Y-value of point pattern.parts.${partId}.points.${pointId} is not a number`) } else if ( - typeof point.attributes !== "object" || + typeof point.attributes !== 'object' || !(point.attributes.clone instanceof Function) ) { debug({ - type: "error", - label: "Problem with point attributes", + type: 'error', + label: 'Problem with point attributes', msg: points - }); + }) throw new Error( `attributes property of point pattern.parts.${partId}.points.${pointId} is not an object` - ); + ) } else if (!(point.clone instanceof Function)) { debug({ - type: "error", - label: "Problem with point", + type: 'error', + label: 'Problem with point', msg: points - }); - throw new Error( - `Point pattern.parts.${partId}.points.${pointId} is not a valid Point object` - ); + }) + throw new Error(`Point pattern.parts.${partId}.points.${pointId} is not a valid Point object`) } - return true; -}; + return true +} validate.text = function(type, item, partId, itemId, debug) { - let text = item.attributes.getAsArray("data-text"); - if (text === false) return true; + let text = item.attributes.getAsArray('data-text') + if (text === false) return true else { - if (item.attributes.get("data-validate-skip-text") !== false) { + if (item.attributes.get('data-validate-skip-text') !== false) { debug({ - type: "warning", - label: "🌐 Possible translation issue", + type: 'warning', + label: '🌐 Possible translation issue', msg: `This text might be a translation problem:, ${item} However, the error was suppresed, so moving on.` - }); - return true; + }) + return true } for (let t of text) { - if (typeof t !== "string" && typeof t !== "number") { + if (typeof t !== 'string' && typeof t !== 'number') { debug({ - type: "error", - label: "This text is not a string or number", + type: 'error', + label: 'This text is not a string or number', msg: t - }); + }) throw new Error( `${type} pattern.parts.${partId}.${type}s.${itemId} has text that is not a string nor a number. Set the 'data-validate-skip-text' attribute to true to suppress this error.` - ); - } else if (typeof t === "string" && t.indexOf(" ") !== -1) { + ) + } else if (typeof t === 'string' && t.indexOf(' ') !== -1) { debug({ - type: "warning", - label: "🌐 Possible translation issue", + type: 'warning', + label: '🌐 Possible translation issue', msg: t - }); + }) debug({ - type: "info", - label: "💡 Tip", + type: 'info', + label: '💡 Tip', msg: `${type} pattern.parts.${partId}.${type}s.${itemId} has text containing spaces. Please insert translation identifiers, and not actual text. Set the 'data-validate-skip-text' attribute to true to suppress this warning.` - }); + }) } } } - return true; -}; + return true +} validate.path = function(path, partId, pathId, debug) { - if (typeof path !== "object") { + if (typeof path !== 'object') { debug({ - type: "error", - label: "Problem with path", + type: 'error', + label: 'Problem with path', msg: path - }); - throw new Error( - `Path pattern.parts.${partId}.paths.${pathId} is not an object` - ); - } else if (typeof path.ops !== "object") { + }) + throw new Error(`Path pattern.parts.${partId}.paths.${pathId} is not an object`) + } else if (typeof path.ops !== 'object') { debug({ - type: "error", - label: "Problem with path ops", + type: 'error', + label: 'Problem with path ops', msg: path - }); - throw new Error( - `ops property of path pattern.parts.${partId}.paths.${pathId} is not an object` - ); + }) + throw new Error(`ops property of path pattern.parts.${partId}.paths.${pathId} is not an object`) } else if (path.ops.length < 2) { debug({ - type: "error", - label: "Problem with path ops", + type: 'error', + label: 'Problem with path ops', msg: path - }); - throw new Error( - `Path pattern.parts.${partId}.paths.${pathId} does not do anything` - ); - } else if (typeof path.attributes !== "object") { + }) + throw new Error(`Path pattern.parts.${partId}.paths.${pathId} does not do anything`) + } else if (typeof path.attributes !== 'object') { debug({ - type: "error", - label: "Problem with path attributes", + type: 'error', + label: 'Problem with path attributes', msg: path - }); + }) throw new Error( `attributes property of path pattern.parts.${partId}.paths.${pathId} is not an object` - ); + ) } else if (!(path.clone instanceof Function)) { debug({ - type: "error", - label: "Problem with path", + type: 'error', + label: 'Problem with path', msg: path - }); - throw new Error( - `Path pattern.parts.${partId}.paths.${pathId} is not a valid Path object` - ); + }) + throw new Error(`Path pattern.parts.${partId}.paths.${pathId} is not a valid Path object`) } else if (!(path.attributes.clone instanceof Function)) { debug({ - type: "error", - label: "Problem with path attributes", + type: 'error', + label: 'Problem with path attributes', msg: path - }); + }) throw new Error( `attributes property of path pattern.parts.${partId}.paths.${pathId} is not a valid Attributes object` - ); + ) } for (let o in path.ops) { - let op = path.ops[o]; - if (op.type !== "close") { - if (!validate.point(op.to, partId, "_unknown_", debug)) { + let op = path.ops[o] + if (op.type !== 'close') { + if (!validate.point(op.to, partId, '_unknown_', debug)) { debug({ - type: "error", - label: "Problem with path TO point", + type: 'error', + label: 'Problem with path TO point', msg: op.to - }); + }) throw new Error( `Point in pattern.parts.${partId}.paths.${pathId}.ops[o].to is not a valid Point object` - ); + ) } - } else if (op.type === "curve") { - if (!validate.point(op.cp1, partId, "_unknown_", debug)) { + } else if (op.type === 'curve') { + if (!validate.point(op.cp1, partId, '_unknown_', debug)) { debug({ - type: "error", - label: "Problem with path CP1 point", + type: 'error', + label: 'Problem with path CP1 point', msg: op.cp1 - }); + }) throw new Error( `Point in pattern.parts.${partId}.paths.${pathId}.ops[o].cp1 is not a valid Point object` - ); - } else if (!validate.point(op.cp2, partId, "_unknown_", debug)) { + ) + } else if (!validate.point(op.cp2, partId, '_unknown_', debug)) { debug({ - type: "error", - label: "Problem with path CP2 point", + type: 'error', + label: 'Problem with path CP2 point', msg: op.cp2 - }); + }) throw new Error( `Point in pattern.parts.${partId}.paths.${pathId}.ops[o].cp2 is not a valid Point object` - ); + ) } } } - return true; -}; + return true +} validate.snippet = function(snippet, partId, snippetId, debug) { - if (typeof snippet !== "object") return false; - if (!validate.point(snippet.anchor, partId, "_unknown_", debug)) return false; - if (typeof snippet.attributes !== "object") return false; - if (!(snippet.clone instanceof Function)) return false; - if (!(snippet.attributes.clone instanceof Function)) return false; + if (typeof snippet !== 'object') return false + if (!validate.point(snippet.anchor, partId, '_unknown_', debug)) return false + if (typeof snippet.attributes !== 'object') return false + if (!(snippet.clone instanceof Function)) return false + if (!(snippet.attributes.clone instanceof Function)) return false - return true; -}; + return true +} -export default validate; +export default validate diff --git a/packages/rendertest/example/src/App.js b/packages/rendertest/example/src/App.js index e7936330e5d..115cdf683af 100644 --- a/packages/rendertest/example/src/App.js +++ b/packages/rendertest/example/src/App.js @@ -1,22 +1,15 @@ -import React from "react"; -import freesewing from "@freesewing/core"; -import Workbench from "@freesewing/components/Workbench"; -import "typeface-roboto-condensed"; -import "@freesewing/css-theme"; +import React from 'react' +import freesewing from '@freesewing/core' +import Workbench from '@freesewing/components/Workbench' +import 'typeface-roboto-condensed' +import '@freesewing/css-theme' -import Pattern from "pattern"; +import Pattern from 'pattern' const App = props => { - let instance = new Pattern(); - let config = instance.config; - return ( - - ); -}; + let instance = new Pattern() + let config = instance.config + return +} -export default App; +export default App diff --git a/packages/rendertest/example/src/index.js b/packages/rendertest/example/src/index.js index 7900787a4d2..9dd7ba788d4 100644 --- a/packages/rendertest/example/src/index.js +++ b/packages/rendertest/example/src/index.js @@ -1,11 +1,11 @@ -import React from "react"; -import ReactDOM from "react-dom"; -import App from "./App"; -import * as serviceWorker from "./serviceWorker"; +import React from 'react' +import ReactDOM from 'react-dom' +import App from './App' +import * as serviceWorker from './serviceWorker' -ReactDOM.render(, document.getElementById("root")); +ReactDOM.render(, document.getElementById('root')) // If you want your app to work offline and load faster, you can change // unregister() to register() below. Note this comes with some pitfalls. // Learn more about service workers: http://bit.ly/CRA-PWA -serviceWorker.unregister(); +serviceWorker.unregister() diff --git a/packages/rendertest/example/src/serviceWorker.js b/packages/rendertest/example/src/serviceWorker.js index 68fda5a0eb6..44e1b1b2f8c 100644 --- a/packages/rendertest/example/src/serviceWorker.js +++ b/packages/rendertest/example/src/serviceWorker.js @@ -9,46 +9,44 @@ // This link also includes instructions on opting out of this behavior. const isLocalhost = Boolean( - window.location.hostname === "localhost" || + window.location.hostname === 'localhost' || // [::1] is the IPv6 localhost address. - window.location.hostname === "[::1]" || + window.location.hostname === '[::1]' || // 127.0.0.1/8 is considered localhost for IPv4. - window.location.hostname.match( - /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ - ) -); + window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/) +) export function register(config) { - if (process.env.NODE_ENV === "production" && "serviceWorker" in navigator) { + if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) { // The URL constructor is available in all browsers that support SW. - const publicUrl = new URL(process.env.PUBLIC_URL, window.location); + const publicUrl = new URL(process.env.PUBLIC_URL, window.location) if (publicUrl.origin !== window.location.origin) { // Our service worker won't work if PUBLIC_URL is on a different origin // from what our page is served on. This might happen if a CDN is used to // serve assets; see https://github.com/facebook/create-react-app/issues/2374 - return; + return } - window.addEventListener("load", () => { - const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; + window.addEventListener('load', () => { + const swUrl = `${process.env.PUBLIC_URL}/service-worker.js` if (isLocalhost) { // This is running on localhost. Let's check if a service worker still exists or not. - checkValidServiceWorker(swUrl, config); + checkValidServiceWorker(swUrl, config) // Add some additional logging to localhost, pointing developers to the // service worker/PWA documentation. navigator.serviceWorker.ready.then(() => { console.log( - "This web app is being served cache-first by a service " + - "worker. To learn more, visit https://goo.gl/SC7cgQ" - ); - }); + 'This web app is being served cache-first by a service ' + + 'worker. To learn more, visit https://goo.gl/SC7cgQ' + ) + }) } else { // Is not local host. Just register service worker - registerValidSW(swUrl, config); + registerValidSW(swUrl, config) } - }); + }) } } @@ -57,38 +55,38 @@ function registerValidSW(swUrl, config) { .register(swUrl) .then(registration => { registration.onupdatefound = () => { - const installingWorker = registration.installing; + const installingWorker = registration.installing installingWorker.onstatechange = () => { - if (installingWorker.state === "installed") { + if (installingWorker.state === 'installed') { if (navigator.serviceWorker.controller) { // At this point, the old content will have been purged and // the fresh content will have been added to the cache. // It's the perfect time to display a "New content is // available; please refresh." message in your web app. - console.log("New content is available; please refresh."); + console.log('New content is available; please refresh.') // Execute callback if (config.onUpdate) { - config.onUpdate(registration); + config.onUpdate(registration) } } else { // At this point, everything has been precached. // It's the perfect time to display a // "Content is cached for offline use." message. - console.log("Content is cached for offline use."); + console.log('Content is cached for offline use.') // Execute callback if (config.onSuccess) { - config.onSuccess(registration); + config.onSuccess(registration) } } } - }; - }; + } + } }) .catch(error => { - console.error("Error during service worker registration:", error); - }); + console.error('Error during service worker registration:', error) + }) } function checkValidServiceWorker(swUrl, config) { @@ -98,30 +96,28 @@ function checkValidServiceWorker(swUrl, config) { // Ensure service worker exists, and that we really are getting a JS file. if ( response.status === 404 || - response.headers.get("content-type").indexOf("javascript") === -1 + response.headers.get('content-type').indexOf('javascript') === -1 ) { // No service worker found. Probably a different app. Reload the page. navigator.serviceWorker.ready.then(registration => { registration.unregister().then(() => { - window.location.reload(); - }); - }); + window.location.reload() + }) + }) } else { // Service worker found. Proceed as normal. - registerValidSW(swUrl, config); + registerValidSW(swUrl, config) } }) .catch(() => { - console.log( - "No internet connection found. App is running in offline mode." - ); - }); + console.log('No internet connection found. App is running in offline mode.') + }) } export function unregister() { - if ("serviceWorker" in navigator) { + if ('serviceWorker' in navigator) { navigator.serviceWorker.ready.then(registration => { - registration.unregister(); - }); + registration.unregister() + }) } } diff --git a/packages/rendertest/src/circles.js b/packages/rendertest/src/circles.js index e1d1c030e46..2981925f37c 100644 --- a/packages/rendertest/src/circles.js +++ b/packages/rendertest/src/circles.js @@ -1,24 +1,24 @@ export default function(part) { - let { Point, Path, points, paths, store } = part.shorthand(); + let { Point, Path, points, paths, store } = part.shorthand() - let y = store.get("y"); - let w = store.get("w"); - let colors = store.get("colors"); + let y = store.get('y') + let w = store.get('w') + let colors = store.get('colors') - points.crl = new Point(0, y); - points.crr = new Point(w, y); + points.crl = new Point(0, y) + points.crr = new Point(w, y) paths.circles = new Path() .move(points.crl) .line(points.crr) - .attr("data-text", "circles"); - y += w / 2; + .attr('data-text', 'circles') + y += w / 2 for (let i = 1; i < 50; i++) { - points["cr" + i] = new Point(w / 2, y) - .attr("data-circle", i * (w / 100)) - .attr("data-circle-class", colors[i % colors.length]); + points['cr' + i] = new Point(w / 2, y) + .attr('data-circle', i * (w / 100)) + .attr('data-circle-class', colors[i % colors.length]) } - y += w / 2; - store.set("y", y); + y += w / 2 + store.set('y', y) - return part; + return part } diff --git a/packages/rendertest/src/colors.js b/packages/rendertest/src/colors.js index cd69511fb11..c932fd26550 100644 --- a/packages/rendertest/src/colors.js +++ b/packages/rendertest/src/colors.js @@ -1,77 +1,74 @@ export default function(part) { - let { Point, Path, points, paths, store } = part.shorthand(); + let { Point, Path, points, paths, store } = part.shorthand() - let y = store.get("y"); - let w = store.get("w"); - let colors = store.get("colors"); - let sizes = ["xs", "sm", "", "l", "xl"]; - let utility = ["dotted", "dashed", "lashed", "sa", "help", "hidden"]; + let y = store.get('y') + let w = store.get('w') + let colors = store.get('colors') + let sizes = ['xs', 'sm', '', 'l', 'xl'] + let utility = ['dotted', 'dashed', 'lashed', 'sa', 'help', 'hidden'] for (let i = 0; i < utility.length; i++) { - y += 15; - points["l" + i] = new Point(0, y); - points["r" + i] = new Point(w, y); - paths["heading" + i] = new Path() - .move(points["l" + i]) - .line(points["r" + i]) - .attr("class", colors[i]) - .attr("data-text", colors[i]); + y += 15 + points['l' + i] = new Point(0, y) + points['r' + i] = new Point(w, y) + paths['heading' + i] = new Path() + .move(points['l' + i]) + .line(points['r' + i]) + .attr('class', colors[i]) + .attr('data-text', colors[i]) for (let j = 0; j < sizes.length; j++) { - y += 10; - points["sl" + i + j] = new Point(0, y); - points["sr" + i + j] = new Point(w, y); - paths["size" + i + j] = new Path() - .move(points["sl" + i + j]) - .line(points["sr" + i + j]) - .attr("class", colors[i]) - .attr("class", "stroke-" + sizes[j]) - .attr( - "data-text", - "path." + colors[i] + (sizes[j] === "" ? "" : ".stroke-" + sizes[j]) - ) - .attr("data-text-class", "center"); + y += 10 + points['sl' + i + j] = new Point(0, y) + points['sr' + i + j] = new Point(w, y) + paths['size' + i + j] = new Path() + .move(points['sl' + i + j]) + .line(points['sr' + i + j]) + .attr('class', colors[i]) + .attr('class', 'stroke-' + sizes[j]) + .attr('data-text', 'path.' + colors[i] + (sizes[j] === '' ? '' : '.stroke-' + sizes[j])) + .attr('data-text-class', 'center') } for (let j = 0; j < utility.length; j++) { - y += 10; - points["ul" + i + j] = new Point(0, y); - points["ur" + i + j] = new Point(w, y); - paths["util" + i + j] = new Path() - .move(points["ul" + i + j]) - .line(points["ur" + i + j]) - .attr("class", colors[i]) - .attr("class", utility[j]) - .attr("data-text", "path." + colors[i] + "." + utility[j]) - .attr("data-text-class", "center"); + y += 10 + points['ul' + i + j] = new Point(0, y) + points['ur' + i + j] = new Point(w, y) + paths['util' + i + j] = new Path() + .move(points['ul' + i + j]) + .line(points['ur' + i + j]) + .attr('class', colors[i]) + .attr('class', utility[j]) + .attr('data-text', 'path.' + colors[i] + '.' + utility[j]) + .attr('data-text-class', 'center') } } - y += 10; - points.ftl = new Point(0, y); - points.ftr = new Point(w, y); + y += 10 + points.ftl = new Point(0, y) + points.ftr = new Point(w, y) paths.snip = new Path() .move(points.ftl) .line(points.ftr) - .attr("data-text", "fill"); - y += 15; + .attr('data-text', 'fill') + y += 15 for (let i of colors) { - let h = 10; - points["_bl" + i] = new Point(0, y); - points["_br" + i] = new Point(w, y); - points["_tr" + i] = new Point(w, y - h); - points["_tl" + i] = new Point(0, y - h); - paths["box" + i] = new Path() - .move(points["_bl" + i]) - .line(points["_br" + i]) - .line(points["_tr" + i]) - .line(points["_tl" + i]) + let h = 10 + points['_bl' + i] = new Point(0, y) + points['_br' + i] = new Point(w, y) + points['_tr' + i] = new Point(w, y - h) + points['_tl' + i] = new Point(0, y - h) + paths['box' + i] = new Path() + .move(points['_bl' + i]) + .line(points['_br' + i]) + .line(points['_tr' + i]) + .line(points['_tl' + i]) .close() - .attr("class", i) - .attr("class", "fill-" + i) - .attr("data-text", ".fill-" + i); - if (i === "fabric") paths["box" + i].attr("data-text-class", "fill-mark"); - y += h * 1.2; + .attr('class', i) + .attr('class', 'fill-' + i) + .attr('data-text', '.fill-' + i) + if (i === 'fabric') paths['box' + i].attr('data-text-class', 'fill-mark') + y += h * 1.2 } - store.set("y", y); + store.set('y', y) - return part; + return part } diff --git a/packages/rendertest/src/index.js b/packages/rendertest/src/index.js index 6406af6bf0a..9c7070ce72e 100644 --- a/packages/rendertest/src/index.js +++ b/packages/rendertest/src/index.js @@ -1,13 +1,13 @@ -import freesewing from "@freesewing/core"; -import plugins from "@freesewing/plugin-bundle"; -import config from "../config"; +import freesewing from '@freesewing/core' +import plugins from '@freesewing/plugin-bundle' +import config from '../config' // Parts -import draftTest from "./test"; +import draftTest from './test' // Create design -const Pattern = new freesewing.Design(config, plugins); +const Pattern = new freesewing.Design(config, plugins) // Attach draft methods to prototype -Pattern.prototype.draftTest = part => draftTest(part); +Pattern.prototype.draftTest = part => draftTest(part) -export default Pattern; +export default Pattern diff --git a/packages/rendertest/src/macros.js b/packages/rendertest/src/macros.js index 3707a8fe369..5c9d843285b 100644 --- a/packages/rendertest/src/macros.js +++ b/packages/rendertest/src/macros.js @@ -1,68 +1,68 @@ export default function(part) { - let { macro, Point, Path, points, paths, store } = part.shorthand(); + let { macro, Point, Path, points, paths, store } = part.shorthand() - let y = store.get("y"); - let w = store.get("w"); - y += 10; - points.ml = new Point(0, y); - points.mr = new Point(w, y); + let y = store.get('y') + let w = store.get('w') + y += 10 + points.ml = new Point(0, y) + points.mr = new Point(w, y) paths.macros = new Path() .move(points.ml) .line(points.mr) - .attr("data-text", "macros"); + .attr('data-text', 'macros') - y += 40; - macro("title", { + y += 40 + macro('title', { at: new Point(w / 2, y), nr: 5, - title: "title" - }); + title: 'title' + }) - y += 40; - macro("grainline", { + y += 40 + macro('grainline', { from: new Point(0, y), to: new Point(w, y) - }); + }) - y += 20; - macro("cutonfold", { + y += 20 + macro('cutonfold', { from: new Point(w, y), to: new Point(0, y) - }); + }) - y += 70; - points.dimf = new Point(20, y); - points.dimt = new Point(w - 20, y + 120); - points.dimv = new Point(20, y + 80); - paths.dims = new Path().move(points.dimf)._curve(points.dimv, points.dimt); - macro("hd", { + y += 70 + points.dimf = new Point(20, y) + points.dimt = new Point(w - 20, y + 120) + points.dimv = new Point(20, y + 80) + paths.dims = new Path().move(points.dimf)._curve(points.dimv, points.dimt) + macro('hd', { from: points.dimf, to: points.dimt, - text: "hd", + text: 'hd', y: y - 15 - }); - macro("vd", { + }) + macro('vd', { from: points.dimt, to: points.dimf, - text: "vd", + text: 'vd', x: 0 - }); - macro("ld", { + }) + macro('ld', { from: points.dimf, to: points.dimt, - text: "ld" - }); - macro("pd", { + text: 'ld' + }) + macro('pd', { path: paths.dims, - text: "pd", + text: 'pd', d: 10 - }); + }) - y += 170; - macro("scalebox", { + y += 170 + macro('scalebox', { at: new Point(w / 2, y) - }); - store.set("y", y); + }) + store.set('y', y) - return part; + return part } diff --git a/packages/rendertest/src/snippets.js b/packages/rendertest/src/snippets.js index 7b2c1daaead..e971a6a893c 100644 --- a/packages/rendertest/src/snippets.js +++ b/packages/rendertest/src/snippets.js @@ -1,16 +1,8 @@ export default function(part) { - let { - Point, - Path, - points, - paths, - snippets, - Snippet, - store - } = part.shorthand(); + let { Point, Path, points, paths, snippets, Snippet, store } = part.shorthand() - let y = store.get("y"); - let w = store.get("w"); + let y = store.get('y') + let w = store.get('w') let snips = { logo: 25, @@ -18,45 +10,45 @@ export default function(part) { bnotch: 15, button: 15, buttonhole: 15 - }; - y += 10; - points.tl = new Point(0, y); - points.tr = new Point(w, y); + } + y += 10 + points.tl = new Point(0, y) + points.tr = new Point(w, y) paths.texts = new Path() .move(points.tl) .line(points.tr) - .attr("data-text", "snippets"); - y += 10; - points["sl1"] = new Point(w * 0.25, y); - points["sl2"] = new Point(w * 0.5, y); - points["sl3"] = new Point(w * 0.75, y); - points["sl1"] - .attr("data-text", "data-scale: 1\ndata-rotate: 0") - .attr("data-text-class", "center text-sm") - .attr("data-text-lineheight", 5); - points["sl2"] - .attr("data-text", "data-scale: 1.25\ndata-rotate: 0") - .attr("data-text-class", "center text-sm") - .attr("data-text-lineheight", 5); - points["sl3"] - .attr("data-text", "data-scale: 0.75\ndata-rotate: 90") - .attr("data-text-class", "center text-sm") - .attr("data-text-lineheight", 5); - y += 55; + .attr('data-text', 'snippets') + y += 10 + points['sl1'] = new Point(w * 0.25, y) + points['sl2'] = new Point(w * 0.5, y) + points['sl3'] = new Point(w * 0.75, y) + points['sl1'] + .attr('data-text', 'data-scale: 1\ndata-rotate: 0') + .attr('data-text-class', 'center text-sm') + .attr('data-text-lineheight', 5) + points['sl2'] + .attr('data-text', 'data-scale: 1.25\ndata-rotate: 0') + .attr('data-text-class', 'center text-sm') + .attr('data-text-lineheight', 5) + points['sl3'] + .attr('data-text', 'data-scale: 0.75\ndata-rotate: 90') + .attr('data-text-class', 'center text-sm') + .attr('data-text-lineheight', 5) + y += 55 for (let i in snips) { - points["snt" + i] = new Point(0, y); - points["snt" + i].attr("data-text", i); - points["sn1" + i] = new Point(w * 0.25, y); - points["sn2" + i] = new Point(w * 0.5, y); - points["sn3" + i] = new Point(w * 0.75, y); - snippets["sn1" + i] = new Snippet(i, points["sn1" + i]); - snippets["sn2" + i] = new Snippet(i, points["sn2" + i]); - snippets["sn2" + i].attr("data-scale", 1.25); - snippets["sn3" + i] = new Snippet(i, points["sn3" + i]); - snippets["sn3" + i].attr("data-scale", 0.75).attr("data-rotate", 90); - y += snips[i]; + points['snt' + i] = new Point(0, y) + points['snt' + i].attr('data-text', i) + points['sn1' + i] = new Point(w * 0.25, y) + points['sn2' + i] = new Point(w * 0.5, y) + points['sn3' + i] = new Point(w * 0.75, y) + snippets['sn1' + i] = new Snippet(i, points['sn1' + i]) + snippets['sn2' + i] = new Snippet(i, points['sn2' + i]) + snippets['sn2' + i].attr('data-scale', 1.25) + snippets['sn3' + i] = new Snippet(i, points['sn3' + i]) + snippets['sn3' + i].attr('data-scale', 0.75).attr('data-rotate', 90) + y += snips[i] } - store.set("y", y); + store.set('y', y) - return part; + return part } diff --git a/packages/rendertest/src/test.js b/packages/rendertest/src/test.js index c80dbb6e89d..b6ba1d56650 100644 --- a/packages/rendertest/src/test.js +++ b/packages/rendertest/src/test.js @@ -1,40 +1,31 @@ -import colors from "./colors"; -import circles from "./circles"; -import text from "./text"; -import snippets from "./snippets"; -import macros from "./macros"; +import colors from './colors' +import circles from './circles' +import text from './text' +import snippets from './snippets' +import macros from './macros' export default function(part) { - let { macro, store, options, Path, paths, Point } = part.shorthand(); - store.set("y", 0); - store.set("w", options.width); - let color = [ - "fabric", - "lining", - "interfacing", - "canvas", - "various", - "mark", - "contrast", - "note" - ]; - store.set("colors", color); + let { macro, store, options, Path, paths, Point } = part.shorthand() + store.set('y', 0) + store.set('w', options.width) + let color = ['fabric', 'lining', 'interfacing', 'canvas', 'various', 'mark', 'contrast', 'note'] + store.set('colors', color) if (options.widthHd) - macro("hd", { + macro('hd', { from: new Point(0, 0), to: new Point(options.width, 0) - }); - if (options.colors) colors(part); - if (options.circles) circles(part); - if (options.text) text(part); - if (options.snippets) snippets(part); - if (options.macros) macros(part); + }) + if (options.colors) colors(part) + if (options.circles) circles(part) + if (options.text) text(part) + if (options.snippets) snippets(part) + if (options.macros) macros(part) // Make sure no text is cut off paths.box = new Path() .move(new Point(0, -10)) - .line(new Point(store.get("w"), store.get("y"))) - .attr("class", "hidden"); + .line(new Point(store.get('w'), store.get('y'))) + .attr('class', 'hidden') - return part; + return part } diff --git a/packages/rendertest/src/text.js b/packages/rendertest/src/text.js index 4724696d68d..69b08a4ae56 100644 --- a/packages/rendertest/src/text.js +++ b/packages/rendertest/src/text.js @@ -1,39 +1,39 @@ export default function(part) { - let { Point, Path, points, paths, store } = part.shorthand(); + let { Point, Path, points, paths, store } = part.shorthand() - let y = store.get("y"); - let w = store.get("w"); - let text = ["xs", "sm", "", "l", "xl", "xxl"]; - y += 10; - points.tl = new Point(0, y); - points.tr = new Point(w, y); + let y = store.get('y') + let w = store.get('w') + let text = ['xs', 'sm', '', 'l', 'xl', 'xxl'] + y += 10 + points.tl = new Point(0, y) + points.tr = new Point(w, y) paths.text = new Path() .move(points.tl) .line(points.tr) - .attr("data-text", "text"); - y += 10; - points.tlc = new Point(0, y); - points.trc = new Point(w, y); + .attr('data-text', 'text') + y += 10 + points.tlc = new Point(0, y) + points.trc = new Point(w, y) paths.textc = new Path() .move(points.tlc) .line(points.trc) - .attr("data-text", "text.center") - .attr("data-text-class", "center"); - y += 10; - points.tlr = new Point(0, y); - points.trr = new Point(w, y); + .attr('data-text', 'text.center') + .attr('data-text-class', 'center') + y += 10 + points.tlr = new Point(0, y) + points.trr = new Point(w, y) paths.textr = new Path() .move(points.tlr) .line(points.trr) - .attr("data-text", "text.right") - .attr("data-text-class", "right"); + .attr('data-text', 'text.right') + .attr('data-text-class', 'right') for (let i = 0; i < text.length; i++) { - y += 15; - points["t" + i] = new Point(0, y) - .attr("data-text", "text" + (text[i] === "" ? "" : ".text-" + text[i])) - .attr("data-text-class", "text-" + text[i]); + y += 15 + points['t' + i] = new Point(0, y) + .attr('data-text', 'text' + (text[i] === '' ? '' : '.text-' + text[i])) + .attr('data-text-class', 'text-' + text[i]) } - store.set("y", y); + store.set('y', y) - return part; + return part } diff --git a/packages/sandy/example/src/App.js b/packages/sandy/example/src/App.js index e7936330e5d..115cdf683af 100644 --- a/packages/sandy/example/src/App.js +++ b/packages/sandy/example/src/App.js @@ -1,22 +1,15 @@ -import React from "react"; -import freesewing from "@freesewing/core"; -import Workbench from "@freesewing/components/Workbench"; -import "typeface-roboto-condensed"; -import "@freesewing/css-theme"; +import React from 'react' +import freesewing from '@freesewing/core' +import Workbench from '@freesewing/components/Workbench' +import 'typeface-roboto-condensed' +import '@freesewing/css-theme' -import Pattern from "pattern"; +import Pattern from 'pattern' const App = props => { - let instance = new Pattern(); - let config = instance.config; - return ( - - ); -}; + let instance = new Pattern() + let config = instance.config + return +} -export default App; +export default App diff --git a/packages/sandy/example/src/index.js b/packages/sandy/example/src/index.js index 7900787a4d2..9dd7ba788d4 100644 --- a/packages/sandy/example/src/index.js +++ b/packages/sandy/example/src/index.js @@ -1,11 +1,11 @@ -import React from "react"; -import ReactDOM from "react-dom"; -import App from "./App"; -import * as serviceWorker from "./serviceWorker"; +import React from 'react' +import ReactDOM from 'react-dom' +import App from './App' +import * as serviceWorker from './serviceWorker' -ReactDOM.render(, document.getElementById("root")); +ReactDOM.render(, document.getElementById('root')) // If you want your app to work offline and load faster, you can change // unregister() to register() below. Note this comes with some pitfalls. // Learn more about service workers: http://bit.ly/CRA-PWA -serviceWorker.unregister(); +serviceWorker.unregister() diff --git a/packages/sandy/example/src/serviceWorker.js b/packages/sandy/example/src/serviceWorker.js index 68fda5a0eb6..44e1b1b2f8c 100644 --- a/packages/sandy/example/src/serviceWorker.js +++ b/packages/sandy/example/src/serviceWorker.js @@ -9,46 +9,44 @@ // This link also includes instructions on opting out of this behavior. const isLocalhost = Boolean( - window.location.hostname === "localhost" || + window.location.hostname === 'localhost' || // [::1] is the IPv6 localhost address. - window.location.hostname === "[::1]" || + window.location.hostname === '[::1]' || // 127.0.0.1/8 is considered localhost for IPv4. - window.location.hostname.match( - /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ - ) -); + window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/) +) export function register(config) { - if (process.env.NODE_ENV === "production" && "serviceWorker" in navigator) { + if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) { // The URL constructor is available in all browsers that support SW. - const publicUrl = new URL(process.env.PUBLIC_URL, window.location); + const publicUrl = new URL(process.env.PUBLIC_URL, window.location) if (publicUrl.origin !== window.location.origin) { // Our service worker won't work if PUBLIC_URL is on a different origin // from what our page is served on. This might happen if a CDN is used to // serve assets; see https://github.com/facebook/create-react-app/issues/2374 - return; + return } - window.addEventListener("load", () => { - const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; + window.addEventListener('load', () => { + const swUrl = `${process.env.PUBLIC_URL}/service-worker.js` if (isLocalhost) { // This is running on localhost. Let's check if a service worker still exists or not. - checkValidServiceWorker(swUrl, config); + checkValidServiceWorker(swUrl, config) // Add some additional logging to localhost, pointing developers to the // service worker/PWA documentation. navigator.serviceWorker.ready.then(() => { console.log( - "This web app is being served cache-first by a service " + - "worker. To learn more, visit https://goo.gl/SC7cgQ" - ); - }); + 'This web app is being served cache-first by a service ' + + 'worker. To learn more, visit https://goo.gl/SC7cgQ' + ) + }) } else { // Is not local host. Just register service worker - registerValidSW(swUrl, config); + registerValidSW(swUrl, config) } - }); + }) } } @@ -57,38 +55,38 @@ function registerValidSW(swUrl, config) { .register(swUrl) .then(registration => { registration.onupdatefound = () => { - const installingWorker = registration.installing; + const installingWorker = registration.installing installingWorker.onstatechange = () => { - if (installingWorker.state === "installed") { + if (installingWorker.state === 'installed') { if (navigator.serviceWorker.controller) { // At this point, the old content will have been purged and // the fresh content will have been added to the cache. // It's the perfect time to display a "New content is // available; please refresh." message in your web app. - console.log("New content is available; please refresh."); + console.log('New content is available; please refresh.') // Execute callback if (config.onUpdate) { - config.onUpdate(registration); + config.onUpdate(registration) } } else { // At this point, everything has been precached. // It's the perfect time to display a // "Content is cached for offline use." message. - console.log("Content is cached for offline use."); + console.log('Content is cached for offline use.') // Execute callback if (config.onSuccess) { - config.onSuccess(registration); + config.onSuccess(registration) } } } - }; - }; + } + } }) .catch(error => { - console.error("Error during service worker registration:", error); - }); + console.error('Error during service worker registration:', error) + }) } function checkValidServiceWorker(swUrl, config) { @@ -98,30 +96,28 @@ function checkValidServiceWorker(swUrl, config) { // Ensure service worker exists, and that we really are getting a JS file. if ( response.status === 404 || - response.headers.get("content-type").indexOf("javascript") === -1 + response.headers.get('content-type').indexOf('javascript') === -1 ) { // No service worker found. Probably a different app. Reload the page. navigator.serviceWorker.ready.then(registration => { registration.unregister().then(() => { - window.location.reload(); - }); - }); + window.location.reload() + }) + }) } else { // Service worker found. Proceed as normal. - registerValidSW(swUrl, config); + registerValidSW(swUrl, config) } }) .catch(() => { - console.log( - "No internet connection found. App is running in offline mode." - ); - }); + console.log('No internet connection found. App is running in offline mode.') + }) } export function unregister() { - if ("serviceWorker" in navigator) { + if ('serviceWorker' in navigator) { navigator.serviceWorker.ready.then(registration => { - registration.unregister(); - }); + registration.unregister() + }) } } diff --git a/packages/sandy/src/curved-waistband.js b/packages/sandy/src/curved-waistband.js index 12aa891b110..28d92c0c34d 100644 --- a/packages/sandy/src/curved-waistband.js +++ b/packages/sandy/src/curved-waistband.js @@ -1,4 +1,4 @@ -import draftRingSector from "./shared"; +import draftRingSector from './shared' export default function(part) { /** @@ -19,117 +19,102 @@ export default function(part) { complete, paperless, macro - } = part.shorthand(); + } = part.shorthand() // Calculate the angle of the ring sector and the radius of the upper arc const an = - utils.rad2deg( - store.get("bottomCircumference") - store.get("topCircumference") - ) / options.waistbandWidth; + utils.rad2deg(store.get('bottomCircumference') - store.get('topCircumference')) / + options.waistbandWidth - const rad = store.get("topCircumference") / utils.deg2rad(an); + const rad = store.get('topCircumference') / utils.deg2rad(an) // Extra angle to extend the waistband to overlap according to waistbandOverlap - const anExtra = utils.rad2deg( - store.get("waistbandOverlap") / (rad + options.waistbandWidth) - ); + const anExtra = utils.rad2deg(store.get('waistbandOverlap') / (rad + options.waistbandWidth)) // The curved waistband is shown with no rotation - const rot = 0; + const rot = 0 // Call draftRingSector to draft the part - paths.seam = draftRingSector( - part, - rot, - an + anExtra, - rad, - rad + options.waistbandWidth - ).attr("class", "fabric"); + paths.seam = draftRingSector(part, rot, an + anExtra, rad, rad + options.waistbandWidth).attr( + 'class', + 'fabric' + ) // Anchor samples to the centre of the waist - points.gridAnchor = points.in1.clone(); + points.gridAnchor = points.in1.clone() // Complete pattern? if (complete) { - points.title = points.in1Rotated - .shiftFractionTowards(points.ex1Rotated, 0.5) - .shift(0, 25); - macro("title", { + points.title = points.in1Rotated.shiftFractionTowards(points.ex1Rotated, 0.5).shift(0, 25) + macro('title', { at: points.title, nr: 2, - title: "curvedWaistband", + title: 'curvedWaistband', scale: 0.5 - }); + }) points.grainlineFrom = utils.curveIntersectsY( points.ex2FlippedRotated, points.ex2CFlippedRotated, points.ex1CFlippedRotated, points.ex1Rotated, points.title.y - ); - points.grainlineTo = points.grainlineFrom.flipX(); - macro("grainline", { + ) + points.grainlineTo = points.grainlineFrom.flipX() + macro('grainline', { from: points.grainlineFrom, to: points.grainlineTo - }); + }) - if (store.get("waistbandOverlap") >= options.minimumOverlap) { - points.pivot = points.in2Rotated.shiftFractionTowards( - points.ex2Rotated, - 0.5 - ); + if (store.get('waistbandOverlap') >= options.minimumOverlap) { + points.pivot = points.in2Rotated.shiftFractionTowards(points.ex2Rotated, 0.5) points.button = points.pivot - .shiftTowards(points.ex2Rotated, store.get("waistbandOverlap") / 2) - .rotate(-90, points.pivot); - points.buttonhole = points.button.flipX(); - snippets.button = new Snippet("button", points.button); - snippets.buttonhole = new Snippet("buttonhole", points.buttonhole).attr( - "data-rotate", + .shiftTowards(points.ex2Rotated, store.get('waistbandOverlap') / 2) + .rotate(-90, points.pivot) + points.buttonhole = points.button.flipX() + snippets.button = new Snippet('button', points.button) + snippets.buttonhole = new Snippet('buttonhole', points.buttonhole).attr( + 'data-rotate', -1 * points.ex2FlippedRotated.angle(points.in2FlippedRotated) - ); + ) points.centerNotch = new Path() .move(points.ex1Rotated) - .curve( - points.ex1CFlippedRotated, - points.ex2CFlippedRotated, - points.ex2FlippedRotated - ) - .shiftAlong(store.get("waistbandOverlap") / 2); + .curve(points.ex1CFlippedRotated, points.ex2CFlippedRotated, points.ex2FlippedRotated) + .shiftAlong(store.get('waistbandOverlap') / 2) points.buttonNotch = new Path() .move(points.ex2Rotated) .curve(points.ex2CRotated, points.ex1CRotated, points.ex1Rotated) - .shiftAlong(store.get("waistbandOverlap")); - macro("sprinkle", { - snippet: "notch", - on: ["centerNotch", "buttonNotch", "ex2FlippedRotated"] - }); + .shiftAlong(store.get('waistbandOverlap')) + macro('sprinkle', { + snippet: 'notch', + on: ['centerNotch', 'buttonNotch', 'ex2FlippedRotated'] + }) } - if (sa) paths.sa = paths.seam.offset(sa * -1).attr("class", "fabric sa"); + if (sa) paths.sa = paths.seam.offset(sa * -1).attr('class', 'fabric sa') } // Paperless? if (paperless) { - macro("hd", { + macro('hd', { from: points.in2FlippedRotated, to: points.in2Rotated, y: points.in2Rotated.y - sa - 15 - }); - macro("hd", { + }) + macro('hd', { from: points.ex2FlippedRotated, to: points.ex2Rotated, y: points.in2Rotated.y - sa - 30 - }); - macro("vd", { + }) + macro('vd', { from: points.ex1Rotated, to: points.in2Rotated, x: points.in2Rotated.x + sa + 30 - }); - macro("ld", { + }) + macro('ld', { from: points.ex2Rotated, to: points.in2Rotated, d: -1 * sa - 15 - }); + }) } - return part; + return part } diff --git a/packages/sandy/src/index.js b/packages/sandy/src/index.js index cb7a465cced..ba090ff6a35 100644 --- a/packages/sandy/src/index.js +++ b/packages/sandy/src/index.js @@ -1,15 +1,15 @@ -import freesewing from "@freesewing/core"; -import plugins from "@freesewing/plugin-bundle"; -import config from "../config"; +import freesewing from '@freesewing/core' +import plugins from '@freesewing/plugin-bundle' +import config from '../config' // Parts -import draftSkirt from "./skirt"; -import draftWaistband from "./waistband"; +import draftSkirt from './skirt' +import draftWaistband from './waistband' // Create design -const Pattern = new freesewing.Design(config, plugins); +const Pattern = new freesewing.Design(config, plugins) // Attach draft methods to prototype -Pattern.prototype.draftSkirt = part => draftSkirt(part); -Pattern.prototype.draftWaistband = part => draftWaistband(part); +Pattern.prototype.draftSkirt = part => draftSkirt(part) +Pattern.prototype.draftWaistband = part => draftWaistband(part) -export default Pattern; +export default Pattern diff --git a/packages/sandy/src/shared.js b/packages/sandy/src/shared.js index 5eaf47d6008..32351e8bf46 100644 --- a/packages/sandy/src/shared.js +++ b/packages/sandy/src/shared.js @@ -1,20 +1,20 @@ const draftRingSector = (part, rot, an, radIn, radEx, rotate = false) => { - let { utils, Point, points, Path } = part.shorthand(); + let { utils, Point, points, Path } = part.shorthand() const roundExtended = (radius, angle = 90) => { - let arg = utils.deg2rad(angle / 2); + let arg = utils.deg2rad(angle / 2) - return (radius * 4 * (1 - Math.cos(arg))) / Math.sin(arg) / 3; - }; + return (radius * 4 * (1 - Math.cos(arg))) / Math.sin(arg) / 3 + } /** * Calculates the distance of the control point for the internal * and external arcs using bezierCircleExtended */ - let distIn = roundExtended(radIn, an / 2); - let distEx = roundExtended(radEx, an / 2); + let distIn = roundExtended(radIn, an / 2) + let distEx = roundExtended(radEx, an / 2) // The centre of the circles - points.center = new Point(0, 0); + points.center = new Point(0, 0) /** * This function is expected to draft ring sectors for @@ -27,7 +27,7 @@ const draftRingSector = (part, rot, an, radIn, radEx, rotate = false) => { * The first point of the internal arc, situated at * a radIn distance below the centre */ - points.in1 = points.center.shift(-90, radIn); + points.in1 = points.center.shift(-90, radIn) /** * The control point for 'in1'. It's situated at a @@ -36,14 +36,14 @@ const draftRingSector = (part, rot, an, radIn, radEx, rotate = false) => { * the line between 'in1' and the centre, so it's * shifted in the direction 0º */ - points.in1C = points.in1.shift(0, distIn); + points.in1C = points.in1.shift(0, distIn) /** * The second point of the internal arc, situated at * a $radIn distance of the centre in the direction * $an/2 - 90º */ - points.in2 = points.center.shift(an / 2 - 90, radIn); + points.in2 = points.center.shift(an / 2 - 90, radIn) /** * The control point for 'in2'. It's situated at a @@ -52,45 +52,45 @@ const draftRingSector = (part, rot, an, radIn, radEx, rotate = false) => { * the line between 'in2' and the centre, so it's * shifted in the direction $an/2 + 180º */ - points.in2C = points.in2.shift(an / 2 + 180, distIn); + points.in2C = points.in2.shift(an / 2 + 180, distIn) /** * The points for the external arc are generated in the * same way, using $radEx and $distEx instead */ - points.ex1 = points.center.shift(-90, radEx); - points.ex1C = points.ex1.shift(0, distEx); - points.ex2 = points.center.shift(an / 2 - 90, radEx); - points.ex2C = points.ex2.shift(an / 2 + 180, distEx); + points.ex1 = points.center.shift(-90, radEx) + points.ex1C = points.ex1.shift(0, distEx) + points.ex2 = points.center.shift(an / 2 - 90, radEx) + points.ex2C = points.ex2.shift(an / 2 + 180, distEx) // Flip all the points to generate the full ring sector - for (let id of ["in2", "in2C", "in1C", "ex1C", "ex2C", "ex2"]) - points[id + "Flipped"] = points[id].flipX(); + for (let id of ['in2', 'in2C', 'in1C', 'ex1C', 'ex2C', 'ex2']) + points[id + 'Flipped'] = points[id].flipX() // Rotate all the points an angle rot for (let id of [ - "in1", - "in1C", - "in2", - "in2C", - "ex1", - "ex1C", - "ex2", - "ex2C", - "in2Flipped", - "in2CFlipped", - "in1CFlipped", - "ex1CFlipped", - "ex2CFlipped", - "ex2Flipped" + 'in1', + 'in1C', + 'in2', + 'in2C', + 'ex1', + 'ex1C', + 'ex2', + 'ex2C', + 'in2Flipped', + 'in2CFlipped', + 'in1CFlipped', + 'ex1CFlipped', + 'ex2CFlipped', + 'ex2Flipped' ]) - points[id + "Rotated"] = points[id].rotate(rot, points.center); + points[id + 'Rotated'] = points[id].rotate(rot, points.center) if (rotate) { // Rotate all points so the line from in1Rotated to ex1Rotated is vertical - let deg = 270 - points.in2Flipped.angle(points.ex2Flipped); + let deg = 270 - points.in2Flipped.angle(points.ex2Flipped) for (let id in points) { - points[id] = points[id].rotate(deg, points.in2Flipped); + points[id] = points[id].rotate(deg, points.in2Flipped) } } // Return the path of the full ring sector @@ -101,7 +101,7 @@ const draftRingSector = (part, rot, an, radIn, radEx, rotate = false) => { .line(points.ex2) .curve(points.ex2C, points.ex1C, points.ex1) .curve(points.ex1CFlipped, points.ex2CFlipped, points.ex2Flipped) - .close(); -}; + .close() +} -export default draftRingSector; +export default draftRingSector diff --git a/packages/sandy/src/skirt.js b/packages/sandy/src/skirt.js index e3ec29702ab..bc1daaaea31 100644 --- a/packages/sandy/src/skirt.js +++ b/packages/sandy/src/skirt.js @@ -1,4 +1,4 @@ -import draftRingSector from "./shared"; +import draftRingSector from './shared' export default function(part) { let { @@ -15,49 +15,41 @@ export default function(part) { complete, paperless, macro - } = part.shorthand(); + } = part.shorthand() // Circumference of the top of the waistband, calculated from the waistbandPosition option store.set( - "topCircumference", + 'topCircumference', options.waistbandPosition * measurements.hipsCircumference + (1 - options.waistbandPosition) * measurements.naturalWaist - ); + ) // Circumference of the bottom of the waistband - if (options.waistbandShape === "curved") { + if (options.waistbandShape === 'curved') { // If the waistband is curved, the bottom circumference is calculated from the measurements store.set( - "bottomCircumference", - store.get("topCircumference") + - (options.waistbandWidth * - (measurements.hipsCircumference - measurements.naturalWaist)) / + 'bottomCircumference', + store.get('topCircumference') + + (options.waistbandWidth * (measurements.hipsCircumference - measurements.naturalWaist)) / measurements.naturalWaistToHip - ); + ) } else { // If the waistband is straight, the bottom circumference is the same as the top circumference - store.set("bottomCircumference", store.get("topCircumference")); + store.set('bottomCircumference', store.get('topCircumference')) } // Overlap of the waistband - store.set( - "waistbandOverlap", - store.get("topCircumference") * options.waistbandOverlap - ); + store.set('waistbandOverlap', store.get('topCircumference') * options.waistbandOverlap) // The top circumference of the skirt corresponds to the bottom circumference of the waistband, plus the extraWaist option for gathering/pleating - store.set( - "skirtCircumference", - store.get("bottomCircumference") * (1 + options.gathering) - ); + store.set('skirtCircumference', store.get('bottomCircumference') * (1 + options.gathering)) // The length from the top of the skirt to the floor (max length available) store.set( - "fullLength", - measurements.naturalWaistToFloor - - measurements.naturalWaistToHip * options.waistbandPosition - ); + 'fullLength', + measurements.naturalWaistToFloor - measurements.naturalWaistToHip * options.waistbandPosition + ) - let radiusWaist, an; + let radiusWaist, an if (options.seamlessFullCircle) { /** * If the seamless full circle option is selected, the angle @@ -65,15 +57,15 @@ export default function(part) { * it's not selected, because in this case the fabric is cut * in a double fold */ - an = 90; - radiusWaist = store.get("skirtCircumference") / utils.deg2rad(an) / 4; + an = 90 + radiusWaist = store.get('skirtCircumference') / utils.deg2rad(an) / 4 } else { /** * If the seamless full circle option is not selected, the * angle is calculated using the circlePercent option */ - an = 180 * options.circleRatio; - radiusWaist = store.get("skirtCircumference") / utils.deg2rad(an) / 2; + an = 180 * options.circleRatio + radiusWaist = store.get('skirtCircumference') / utils.deg2rad(an) / 2 /** * If the angle is too large, the seam allowance can fall out @@ -82,8 +74,8 @@ export default function(part) { * fabric */ if (an > 90 && sa) { - let maxAn = utils.rad2deg(Math.atan(radiusWaist / sa)); - if (an > 90 + maxAn) an = 90 + maxAn; + let maxAn = utils.rad2deg(Math.atan(radiusWaist / sa)) + if (an > 90 + maxAn) an = 90 + maxAn } } /** @@ -91,92 +83,63 @@ export default function(part) { * arc with the length of the skirt added */ let radiusHem = - radiusWaist + - store.get("fullLength") * options.lengthBonus - - options.waistbandWidth; + radiusWaist + store.get('fullLength') * options.lengthBonus - options.waistbandWidth /** * The ring sector will be rotated an angle an/2 so we * display the part with one edge of the skirt vertical */ - let rot = an / 2; + let rot = an / 2 // Call draftRingSector to draft the part - paths.seam = draftRingSector( - part, - rot, - an, - radiusWaist, - radiusHem, - true - ).attr("class", "fabric"); + paths.seam = draftRingSector(part, rot, an, radiusWaist, radiusHem, true).attr('class', 'fabric') // Anchor samples to the centre of the waist - points.gridAnchor = points.in2Flipped.clone(); + points.gridAnchor = points.in2Flipped.clone() // Complete pattern? if (complete) { - macro("cutonfold", { + macro('cutonfold', { from: points.in2Flipped, to: points.ex2Flipped, grainline: true - }); + }) if (options.seamlessFullCircle) { - macro("cutonfold", { + macro('cutonfold', { from: points.ex1Rotated, to: points.in1Rotated, - prefix: "double" - }); + prefix: 'double' + }) } - points.logo = points.in2FlippedRotated.shiftFractionTowards( - points.ex2FlippedRotated, - 0.3 - ); - snippets.logo = new Snippet("logo", points.logo); + points.logo = points.in2FlippedRotated.shiftFractionTowards(points.ex2FlippedRotated, 0.3) + snippets.logo = new Snippet('logo', points.logo) - points.title = points.in2FlippedRotated.shiftFractionTowards( - points.ex2FlippedRotated, - 0.5 - ); - macro("title", { at: points.title, nr: 1, title: "skirt" }); + points.title = points.in2FlippedRotated.shiftFractionTowards(points.ex2FlippedRotated, 0.5) + macro('title', { at: points.title, nr: 1, title: 'skirt' }) - points.scalebox = points.in2FlippedRotated.shiftFractionTowards( - points.ex2FlippedRotated, - 0.7 - ); - macro("scalebox", { at: points.scalebox }); + points.scalebox = points.in2FlippedRotated.shiftFractionTowards(points.ex2FlippedRotated, 0.7) + macro('scalebox', { at: points.scalebox }) - macro("sprinkle", { - snippet: "notch", - on: ["in1Rotated", "gridAnchor"] - }); + macro('sprinkle', { + snippet: 'notch', + on: ['in1Rotated', 'gridAnchor'] + }) if (sa) { paths.hemBase = new Path() .move(points.ex1Rotated) - .curve( - points.ex1CFlippedRotated, - points.ex2CFlippedRotated, - points.ex2FlippedRotated - ) + .curve(points.ex1CFlippedRotated, points.ex2CFlippedRotated, points.ex2FlippedRotated) .curve(points.ex1CFlipped, points.ex2CFlipped, points.ex2Flipped) - .offset( - store.get("fullLength") * options.lengthBonus * options.hemWidth * -1 - ); + .offset(store.get('fullLength') * options.lengthBonus * options.hemWidth * -1) paths.saBase = new Path() .move(points.in2Flipped) .curve(points.in2CFlipped, points.in1CFlipped, points.in2FlippedRotated) - .curve( - points.in2CFlippedRotated, - points.in1CFlippedRotated, - points.in1Rotated - ); - if (!options.seamlessFullCircle) - paths.saBase = paths.saBase.line(points.ex1Rotated); - paths.saBase = paths.saBase.offset(sa * -1); + .curve(points.in2CFlippedRotated, points.in1CFlippedRotated, points.in1Rotated) + if (!options.seamlessFullCircle) paths.saBase = paths.saBase.line(points.ex1Rotated) + paths.saBase = paths.saBase.offset(sa * -1) - paths.hemBase.render = false; - paths.saBase.render = false; + paths.hemBase.render = false + paths.saBase.render = false if (options.seamlessFullCircle) { paths.sa = new Path() @@ -188,7 +151,7 @@ export default function(part) { .line(paths.hemBase.start()) .join(paths.hemBase) .line(points.ex2Flipped) - .attr("class", "fabric sa"); + .attr('class', 'fabric sa') } else { paths.sa = new Path() .move(points.in2Flipped) @@ -197,56 +160,47 @@ export default function(part) { .line(paths.hemBase.start()) .join(paths.hemBase) .line(points.ex2Flipped) - .attr("class", "fabric sa"); + .attr('class', 'fabric sa') } } } // Paperless? if (paperless) { - macro("vd", { + macro('vd', { from: points.ex2Flipped, to: points.in2Flipped, x: points.ex2Flipped.x - sa - 15 - }); - macro("vd", { + }) + macro('vd', { from: points.in2Flipped, to: points.center, x: points.ex2Flipped.x - sa - 15 - }); - macro("vd", { + }) + macro('vd', { from: points.ex2Flipped, to: points.center, x: points.ex2Flipped.x - sa - 30 - }); + }) if (options.circleRatio !== 0.5) { - macro("vd", { + macro('vd', { from: points.ex1Rotated, to: points.in1Rotated, - x: - options.circleRatio > 0.5 - ? points.in1Rotated.x - sa - 15 - : points.ex1Rotated.x + sa + 15 - }); - macro("vd", { + x: options.circleRatio > 0.5 ? points.in1Rotated.x - sa - 15 : points.ex1Rotated.x + sa + 15 + }) + macro('vd', { from: points.in1Rotated, to: points.center, - x: - options.circleRatio > 0.5 - ? points.in1Rotated.x - sa - 15 - : points.ex1Rotated.x + sa + 15 - }); - macro("vd", { + x: options.circleRatio > 0.5 ? points.in1Rotated.x - sa - 15 : points.ex1Rotated.x + sa + 15 + }) + macro('vd', { from: points.ex1Rotated, to: points.center, - x: - options.circleRatio > 0.5 - ? points.in1Rotated.x - sa - 30 - : points.ex1Rotated.x + sa + 30 - }); + x: options.circleRatio > 0.5 ? points.in1Rotated.x - sa - 30 : points.ex1Rotated.x + sa + 30 + }) } - snippets.center = new Snippet("bnotch", points.center); + snippets.center = new Snippet('bnotch', points.center) } - return part; + return part } diff --git a/packages/sandy/src/straight-waistband.js b/packages/sandy/src/straight-waistband.js index ac9a107074b..27d77df4060 100644 --- a/packages/sandy/src/straight-waistband.js +++ b/packages/sandy/src/straight-waistband.js @@ -16,19 +16,19 @@ export default function(part) { complete, paperless, macro - } = part.shorthand(); + } = part.shorthand() // Calculate the corners of the rectangle and other auxiliar points - points.center = new Point(0, 0); - points.centerLeft = new Point(store.get("topCircumference") / -2, 0); + points.center = new Point(0, 0) + points.centerLeft = new Point(store.get('topCircumference') / -2, 0) points.centerRight = new Point( - store.get("topCircumference") / 2 + store.get("waistbandOverlap"), + store.get('topCircumference') / 2 + store.get('waistbandOverlap'), 0 - ); - points.topRight = points.centerRight.shift(90, options.waistbandWidth); - points.topLeft = points.centerLeft.shift(90, options.waistbandWidth); - points.bottomRight = points.topRight.flipY(); - points.bottomLeft = points.topLeft.flipY(); + ) + points.topRight = points.centerRight.shift(90, options.waistbandWidth) + points.topLeft = points.centerLeft.shift(90, options.waistbandWidth) + points.bottomRight = points.topRight.flipY() + points.bottomLeft = points.topLeft.flipY() // Draft the rectangle paths.seam = new Path() @@ -38,64 +38,55 @@ export default function(part) { .line(points.topRight) .line(points.topLeft) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') // Draft the foldline paths.fold = new Path() .move(points.centerRight) .line(points.centerLeft) - .attr("class", "fabric dashed"); + .attr('class', 'fabric dashed') // Complete pattern? if (complete) { - points.title = points.center.shiftFractionTowards(points.centerRight, 0.5); - macro("title", { at: points.title, nr: 2, title: "straightWaistband" }); - points.grainlineFrom = points.centerLeft.shiftFractionTowards( - points.topLeft, - 0.5 - ); - points.grainlineTo = points.grainlineFrom.flipX(); - macro("grainline", { + points.title = points.center.shiftFractionTowards(points.centerRight, 0.5) + macro('title', { at: points.title, nr: 2, title: 'straightWaistband' }) + points.grainlineFrom = points.centerLeft.shiftFractionTowards(points.topLeft, 0.5) + points.grainlineTo = points.grainlineFrom.flipX() + macro('grainline', { from: points.grainlineFrom, to: points.grainlineTo - }); + }) points.button = points.centerRight .shiftFractionTowards(points.bottomRight, 0.5) - .shift(180, store.get("waistbandOverlap") / 2); + .shift(180, store.get('waistbandOverlap') / 2) points.buttonhole = points.centerLeft .shiftFractionTowards(points.bottomLeft, 0.5) - .shift(0, store.get("waistbandOverlap") / 2); - snippets.button = new Snippet("button", points.button); - snippets.buttonhole = new Snippet("buttonhole", points.buttonhole); - points.centerNotch = new Point( - (-1 * store.get("waistbandOverlap")) / 2, - points.bottomLeft.y - ); - points.buttonNotch = points.bottomRight.shift( - 180, - store.get("waistbandOverlap") - ); - macro("sprinkle", { - snippet: "notch", - on: ["centerNotch", "buttonNotch", "bottomLeft"] - }); + .shift(0, store.get('waistbandOverlap') / 2) + snippets.button = new Snippet('button', points.button) + snippets.buttonhole = new Snippet('buttonhole', points.buttonhole) + points.centerNotch = new Point((-1 * store.get('waistbandOverlap')) / 2, points.bottomLeft.y) + points.buttonNotch = points.bottomRight.shift(180, store.get('waistbandOverlap')) + macro('sprinkle', { + snippet: 'notch', + on: ['centerNotch', 'buttonNotch', 'bottomLeft'] + }) - if (sa) paths.sa = paths.seam.offset(sa).attr("class", "fabric sa"); + if (sa) paths.sa = paths.seam.offset(sa).attr('class', 'fabric sa') } // Paperless? if (paperless) { - macro("hd", { + macro('hd', { from: points.bottomLeft, to: points.bottomRight, y: points.bottomLeft.y + sa + 15 - }); - macro("vd", { + }) + macro('vd', { from: points.bottomRight, to: points.topRight, x: points.topRight.x + sa + 15 - }); + }) } - return part; + return part } diff --git a/packages/sandy/src/waistband.js b/packages/sandy/src/waistband.js index 76d3d14211a..aa192e20ba5 100644 --- a/packages/sandy/src/waistband.js +++ b/packages/sandy/src/waistband.js @@ -1,10 +1,10 @@ -import straightWaistband from "./straight-waistband"; -import curvedWaistband from "./curved-waistband"; +import straightWaistband from './straight-waistband' +import curvedWaistband from './curved-waistband' export default part => { - let { store, options } = part.shorthand(); - console.log("WB", store.get("topCircumference")); + let { store, options } = part.shorthand() + console.log('WB', store.get('topCircumference')) - if (options.waistbandShape === "curved") return curvedWaistband(part); - else return straightWaistband(part); -}; + if (options.waistbandShape === 'curved') return curvedWaistband(part) + else return straightWaistband(part) +} diff --git a/packages/shin/example/src/App.js b/packages/shin/example/src/App.js index e7936330e5d..115cdf683af 100644 --- a/packages/shin/example/src/App.js +++ b/packages/shin/example/src/App.js @@ -1,22 +1,15 @@ -import React from "react"; -import freesewing from "@freesewing/core"; -import Workbench from "@freesewing/components/Workbench"; -import "typeface-roboto-condensed"; -import "@freesewing/css-theme"; +import React from 'react' +import freesewing from '@freesewing/core' +import Workbench from '@freesewing/components/Workbench' +import 'typeface-roboto-condensed' +import '@freesewing/css-theme' -import Pattern from "pattern"; +import Pattern from 'pattern' const App = props => { - let instance = new Pattern(); - let config = instance.config; - return ( - - ); -}; + let instance = new Pattern() + let config = instance.config + return +} -export default App; +export default App diff --git a/packages/shin/example/src/index.js b/packages/shin/example/src/index.js index 7900787a4d2..9dd7ba788d4 100644 --- a/packages/shin/example/src/index.js +++ b/packages/shin/example/src/index.js @@ -1,11 +1,11 @@ -import React from "react"; -import ReactDOM from "react-dom"; -import App from "./App"; -import * as serviceWorker from "./serviceWorker"; +import React from 'react' +import ReactDOM from 'react-dom' +import App from './App' +import * as serviceWorker from './serviceWorker' -ReactDOM.render(, document.getElementById("root")); +ReactDOM.render(, document.getElementById('root')) // If you want your app to work offline and load faster, you can change // unregister() to register() below. Note this comes with some pitfalls. // Learn more about service workers: http://bit.ly/CRA-PWA -serviceWorker.unregister(); +serviceWorker.unregister() diff --git a/packages/shin/example/src/serviceWorker.js b/packages/shin/example/src/serviceWorker.js index 68fda5a0eb6..44e1b1b2f8c 100644 --- a/packages/shin/example/src/serviceWorker.js +++ b/packages/shin/example/src/serviceWorker.js @@ -9,46 +9,44 @@ // This link also includes instructions on opting out of this behavior. const isLocalhost = Boolean( - window.location.hostname === "localhost" || + window.location.hostname === 'localhost' || // [::1] is the IPv6 localhost address. - window.location.hostname === "[::1]" || + window.location.hostname === '[::1]' || // 127.0.0.1/8 is considered localhost for IPv4. - window.location.hostname.match( - /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ - ) -); + window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/) +) export function register(config) { - if (process.env.NODE_ENV === "production" && "serviceWorker" in navigator) { + if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) { // The URL constructor is available in all browsers that support SW. - const publicUrl = new URL(process.env.PUBLIC_URL, window.location); + const publicUrl = new URL(process.env.PUBLIC_URL, window.location) if (publicUrl.origin !== window.location.origin) { // Our service worker won't work if PUBLIC_URL is on a different origin // from what our page is served on. This might happen if a CDN is used to // serve assets; see https://github.com/facebook/create-react-app/issues/2374 - return; + return } - window.addEventListener("load", () => { - const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; + window.addEventListener('load', () => { + const swUrl = `${process.env.PUBLIC_URL}/service-worker.js` if (isLocalhost) { // This is running on localhost. Let's check if a service worker still exists or not. - checkValidServiceWorker(swUrl, config); + checkValidServiceWorker(swUrl, config) // Add some additional logging to localhost, pointing developers to the // service worker/PWA documentation. navigator.serviceWorker.ready.then(() => { console.log( - "This web app is being served cache-first by a service " + - "worker. To learn more, visit https://goo.gl/SC7cgQ" - ); - }); + 'This web app is being served cache-first by a service ' + + 'worker. To learn more, visit https://goo.gl/SC7cgQ' + ) + }) } else { // Is not local host. Just register service worker - registerValidSW(swUrl, config); + registerValidSW(swUrl, config) } - }); + }) } } @@ -57,38 +55,38 @@ function registerValidSW(swUrl, config) { .register(swUrl) .then(registration => { registration.onupdatefound = () => { - const installingWorker = registration.installing; + const installingWorker = registration.installing installingWorker.onstatechange = () => { - if (installingWorker.state === "installed") { + if (installingWorker.state === 'installed') { if (navigator.serviceWorker.controller) { // At this point, the old content will have been purged and // the fresh content will have been added to the cache. // It's the perfect time to display a "New content is // available; please refresh." message in your web app. - console.log("New content is available; please refresh."); + console.log('New content is available; please refresh.') // Execute callback if (config.onUpdate) { - config.onUpdate(registration); + config.onUpdate(registration) } } else { // At this point, everything has been precached. // It's the perfect time to display a // "Content is cached for offline use." message. - console.log("Content is cached for offline use."); + console.log('Content is cached for offline use.') // Execute callback if (config.onSuccess) { - config.onSuccess(registration); + config.onSuccess(registration) } } } - }; - }; + } + } }) .catch(error => { - console.error("Error during service worker registration:", error); - }); + console.error('Error during service worker registration:', error) + }) } function checkValidServiceWorker(swUrl, config) { @@ -98,30 +96,28 @@ function checkValidServiceWorker(swUrl, config) { // Ensure service worker exists, and that we really are getting a JS file. if ( response.status === 404 || - response.headers.get("content-type").indexOf("javascript") === -1 + response.headers.get('content-type').indexOf('javascript') === -1 ) { // No service worker found. Probably a different app. Reload the page. navigator.serviceWorker.ready.then(registration => { registration.unregister().then(() => { - window.location.reload(); - }); - }); + window.location.reload() + }) + }) } else { // Service worker found. Proceed as normal. - registerValidSW(swUrl, config); + registerValidSW(swUrl, config) } }) .catch(() => { - console.log( - "No internet connection found. App is running in offline mode." - ); - }); + console.log('No internet connection found. App is running in offline mode.') + }) } export function unregister() { - if ("serviceWorker" in navigator) { + if ('serviceWorker' in navigator) { navigator.serviceWorker.ready.then(registration => { - registration.unregister(); - }); + registration.unregister() + }) } } diff --git a/packages/shin/src/back.js b/packages/shin/src/back.js index fe9dff0720f..6078de1b6f5 100644 --- a/packages/shin/src/back.js +++ b/packages/shin/src/back.js @@ -14,89 +14,71 @@ export default function(part) { options, measurements, utils - } = part.shorthand(); + } = part.shorthand() // Store some helper variables - store.set( - "hips", - (measurements.hipsCircumference / 2) * utils.stretchToScale(options.stretch) - ); - store.set("hipFront", store.get("hips") * options.frontFactor); - store.set("hipBack", store.get("hips") * (1 - options.frontFactor)); - store.set( - "legs", - measurements.upperLegCircumference * utils.stretchToScale(options.stretch) - ); - store.set("legFront", store.get("legs") * options.legFrontFactor); - store.set("legBack", store.get("legs") * (1 - options.legFrontFactor)); - store.set("gusset", measurements.hipsCircumference * options.gussetFactor); + store.set('hips', (measurements.hipsCircumference / 2) * utils.stretchToScale(options.stretch)) + store.set('hipFront', store.get('hips') * options.frontFactor) + store.set('hipBack', store.get('hips') * (1 - options.frontFactor)) + store.set('legs', measurements.upperLegCircumference * utils.stretchToScale(options.stretch)) + store.set('legFront', store.get('legs') * options.legFrontFactor) + store.set('legBack', store.get('legs') * (1 - options.legFrontFactor)) + store.set('gusset', measurements.hipsCircumference * options.gussetFactor) - points.hipSide = new Point(0, 0); - points.hipCb = new Point(store.get("hipBack"), 0); - points.legSide = points.hipSide.shift( - -90 - options.angle, - measurements.hipsToUpperLeg - ); - points.legSideCp = points.legSide.shift( - options.angle * -1 + 7, - store.get("legBack") - ); - points.legInner = points.legSideCp.shift( - options.angle * -1 - 90, - store.get("gusset") / 2 - ); - points.legSideCp = points.legSideCp.shiftFractionTowards(points.legSide, 0.5); + points.hipSide = new Point(0, 0) + points.hipCb = new Point(store.get('hipBack'), 0) + points.legSide = points.hipSide.shift(-90 - options.angle, measurements.hipsToUpperLeg) + points.legSideCp = points.legSide.shift(options.angle * -1 + 7, store.get('legBack')) + points.legInner = points.legSideCp.shift(options.angle * -1 - 90, store.get('gusset') / 2) + points.legSideCp = points.legSideCp.shiftFractionTowards(points.legSide, 0.5) let tmp = new Path() .move(points.legInner) ._curve(points.legSideCp, points.legSide) - .shiftAlong(2); - let gussetAngle = points.legInner.angle(tmp); - points.crossSeam = points.legInner.shift( - gussetAngle - 90, - store.get("gusset") - ); - points.seatCb = points.hipCb.shift(-86, measurements.hipsToUpperLeg * 0.62); + .shiftAlong(2) + let gussetAngle = points.legInner.angle(tmp) + points.crossSeam = points.legInner.shift(gussetAngle - 90, store.get('gusset')) + points.seatCb = points.hipCb.shift(-86, measurements.hipsToUpperLeg * 0.62) tmp = utils.beamsIntersect( points.crossSeam, points.crossSeam.shift(gussetAngle, 20), points.hipCb, points.seatCb - ); - points.seatCp = points.seatCb.shiftFractionTowards(tmp, 0.7); - points.crossSeamCp = points.crossSeam.shiftFractionTowards(tmp, 0.7); + ) + points.seatCp = points.seatCb.shiftFractionTowards(tmp, 0.7) + points.crossSeamCp = points.crossSeam.shiftFractionTowards(tmp, 0.7) // Reduce the legs points.reducedLegInner = new Path() .move(points.legSide) .curve_(points.legSideCp, points.legInner) - .shiftFractionAlong(1 - options.legReduction); - points.reducedLegInnerCp = points.legInner.rotate(90, points.reducedLegInner); + .shiftFractionAlong(1 - options.legReduction) + points.reducedLegInnerCp = points.legInner.rotate(90, points.reducedLegInner) points.reducedCrossSeam = new Path() .move(points.crossSeam) .curve(points.crossSeamCp, points.seatCp, points.seatCb) - .shiftFractionAlong(options.legReduction * 2); + .shiftFractionAlong(options.legReduction * 2) // Lengthen the legs if (options.legBonus > 0) { - let bonus = measurements.hipsToUpperLeg * options.legBonus; - points.legSide = points.legSide.shift(-90, bonus); - points.legSideCp = points.legSideCp.shift(-90, bonus); - points.reducedLegInner = points.reducedLegInner.shift(-90, bonus); + let bonus = measurements.hipsToUpperLeg * options.legBonus + points.legSide = points.legSide.shift(-90, bonus) + points.legSideCp = points.legSideCp.shift(-90, bonus) + points.reducedLegInner = points.reducedLegInner.shift(-90, bonus) } // Rise if (options.rise > 0) { - let rise = measurements.hipsToUpperLeg * options.rise; - points.hipSide = points.hipSide.shift(90, rise); - points.hipCb = points.hipCb.shift(90, rise); + let rise = measurements.hipsToUpperLeg * options.rise + points.hipSide = points.hipSide.shift(90, rise) + points.hipCb = points.hipCb.shift(90, rise) } // Back rise if (options.backRise > 0) { - let backRise = measurements.hipsToUpperLeg * options.backRise; - points.hipCb = points.hipCb.shift(90, backRise); - points.hipSide = points.hipSide.shift(90, backRise); - points.hipCbCp = new Point(points.hipCb.x / 2, points.hipCb.y); + let backRise = measurements.hipsToUpperLeg * options.backRise + points.hipCb = points.hipCb.shift(90, backRise) + points.hipSide = points.hipSide.shift(90, backRise) + points.hipCbCp = new Point(points.hipCb.x / 2, points.hipCb.y) } // Paths @@ -105,22 +87,20 @@ export default function(part) { .curve(points.crossSeamCp, points.seatCp, points.seatCb) .split(points.reducedCrossSeam) // Now split it .pop() // Return the relevant part - .line(points.hipCb); // Continue from here - if (options.backRise > 0) paths.saBase._curve(points.hipCbCp, points.hipSide); - else paths.saBase.line(points.hipSide); - paths.saBase.line(points.legSide); + .line(points.hipCb) // Continue from here + if (options.backRise > 0) paths.saBase._curve(points.hipCbCp, points.hipSide) + else paths.saBase.line(points.hipSide) + paths.saBase.line(points.legSide) paths.saBase = new Path() .move(points.reducedLegInner) .line(points.reducedCrossSeam) - .join(paths.saBase); + .join(paths.saBase) - paths.hemBase = new Path() - .move(points.legSide) - .curve_(points.legSideCp, points.reducedLegInner); - paths.saBase.render = false; - paths.hemBase.render = false; + paths.hemBase = new Path().move(points.legSide).curve_(points.legSideCp, points.reducedLegInner) + paths.saBase.render = false + paths.hemBase.render = false - paths.seam = paths.saBase.join(paths.hemBase).attr("class", "fabric"); + paths.seam = paths.saBase.join(paths.hemBase).attr('class', 'fabric') /** Uncomment this to see the reduced crossSeam paths.xred = new Path() @@ -131,66 +111,66 @@ export default function(part) { // Complete? if (complete) { - points.logo = points.hipSide.shiftFractionTowards(points.seatCb, 0.3); - points.title = points.hipSide.shiftFractionTowards(points.seatCb, 0.7); - snippets.logo = new Snippet("logo", points.logo); - macro("title", { + points.logo = points.hipSide.shiftFractionTowards(points.seatCb, 0.3) + points.title = points.hipSide.shiftFractionTowards(points.seatCb, 0.7) + snippets.logo = new Snippet('logo', points.logo) + macro('title', { at: points.title, nr: 1, - title: "back" - }); + title: 'back' + }) if (sa) { paths.sa = paths.hemBase .offset(3 * sa) .join(paths.saBase.offset(sa)) .close() - .attr("class", "fabric sa"); + .attr('class', 'fabric sa') } } // Paperless? if (paperless) { - macro("hd", { + macro('hd', { from: points.hipSide, to: points.hipCb, y: points.hipCb.y - sa - 15 - }); - macro("hd", { + }) + macro('hd', { from: points.legSide, to: points.hipCb, y: points.hipCb.y - sa - 30 - }); - macro("vd", { + }) + macro('vd', { from: points.legSide, to: points.hipSide, x: points.legSide.x - sa - 15 - }); - macro("vd", { + }) + macro('vd', { from: points.reducedLegInner, to: points.hipSide, x: points.legSide.x - sa - 30 - }); - macro("hd", { + }) + macro('hd', { from: points.legSide, to: points.reducedLegInner, y: points.reducedLegInner.y + 3 * sa + 15 - }); - macro("hd", { + }) + macro('hd', { from: points.legSide, to: points.reducedCrossSeam, y: points.reducedLegInner.y + 3 * sa + 30 - }); - macro("vd", { + }) + macro('vd', { from: points.reducedLegInner, to: points.reducedCrossSeam, x: points.reducedCrossSeam.x + sa + 15 - }); - macro("vd", { + }) + macro('vd', { from: points.reducedLegInner, to: points.hipCb, x: points.reducedCrossSeam.x + sa + 30 - }); + }) } - return part; + return part } diff --git a/packages/shin/src/front.js b/packages/shin/src/front.js index a4347ee0cb4..17291477732 100644 --- a/packages/shin/src/front.js +++ b/packages/shin/src/front.js @@ -14,99 +14,70 @@ export default function(part) { options, measurements, utils - } = part.shorthand(); + } = part.shorthand() - let angle = -12; - let bulge = measurements.hipsToUpperLeg * options.bulge; - points.hipSide = new Point(0, 0); - points.hipCb = new Point(store.get("hipFront"), 0); - points.legSide = points.hipSide.shift( - -90 - angle, - measurements.hipsToUpperLeg - ); - points.legSideCp = points.legSide.shift(0, store.get("legFront")); - points.legInner = points.legSideCp.shift(-100, store.get("gusset") / 2); - points.crossSeam = points.legSideCp.shift(80, store.get("gusset") / 2); - points.legSideCp = points.legSide.shiftFractionTowards(points.legSideCp, 0.4); - points.seatCb = points.hipCb.shift( - -90 - angle - 5, - measurements.hipsToUpperLeg * 0.67 - ); - points._tmp2 = points.crossSeam.shift(angle, 20); - points._tmp3 = utils.beamsIntersect( - points.crossSeam, - points._tmp2, - points.hipCb, - points.seatCb - ); - points.seatCp = points.seatCb.shiftFractionTowards(points._tmp3, 0.7); - points.crossSeamCp = points.crossSeam.shiftFractionTowards(points._tmp3, 0.7); - points.midFront = points.hipCb.shiftFractionTowards(points.seatCb, 0.6); - points.midFrontCpTop = points.hipCb.shiftFractionTowards(points.seatCb, 0.3); - points.midFrontCpBottom = points.hipCb.shiftFractionTowards( - points.seatCb, - 0.9 - ); - points.midBulge = points.midFront.shift(angle * -1, bulge); - points.bulgeCpTop = points.midFrontCpTop.shift(angle * -1, bulge); - points.bulgeCpBottom = points.midFrontCpBottom.shift(angle * -1, bulge); - points.midSide = points.hipSide.shiftFractionTowards(points.legSide, 0.5); - points.hipSideCpBottom = points.hipSide.shiftFractionTowards( - points.legSide, - 0.2 - ); - points.midSideCpTop = points.hipSide.shiftFractionTowards( - points.legSide, - 0.2 - ); - points.midSideCpBottom = points.hipSide.shiftFractionTowards( - points.legSide, - 0.7 - ); - points.legSideCpTop = points.hipSide.shiftFractionTowards( - points.legSide, - 0.8 - ); - points.midSideBulge = points.midSide.shift(angle * -1, bulge * -1); - points.midSideBulgeCpTop = points.midSideCpTop.shift(angle * -1, bulge * -1); - points.midSideBulgeCpBottom = points.midSideCpBottom.shift( - angle * -1, - bulge * -1 - ); + let angle = -12 + let bulge = measurements.hipsToUpperLeg * options.bulge + points.hipSide = new Point(0, 0) + points.hipCb = new Point(store.get('hipFront'), 0) + points.legSide = points.hipSide.shift(-90 - angle, measurements.hipsToUpperLeg) + points.legSideCp = points.legSide.shift(0, store.get('legFront')) + points.legInner = points.legSideCp.shift(-100, store.get('gusset') / 2) + points.crossSeam = points.legSideCp.shift(80, store.get('gusset') / 2) + points.legSideCp = points.legSide.shiftFractionTowards(points.legSideCp, 0.4) + points.seatCb = points.hipCb.shift(-90 - angle - 5, measurements.hipsToUpperLeg * 0.67) + points._tmp2 = points.crossSeam.shift(angle, 20) + points._tmp3 = utils.beamsIntersect(points.crossSeam, points._tmp2, points.hipCb, points.seatCb) + points.seatCp = points.seatCb.shiftFractionTowards(points._tmp3, 0.7) + points.crossSeamCp = points.crossSeam.shiftFractionTowards(points._tmp3, 0.7) + points.midFront = points.hipCb.shiftFractionTowards(points.seatCb, 0.6) + points.midFrontCpTop = points.hipCb.shiftFractionTowards(points.seatCb, 0.3) + points.midFrontCpBottom = points.hipCb.shiftFractionTowards(points.seatCb, 0.9) + points.midBulge = points.midFront.shift(angle * -1, bulge) + points.bulgeCpTop = points.midFrontCpTop.shift(angle * -1, bulge) + points.bulgeCpBottom = points.midFrontCpBottom.shift(angle * -1, bulge) + points.midSide = points.hipSide.shiftFractionTowards(points.legSide, 0.5) + points.hipSideCpBottom = points.hipSide.shiftFractionTowards(points.legSide, 0.2) + points.midSideCpTop = points.hipSide.shiftFractionTowards(points.legSide, 0.2) + points.midSideCpBottom = points.hipSide.shiftFractionTowards(points.legSide, 0.7) + points.legSideCpTop = points.hipSide.shiftFractionTowards(points.legSide, 0.8) + points.midSideBulge = points.midSide.shift(angle * -1, bulge * -1) + points.midSideBulgeCpTop = points.midSideCpTop.shift(angle * -1, bulge * -1) + points.midSideBulgeCpBottom = points.midSideCpBottom.shift(angle * -1, bulge * -1) // Now reduce the legs points.reducedLegInner = new Path() .move(points.legSide) .curve_(points.legSideCp, points.legInner) - .shiftFractionAlong(1 - options.legReduction); - points.reducedLegInnerCp = points.legInner.rotate(90, points.reducedLegInner); + .shiftFractionAlong(1 - options.legReduction) + points.reducedLegInnerCp = points.legInner.rotate(90, points.reducedLegInner) points.reducedCrossSeam = new Path() .move(points.crossSeam) .curve(points.crossSeamCp, points.seatCp, points.seatCb) - .shiftFractionAlong(options.legReduction * 2); + .shiftFractionAlong(options.legReduction * 2) // Lengthen legs if (options.legBonus > 0) { - let shift = measurements.hipsToUpperLeg * options.legBonus; - points.legSide = points.legSide.shift(-90, shift); - points.legSideCp = points.legSideCp.shift(-90, shift); - points.reducedLegInner = points.reducedLegInner(-90, shift); + let shift = measurements.hipsToUpperLeg * options.legBonus + points.legSide = points.legSide.shift(-90, shift) + points.legSideCp = points.legSideCp.shift(-90, shift) + points.reducedLegInner = points.reducedLegInner(-90, shift) } // Rise if (options.rise > 0) { - let shift = measurements.hipsToUpperLeg * options.rise; - points.hipSide = points.hipSide.shift(90, shift); - points.hipCb = points.hipCb.shift(0, shift); + let shift = measurements.hipsToUpperLeg * options.rise + points.hipSide = points.hipSide.shift(90, shift) + points.hipCb = points.hipCb.shift(0, shift) } // Back rise if (options.backRise > 0) { - let shift = measurements.hipsToUpperLeg * options.backRise; - points.hipSide = points.hipSide.shift(90, shift / 2); - points.hipCbCp = new Point(points.hipCb.x / 2, points.hipCb.y); + let shift = measurements.hipsToUpperLeg * options.backRise + points.hipSide = points.hipSide.shift(90, shift / 2) + points.hipCbCp = new Point(points.hipCb.x / 2, points.hipCb.y) } - console.log(points.hipSideCpBottom); + console.log(points.hipSideCpBottom) // Paths paths.saBase = new Path() // Use full crossSeam path @@ -115,24 +86,22 @@ export default function(part) { .split(points.reducedCrossSeam) // Now split it .pop() // Return the relevant part .curve(points.midFrontCpBottom, points.bulgeCpBottom, points.midBulge) // Continue from here - .curve(points.bulgeCpTop, points.midFrontCpTop, points.hipCb); - if (options.backRise > 0) paths.saBase.curve_(points.hipCbCp, points.hipSide); - else paths.saBase.line(points.hipSide); + .curve(points.bulgeCpTop, points.midFrontCpTop, points.hipCb) + if (options.backRise > 0) paths.saBase.curve_(points.hipCbCp, points.hipSide) + else paths.saBase.line(points.hipSide) paths.saBase .curve(points.midSideCpTop, points.midSideBulgeCpTop, points.midSideBulge) - .curve(points.midSideBulgeCpBottom, points.legSideCpTop, points.legSide); + .curve(points.midSideBulgeCpBottom, points.legSideCpTop, points.legSide) paths.saBase = new Path() .move(points.reducedLegInner) .line(points.reducedCrossSeam) - .join(paths.saBase); - paths.hemBase = new Path() - .move(points.legSide) - .curve_(points.legSideCp, points.reducedLegInner); + .join(paths.saBase) + paths.hemBase = new Path().move(points.legSide).curve_(points.legSideCp, points.reducedLegInner) - paths.saBase.render = false; - paths.hemBase.render = false; + paths.saBase.render = false + paths.hemBase.render = false - paths.seam = paths.saBase.join(paths.hemBase).attr("class", "fabric"); + paths.seam = paths.saBase.join(paths.hemBase).attr('class', 'fabric') /** Uncomment this to see the reduced crossSeam paths.xred = new Path() @@ -143,66 +112,66 @@ export default function(part) { // Complete? if (complete) { - points.logo = points.hipSide.shiftFractionTowards(points.seatCb, 0.3); - points.title = points.hipSide.shiftFractionTowards(points.seatCb, 0.7); - snippets.logo = new Snippet("logo", points.logo); - macro("title", { + points.logo = points.hipSide.shiftFractionTowards(points.seatCb, 0.3) + points.title = points.hipSide.shiftFractionTowards(points.seatCb, 0.7) + snippets.logo = new Snippet('logo', points.logo) + macro('title', { at: points.title, nr: 2, - title: "front" - }); + title: 'front' + }) if (sa) { paths.sa = paths.hemBase .offset(3 * sa) .join(paths.saBase.offset(sa)) .close() - .attr("class", "fabric sa"); + .attr('class', 'fabric sa') } } // Paperless? if (paperless) { - macro("vd", { + macro('vd', { from: points.legSide, to: points.hipSide, x: points.hipSide.x - sa - 15 - }); - macro("vd", { + }) + macro('vd', { from: points.reducedLegInner, to: points.hipSide, x: points.hipSide.x - sa - 30 - }); - macro("vd", { + }) + macro('vd', { from: points.reducedLegInner, to: points.reducedCrossSeam, x: points.reducedCrossSeam.x + sa + 15 - }); - macro("vd", { + }) + macro('vd', { from: points.reducedLegInner, to: points.hipCb, x: points.reducedCrossSeam.x + sa + 30 - }); - macro("hd", { + }) + macro('hd', { from: points.hipSide, to: points.hipCb, y: points.hipSide.y - sa - 15 - }); - macro("hd", { + }) + macro('hd', { from: points.hipSide, to: points.reducedCrossSeam, y: points.hipSide.y - sa - 30 - }); - macro("hd", { + }) + macro('hd', { from: points.legSide, to: points.reducedLegInner, y: points.reducedLegInner.y + 3 * sa + 15 - }); - macro("hd", { + }) + macro('hd', { from: points.legSide, to: points.reducedCrossSeam, y: points.reducedLegInner.y + 3 * sa + 30 - }); + }) } - return part; + return part } diff --git a/packages/shin/src/index.js b/packages/shin/src/index.js index 551ce426a66..fceb69babc5 100644 --- a/packages/shin/src/index.js +++ b/packages/shin/src/index.js @@ -1,17 +1,17 @@ -import freesewing from "@freesewing/core"; -import plugins from "@freesewing/plugin-bundle"; -import config from "../config"; +import freesewing from '@freesewing/core' +import plugins from '@freesewing/plugin-bundle' +import config from '../config' // Parts -import draftBack from "./back"; -import draftFront from "./front"; -import draftWaistband from "./waistband"; +import draftBack from './back' +import draftFront from './front' +import draftWaistband from './waistband' // Create new design -const Pattern = new freesewing.Design(config, plugins); +const Pattern = new freesewing.Design(config, plugins) // Attach draft methods to prototype -Pattern.prototype.draftBack = draftBack; -Pattern.prototype.draftFront = draftFront; -Pattern.prototype.draftWaistband = draftWaistband; +Pattern.prototype.draftBack = draftBack +Pattern.prototype.draftFront = draftFront +Pattern.prototype.draftWaistband = draftWaistband -export default Pattern; +export default Pattern diff --git a/packages/shin/src/waistband.js b/packages/shin/src/waistband.js index 10f47c7dd85..0822c36429b 100644 --- a/packages/shin/src/waistband.js +++ b/packages/shin/src/waistband.js @@ -11,17 +11,17 @@ export default function(part) { sa, options, utils - } = part.shorthand(); + } = part.shorthand() - let height = options.elasticWidth * 2; - points.topLeft = new Point(0, 0); - points.bottomLeft = new Point(0, height); - points.topMidLeft = new Point(height, 0); - points.bottomMidLeft = new Point(height, height); - points.topMidRight = new Point(height * 1.5, 0); - points.bottomMidRight = new Point(height * 1.5, height); - points.topRight = new Point(height * 2.5, 0); - points.bottomRight = new Point(height * 2.5, height); + let height = options.elasticWidth * 2 + points.topLeft = new Point(0, 0) + points.bottomLeft = new Point(0, height) + points.topMidLeft = new Point(height, 0) + points.bottomMidLeft = new Point(height, height) + points.topMidRight = new Point(height * 1.5, 0) + points.bottomMidRight = new Point(height * 1.5, height) + points.topRight = new Point(height * 2.5, 0) + points.bottomRight = new Point(height * 2.5, height) paths.seam = new Path() .move(points.topMidLeft) @@ -32,22 +32,22 @@ export default function(part) { .line(points.bottomRight) .line(points.topRight) .line(points.topMidRight) - .attr("class", "fabric"); + .attr('class', 'fabric') paths.hint = new Path() .move(points.topMidRight) .line(points.topMidLeft) .move(points.bottomMidLeft) .line(points.bottomMidRight) - .attr("class", "fabric dashed"); + .attr('class', 'fabric dashed') // Complete? if (complete) { - points.title = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5); - macro("title", { + points.title = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5) + macro('title', { at: points.title, nr: 3, - title: "waistband" - }); + title: 'waistband' + }) if (sa) { paths.sa = new Path() .move(points.topLeft) @@ -57,24 +57,24 @@ export default function(part) { .line(points.topLeft) .close() .offset(sa) - .attr("class", "fabric sa"); + .attr('class', 'fabric sa') } - macro("hd", { + macro('hd', { from: points.bottomLeft, to: points.bottomRight, y: points.bottomLeft.y - 10, - text: utils.units(store.get("hips") * 2) - }); + text: utils.units(store.get('hips') * 2) + }) } // Paperless? if (paperless) { - macro("vd", { + macro('vd', { from: points.bottomRight, to: points.topRight, x: points.topRight.x + sa + 15 - }); + }) } - return part; + return part } diff --git a/packages/simon/example/src/App.js b/packages/simon/example/src/App.js index e7936330e5d..115cdf683af 100644 --- a/packages/simon/example/src/App.js +++ b/packages/simon/example/src/App.js @@ -1,22 +1,15 @@ -import React from "react"; -import freesewing from "@freesewing/core"; -import Workbench from "@freesewing/components/Workbench"; -import "typeface-roboto-condensed"; -import "@freesewing/css-theme"; +import React from 'react' +import freesewing from '@freesewing/core' +import Workbench from '@freesewing/components/Workbench' +import 'typeface-roboto-condensed' +import '@freesewing/css-theme' -import Pattern from "pattern"; +import Pattern from 'pattern' const App = props => { - let instance = new Pattern(); - let config = instance.config; - return ( - - ); -}; + let instance = new Pattern() + let config = instance.config + return +} -export default App; +export default App diff --git a/packages/simon/example/src/index.js b/packages/simon/example/src/index.js index 7900787a4d2..9dd7ba788d4 100644 --- a/packages/simon/example/src/index.js +++ b/packages/simon/example/src/index.js @@ -1,11 +1,11 @@ -import React from "react"; -import ReactDOM from "react-dom"; -import App from "./App"; -import * as serviceWorker from "./serviceWorker"; +import React from 'react' +import ReactDOM from 'react-dom' +import App from './App' +import * as serviceWorker from './serviceWorker' -ReactDOM.render(, document.getElementById("root")); +ReactDOM.render(, document.getElementById('root')) // If you want your app to work offline and load faster, you can change // unregister() to register() below. Note this comes with some pitfalls. // Learn more about service workers: http://bit.ly/CRA-PWA -serviceWorker.unregister(); +serviceWorker.unregister() diff --git a/packages/simon/example/src/serviceWorker.js b/packages/simon/example/src/serviceWorker.js index 68fda5a0eb6..44e1b1b2f8c 100644 --- a/packages/simon/example/src/serviceWorker.js +++ b/packages/simon/example/src/serviceWorker.js @@ -9,46 +9,44 @@ // This link also includes instructions on opting out of this behavior. const isLocalhost = Boolean( - window.location.hostname === "localhost" || + window.location.hostname === 'localhost' || // [::1] is the IPv6 localhost address. - window.location.hostname === "[::1]" || + window.location.hostname === '[::1]' || // 127.0.0.1/8 is considered localhost for IPv4. - window.location.hostname.match( - /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ - ) -); + window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/) +) export function register(config) { - if (process.env.NODE_ENV === "production" && "serviceWorker" in navigator) { + if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) { // The URL constructor is available in all browsers that support SW. - const publicUrl = new URL(process.env.PUBLIC_URL, window.location); + const publicUrl = new URL(process.env.PUBLIC_URL, window.location) if (publicUrl.origin !== window.location.origin) { // Our service worker won't work if PUBLIC_URL is on a different origin // from what our page is served on. This might happen if a CDN is used to // serve assets; see https://github.com/facebook/create-react-app/issues/2374 - return; + return } - window.addEventListener("load", () => { - const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; + window.addEventListener('load', () => { + const swUrl = `${process.env.PUBLIC_URL}/service-worker.js` if (isLocalhost) { // This is running on localhost. Let's check if a service worker still exists or not. - checkValidServiceWorker(swUrl, config); + checkValidServiceWorker(swUrl, config) // Add some additional logging to localhost, pointing developers to the // service worker/PWA documentation. navigator.serviceWorker.ready.then(() => { console.log( - "This web app is being served cache-first by a service " + - "worker. To learn more, visit https://goo.gl/SC7cgQ" - ); - }); + 'This web app is being served cache-first by a service ' + + 'worker. To learn more, visit https://goo.gl/SC7cgQ' + ) + }) } else { // Is not local host. Just register service worker - registerValidSW(swUrl, config); + registerValidSW(swUrl, config) } - }); + }) } } @@ -57,38 +55,38 @@ function registerValidSW(swUrl, config) { .register(swUrl) .then(registration => { registration.onupdatefound = () => { - const installingWorker = registration.installing; + const installingWorker = registration.installing installingWorker.onstatechange = () => { - if (installingWorker.state === "installed") { + if (installingWorker.state === 'installed') { if (navigator.serviceWorker.controller) { // At this point, the old content will have been purged and // the fresh content will have been added to the cache. // It's the perfect time to display a "New content is // available; please refresh." message in your web app. - console.log("New content is available; please refresh."); + console.log('New content is available; please refresh.') // Execute callback if (config.onUpdate) { - config.onUpdate(registration); + config.onUpdate(registration) } } else { // At this point, everything has been precached. // It's the perfect time to display a // "Content is cached for offline use." message. - console.log("Content is cached for offline use."); + console.log('Content is cached for offline use.') // Execute callback if (config.onSuccess) { - config.onSuccess(registration); + config.onSuccess(registration) } } } - }; - }; + } + } }) .catch(error => { - console.error("Error during service worker registration:", error); - }); + console.error('Error during service worker registration:', error) + }) } function checkValidServiceWorker(swUrl, config) { @@ -98,30 +96,28 @@ function checkValidServiceWorker(swUrl, config) { // Ensure service worker exists, and that we really are getting a JS file. if ( response.status === 404 || - response.headers.get("content-type").indexOf("javascript") === -1 + response.headers.get('content-type').indexOf('javascript') === -1 ) { // No service worker found. Probably a different app. Reload the page. navigator.serviceWorker.ready.then(registration => { registration.unregister().then(() => { - window.location.reload(); - }); - }); + window.location.reload() + }) + }) } else { // Service worker found. Proceed as normal. - registerValidSW(swUrl, config); + registerValidSW(swUrl, config) } }) .catch(() => { - console.log( - "No internet connection found. App is running in offline mode." - ); - }); + console.log('No internet connection found. App is running in offline mode.') + }) } export function unregister() { - if ("serviceWorker" in navigator) { + if ('serviceWorker' in navigator) { navigator.serviceWorker.ready.then(registration => { - registration.unregister(); - }); + registration.unregister() + }) } } diff --git a/packages/simon/src/back.js b/packages/simon/src/back.js index 743c3dd55fa..1b1d72b44b5 100644 --- a/packages/simon/src/back.js +++ b/packages/simon/src/back.js @@ -1,7 +1,7 @@ -import { calculateReduction } from "./shared"; +import { calculateReduction } from './shared' export default part => { - part.paths = {}; // Removes paperless dimensions from brian + part.paths = {} // Removes paperless dimensions from brian let { store, measurements, @@ -17,60 +17,50 @@ export default part => { paperless, macro, options - } = part.shorthand(); + } = part.shorthand() // Populare store with data we need - calculateReduction(part); + calculateReduction(part) store.set( - "backArmholeLength", + 'backArmholeLength', new Path() .move(points.armhole) .curve(points.armholeCp2, points.armholeHollowCp1, points.armholeHollow) - .curve( - points.armholeHollowCp2, - points.armholePitchCp1, - points.armholePitch - ) + .curve(points.armholeHollowCp2, points.armholePitchCp1, points.armholePitch) .curve(points.armholePitchCp2, points.shoulderCp1, points.shoulder) .length() - ); + ) // Hip shaping - points.hips = points.hips.shift(180, store.get("hipsReduction") / 4); - points.hem = points.hem.shift(180, store.get("hipsReduction") / 4); + points.hips = points.hips.shift(180, store.get('hipsReduction') / 4) + points.hem = points.hem.shift(180, store.get('hipsReduction') / 4) // Waist shaping - let reduce = store.get("waistReduction"); + let reduce = store.get('waistReduction') if (reduce / 4 > options.minimalDartShaping) { // Add darts in the back - points.waist = points.waist.shift(180, reduce / 8); - points.dartCenter = points.cbWaist.shiftFractionTowards(points.waist, 0.6); - points.dartTop = points.dartCenter.shift( - 90, - points.armhole.dy(points.waist) * 0.75 - ); - points.dartBottom = points.dartCenter.shift( - -90, - measurements.naturalWaistToHip * 0.75 - ); - points.dartCenterIn = points.dartCenter.shift(180, reduce / 8); - points.dartCenterOut = points.dartCenter.shift(0, reduce / 8); + points.waist = points.waist.shift(180, reduce / 8) + points.dartCenter = points.cbWaist.shiftFractionTowards(points.waist, 0.6) + points.dartTop = points.dartCenter.shift(90, points.armhole.dy(points.waist) * 0.75) + points.dartBottom = points.dartCenter.shift(-90, measurements.naturalWaistToHip * 0.75) + points.dartCenterIn = points.dartCenter.shift(180, reduce / 8) + points.dartCenterOut = points.dartCenter.shift(0, reduce / 8) points.dartCenterInCp1 = points.dartCenterIn.shift( 90, points.dartTop.dy(points.dartCenter) * 0.2 - ); + ) points.dartCenterInCp2 = points.dartCenterIn.shift( 90, points.dartBottom.dy(points.dartCenter) * 0.2 - ); + ) points.dartCenterOutCp1 = points.dartCenterOut.shift( 90, points.dartBottom.dy(points.dartCenter) * 0.2 - ); + ) points.dartCenterOutCp2 = points.dartCenterOut.shift( 90, points.dartTop.dy(points.dartCenter) * 0.2 - ); + ) paths.dart = new Path() .move(points.dartTop) ._curve(points.dartCenterInCp1, points.dartCenterIn) @@ -78,35 +68,28 @@ export default part => { ._curve(points.dartCenterOutCp1, points.dartCenterOut) .curve_(points.dartCenterOutCp2, points.dartTop) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') } else { // No darts in the back - points.waist = points.waist.shift(180, reduce / 4); + points.waist = points.waist.shift(180, reduce / 4) } - points.waistCp1 = points.waist.shift( - -90, - measurements.naturalWaistToHip * 0.5 - ); - points.waistCp2 = points.waist.shift(90, points.armhole.dy(points.waist) / 2); - points.hipsCp2 = points.hips.shift(90, points.waist.dy(points.hips) / 4); + points.waistCp1 = points.waist.shift(-90, measurements.naturalWaistToHip * 0.5) + points.waistCp2 = points.waist.shift(90, points.armhole.dy(points.waist) / 2) + points.hipsCp2 = points.hips.shift(90, points.waist.dy(points.hips) / 4) // Yoke dart paths.armhole = new Path() .move(points.armhole) .curve(points.armholeCp2, points.armholeHollowCp1, points.armholeHollow) - .curve( - points.armholeHollowCp2, - points.armholePitchCp1, - points.armholePitch - ); - paths.armhole.render = false; + .curve(points.armholeHollowCp2, points.armholePitchCp1, points.armholePitch) + paths.armhole.render = false if (options.yokeDart > 0) { points.tmp1 = points.armholePitch.shift( -90, points.armholePitch.dy(points.armhole) * options.yokeDart - ); - points.tmp2 = points.tmp1.shift(180, 50); - points.tmp3 = points.tmp1.shift(0, 50); + ) + points.tmp2 = points.tmp1.shift(180, 50) + points.tmp3 = points.tmp1.shift(0, 50) points.yokeDartEdge = utils.lineIntersectsCurve( points.tmp2, points.tmp3, @@ -114,69 +97,59 @@ export default part => { points.armholePitchCp1, points.armholeHollowCp2, points.armholeHollow - ); - points.yokeDartTip = points.armholePitch.shift( - 180, - points.armholePitch.x * 0.4 - ); - points.yokeDartTipCp1 = points.armholePitch.shiftFractionTowards( - points.yokeDartTip, - 0.4 - ); - paths.armhole = paths.armhole.split(points.yokeDartEdge)[0]; - paths.armhole._curve(points.yokeDartTipCp1, points.yokeDartTip); + ) + points.yokeDartTip = points.armholePitch.shift(180, points.armholePitch.x * 0.4) + points.yokeDartTipCp1 = points.armholePitch.shiftFractionTowards(points.yokeDartTip, 0.4) + paths.armhole = paths.armhole.split(points.yokeDartEdge)[0] + paths.armhole._curve(points.yokeDartTipCp1, points.yokeDartTip) // Adapt armhole length to accomodate dart store.set( - "backArmholeLength", - store.get("backArmholeLength") - - points.yokeDartEdge.dist(points.armholePitch) - ); + 'backArmholeLength', + store.get('backArmholeLength') - points.yokeDartEdge.dist(points.armholePitch) + ) } // Cut off at yoke - points.cbYoke = new Point(0, points.armholePitch.y); + points.cbYoke = new Point(0, points.armholePitch.y) // Draft hem switch (options.hemStyle) { - case "baseball": - points.bballStart = points.cbHem.shiftFractionTowards(points.hem, 0.5); - points.bballEnd = points.hem.shiftFractionTowards( - points.hips, - options.hemCurve - ); - points.bballCp1 = points.bballStart.shiftFractionTowards(points.hem, 0.5); - points.bballCp2 = new Point(points.bballCp1.x, points.bballEnd.y); + case 'baseball': + points.bballStart = points.cbHem.shiftFractionTowards(points.hem, 0.5) + points.bballEnd = points.hem.shiftFractionTowards(points.hips, options.hemCurve) + points.bballCp1 = points.bballStart.shiftFractionTowards(points.hem, 0.5) + points.bballCp2 = new Point(points.bballCp1.x, points.bballEnd.y) paths.saBase = new Path() .move(points.bballEnd) .line(points.hips) .curve(points.hipsCp2, points.waistCp1, points.waist) .curve_(points.waistCp2, points.armhole) .join(paths.armhole) - .line(points.cbYoke); + .line(points.cbYoke) paths.hemBase = new Path() .move(points.cbHem) .line(points.bballStart) - .curve(points.bballCp1, points.bballCp2, points.bballEnd); - break; - case "slashed": - macro("round", { + .curve(points.bballCp1, points.bballCp2, points.bballEnd) + break + case 'slashed': + macro('round', { from: points.hips, to: points.cbHem, via: points.hem, radius: points.hips.dist(points.hem) * options.hemCurve, - prefix: "slash" - }); + prefix: 'slash' + }) paths.saBase = new Path() .move(points.hips) .curve(points.hipsCp2, points.waistCp1, points.waist) .curve_(points.waistCp2, points.armhole) .join(paths.armhole) - .line(points.cbYoke); + .line(points.cbYoke) paths.hemBase = new Path() .move(points.cbHem) .line(points.slashEnd) - .curve(points.slashCp2, points.slashCp1, points.slashStart); - break; + .curve(points.slashCp2, points.slashCp1, points.slashStart) + break default: paths.saBase = new Path() .move(points.hem) @@ -184,34 +157,34 @@ export default part => { .curve(points.hipsCp2, points.waistCp1, points.waist) .curve_(points.waistCp2, points.armhole) .join(paths.armhole) - .line(points.cbYoke); - paths.hemBase = new Path().move(points.cbHem).line(points.hem); + .line(points.cbYoke) + paths.hemBase = new Path().move(points.cbHem).line(points.hem) } // Paths - paths.saBase.render = false; - paths.hemBase.render = false; + paths.saBase.render = false + paths.hemBase.render = false paths.seam = paths.hemBase .join(paths.saBase) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') // Complete pattern? if (complete) { - delete snippets.armholePitchNotch; - macro("cutonfold", { + delete snippets.armholePitchNotch + macro('cutonfold', { from: points.cbYoke, to: points.cbHem, grainline: true - }); - points.title = new Point(points.armhole.x / 4, points.armhole.y); - macro("title", { at: points.title, nr: 3, title: "back" }); - points.logo = points.title.shift(-90, 70); - snippets.logo = new Snippet("logo", points.logo); + }) + points.title = new Point(points.armhole.x / 4, points.armhole.y) + macro('title', { at: points.title, nr: 3, title: 'back' }) + points.logo = points.title.shift(-90, 70) + snippets.logo = new Snippet('logo', points.logo) if (sa) { - paths.sa = paths.saBase.offset(sa).attr("class", "fabric sa"); - paths.hemSa = paths.hemBase.offset(sa * 3).attr("class", "fabric sa"); + paths.sa = paths.saBase.offset(sa).attr('class', 'fabric sa') + paths.hemSa = paths.hemBase.offset(sa * 3).attr('class', 'fabric sa') paths.saConnect = new Path() .move(points.cbHem) .line(paths.hemSa.start()) @@ -219,131 +192,131 @@ export default part => { .line(paths.sa.start()) .move(paths.sa.end()) .line(points.cbYoke) - .attr("class", "fabric sa"); - macro("banner", { - path: "hemSa", - text: ["hem", ": 3x", "seamAllowance"] - }); + .attr('class', 'fabric sa') + macro('banner', { + path: 'hemSa', + text: ['hem', ': 3x', 'seamAllowance'] + }) } } // Paperless? if (paperless) { if (reduce / 4 > options.minimalDartShaping) { - macro("vd", { + macro('vd', { from: points.dartBottom, to: points.dartCenterIn, x: points.dartCenterIn.x - 15 - }); - macro("vd", { + }) + macro('vd', { from: points.dartCenterIn, to: points.dartTop, x: points.dartCenterIn.x - 15 - }); - macro("hd", { + }) + macro('hd', { from: points.dartCenterIn, to: points.dartCenterOut, y: points.dartBottom.y + 15 - }); - macro("hd", { + }) + macro('hd', { from: points.dartCenterOut, to: points.waist - }); - macro("hd", { + }) + macro('hd', { from: points.cbWaist, to: points.dartCenterIn - }); + }) } else { - macro("hd", { + macro('hd', { from: points.cbWaist, to: points.waist - }); + }) } - let bottomRight; - if (typeof points.slashEnd !== "undefined") { - macro("hd", { + let bottomRight + if (typeof points.slashEnd !== 'undefined') { + macro('hd', { from: points.cbHem, to: points.slashEnd, y: points.cbHem.y + 15 + 3 * sa - }); - macro("vd", { + }) + macro('vd', { from: points.slashEnd, to: points.slashStart, x: points.slashStart.x + 15 + 3 * sa - }); - bottomRight = points.slashEnd; - } else if (typeof points.bballStart !== "undefined") { - macro("hd", { + }) + bottomRight = points.slashEnd + } else if (typeof points.bballStart !== 'undefined') { + macro('hd', { from: points.cbHem, to: points.bballStart, y: points.cbHem.y + 15 + 3 * sa - }); - macro("vd", { + }) + macro('vd', { from: points.bballStart, to: points.bballEnd, x: points.hips.x + 15 + sa - }); - bottomRight = points.bballStart; - } else bottomRight = points.hem; - macro("hd", { + }) + bottomRight = points.bballStart + } else bottomRight = points.hem + macro('hd', { from: points.cbHem, to: points.hips, y: points.cbHem.y + 30 + 3 * sa - }); - macro("vd", { + }) + macro('vd', { from: bottomRight, to: points.hips, x: points.hips.x + 30 + sa - }); - macro("vd", { + }) + macro('vd', { from: bottomRight, to: points.waist, x: points.hips.x + 45 + sa - }); - macro("vd", { + }) + macro('vd', { from: bottomRight, to: points.armhole, x: points.hips.x + 60 + sa - }); + }) if (options.yokeDart > 0) { - macro("vd", { + macro('vd', { from: points.armhole, to: points.yokeDartEdge, x: points.armhole.x + 15 + sa - }); - macro("vd", { + }) + macro('vd', { from: points.armhole, to: points.yokeDartTip, x: points.armhole.x + 30 + sa - }); - macro("hd", { + }) + macro('hd', { from: points.cbYoke, to: points.yokeDartTip, y: points.cbYoke.y - 15 - sa - }); - macro("hd", { + }) + macro('hd', { from: points.cbYoke, to: points.yokeDartEdge, y: points.cbYoke.y - 30 - sa - }); + }) } else { - macro("vd", { + macro('vd', { from: points.armhole, to: points.armholePitch, x: points.armhole.x + 15 + sa - }); - macro("hd", { + }) + macro('hd', { from: points.cbYoke, to: points.armholePitch, y: points.cbYoke.y - 15 - sa - }); + }) } - macro("vd", { + macro('vd', { from: points.cbHem, to: points.cbYoke, x: points.cbHem.x - 15 - }); + }) } - return part; -}; + return part +} diff --git a/packages/simon/src/buttonholeplacket.js b/packages/simon/src/buttonholeplacket.js index 473292e47d7..501765187cd 100644 --- a/packages/simon/src/buttonholeplacket.js +++ b/packages/simon/src/buttonholeplacket.js @@ -1,4 +1,4 @@ -import { addButtonHoles } from "./shared"; +import { addButtonHoles } from './shared' export default part => { let { @@ -14,21 +14,18 @@ export default part => { paperless, macro, options - } = part.shorthand(); + } = part.shorthand() - if ( - !options.seperateButtonholePlacket || - options.buttonholePlacketStyle !== "classic" - ) { - part.paths = {}; - part.snippets = {}; - part.points = {}; - return part; + if (!options.seperateButtonholePlacket || options.buttonholePlacketStyle !== 'classic') { + part.paths = {} + part.snippets = {} + part.points = {} + return part } - for (let id of Object.keys(part.paths)) delete part.paths[id]; - let width = options.buttonholePlacketWidth; - let fold = options.buttonholePlacketFoldWidth; + for (let id of Object.keys(part.paths)) delete part.paths[id] + let width = options.buttonholePlacketWidth + let fold = options.buttonholePlacketFoldWidth points.topInnerEdge = utils.lineIntersectsCurve( new Point(points.cfNeck.x + fold * 2, points.cfNeck.y + 20), @@ -37,65 +34,38 @@ export default part => { points.cfNeckCp1, points.neckCp2Front, points.neck - ); - points.bottomInnerEdge = new Point(points.topInnerEdge.x, points.cfHem.y); + ) + points.bottomInnerEdge = new Point(points.topInnerEdge.x, points.cfHem.y) - points.placketCfNeck = points.cfNeck.shift(180, fold * 2); - points.placketTopInnerEdgeFold = points.placketCfNeck.shift(0, width / 2); - points.placketTopInnerEdgeOver = points.placketCfNeck.shift( - 0, - width / 2 - fold - ); - points.placketTopInnerEdgeUnder = points.placketCfNeck.shift( - 0, - width / 2 + fold - ); - points.placketTopOuterEdgeFold = points.placketCfNeck.shift(180, width / 2); - points.placketTopOuterEdgeOver = points.placketCfNeck.shift( - 180, - width / 2 - fold - ); - points.placketTopOuterEdgeUnder = points.placketCfNeck.shift( - 180, - width / 2 + fold - ); - points.placketCfHem = points.cfHem.shift(180, fold * 2); - points.placketBottomInnerEdgeFold = points.placketCfHem.shift(0, width / 2); - points.placketBottomInnerEdgeOver = points.placketCfHem.shift( - 0, - width / 2 - fold - ); - points.placketBottomInnerEdgeUnder = points.placketCfHem.shift( - 0, - width / 2 + fold - ); - points.placketBottomOuterEdgeFold = points.placketCfHem.shift(180, width / 2); - points.placketBottomOuterEdgeOver = points.placketCfHem.shift( - 180, - width / 2 - fold - ); - points.placketBottomOuterEdgeUnder = points.placketCfHem.shift( - 180, - width / 2 + fold - ); - points.placketTopEdge = points.placketTopOuterEdgeFold.shift(180, width); - points.placketBottomEdge = points.placketBottomOuterEdgeFold.shift( - 180, - width - ); + points.placketCfNeck = points.cfNeck.shift(180, fold * 2) + points.placketTopInnerEdgeFold = points.placketCfNeck.shift(0, width / 2) + points.placketTopInnerEdgeOver = points.placketCfNeck.shift(0, width / 2 - fold) + points.placketTopInnerEdgeUnder = points.placketCfNeck.shift(0, width / 2 + fold) + points.placketTopOuterEdgeFold = points.placketCfNeck.shift(180, width / 2) + points.placketTopOuterEdgeOver = points.placketCfNeck.shift(180, width / 2 - fold) + points.placketTopOuterEdgeUnder = points.placketCfNeck.shift(180, width / 2 + fold) + points.placketCfHem = points.cfHem.shift(180, fold * 2) + points.placketBottomInnerEdgeFold = points.placketCfHem.shift(0, width / 2) + points.placketBottomInnerEdgeOver = points.placketCfHem.shift(0, width / 2 - fold) + points.placketBottomInnerEdgeUnder = points.placketCfHem.shift(0, width / 2 + fold) + points.placketBottomOuterEdgeFold = points.placketCfHem.shift(180, width / 2) + points.placketBottomOuterEdgeOver = points.placketCfHem.shift(180, width / 2 - fold) + points.placketBottomOuterEdgeUnder = points.placketCfHem.shift(180, width / 2 + fold) + points.placketTopEdge = points.placketTopOuterEdgeFold.shift(180, width) + points.placketBottomEdge = points.placketBottomOuterEdgeFold.shift(180, width) paths.saBase = new Path() .move(points.placketTopEdge) .line(points.cfNeck) .curve(points.cfNeckCp1, points.neckCp2Front, points.neck) .split(points.topInnerEdge)[0] - .line(points.bottomInnerEdge); + .line(points.bottomInnerEdge) paths.seam = paths.saBase .clone() .line(points.placketBottomEdge) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') // Complete pattern? if (complete) { @@ -103,117 +73,107 @@ export default part => { paths.frontCenter = new Path() .move(points.placketCfNeck) .line(points.placketCfHem) - .attr("class", "help"); + .attr('class', 'help') paths.placketInnerEdgeFold = new Path() .move(points.placketTopInnerEdgeFold) .line(points.placketBottomInnerEdgeFold) - .attr("class", "dotted"); + .attr('class', 'dotted') paths.placketInnerEdgeOver = new Path() .move(points.placketTopInnerEdgeOver) .line(points.placketBottomInnerEdgeOver) - .attr("class", "dotted"); + .attr('class', 'dotted') paths.placketOuterEdgeFold = new Path() .move(points.placketTopOuterEdgeFold) .line(points.placketBottomOuterEdgeFold) - .attr("class", "dotted"); + .attr('class', 'dotted') paths.placketOuterEdgeOver = new Path() .move(points.placketTopOuterEdgeOver) .line(points.placketBottomOuterEdgeOver) - .attr("class", "dotted"); + .attr('class', 'dotted') paths.placketOuterEdgeUnder = new Path() .move(points.placketTopOuterEdgeUnder) .line(points.placketBottomOuterEdgeUnder) - .attr("class", "dotted"); + .attr('class', 'dotted') // Notches - snippets["cfArmhole-notch"].anchor.x = points.cfArmhole.x - fold * 2; - snippets["cfWaist-notch"].anchor.x = points.cfArmhole.x - fold * 2; - snippets["cfHips-notch"].anchor.x = points.cfArmhole.x - fold * 2; + snippets['cfArmhole-notch'].anchor.x = points.cfArmhole.x - fold * 2 + snippets['cfWaist-notch'].anchor.x = points.cfArmhole.x - fold * 2 + snippets['cfHips-notch'].anchor.x = points.cfArmhole.x - fold * 2 // Buttons - addButtonHoles(part, "placketCfNeck"); + addButtonHoles(part, 'placketCfNeck') // Grainline - points.grainlineFrom = points.placketBottomEdge.shift(0, width / 2); - points.grainlineTo = points.placketTopEdge.shift(0, width / 2); - macro("grainline", { + points.grainlineFrom = points.placketBottomEdge.shift(0, width / 2) + points.grainlineTo = points.placketTopEdge.shift(0, width / 2) + macro('grainline', { from: points.grainlineFrom, to: points.grainlineTo - }); + }) // Title - points.title = new Point(points.placketCfNeck.x, points.cfArmhole.y); - macro("title", { + points.title = new Point(points.placketCfNeck.x, points.cfArmhole.y) + macro('title', { at: points.title, - nr: "2b", - title: "buttonholePlacket", + nr: '2b', + title: 'buttonholePlacket', scale: 0.75, rotation: -90 - }); + }) // Logo - points.logo = points.title.shift(-90, 120); - snippets.logo = new Snippet("logo", points.logo) - .attr("data-scale", 0.5) - .attr("data-rotate", -90); + points.logo = points.title.shift(-90, 120) + snippets.logo = new Snippet('logo', points.logo) + .attr('data-scale', 0.5) + .attr('data-rotate', -90) if (sa) { - paths.sa = paths.saBase.offset(sa * -1); + paths.sa = paths.saBase.offset(sa * -1) paths.sa - .line( - new Point( - points.bottomInnerEdge.x + sa, - points.bottomInnerEdge.y + 3 * sa - ) - ) - .line( - new Point( - points.placketBottomEdge.x, - points.placketBottomEdge.y + 3 * sa - ) - ) + .line(new Point(points.bottomInnerEdge.x + sa, points.bottomInnerEdge.y + 3 * sa)) + .line(new Point(points.placketBottomEdge.x, points.placketBottomEdge.y + 3 * sa)) .line(points.placketBottomEdge) .move(points.placketTopEdge) .line(paths.sa.start()) - .attr("class", "fabric sa"); + .attr('class', 'fabric sa') } } // Paperless? if (paperless) { - let offset = 0; + let offset = 0 for (let pid of [ - "placketBottomOuterEdgeUnder", - "placketBottomOuterEdgeFold", - "placketBottomOuterEdgeOver", - "placketCfHem", - "placketBottomInnerEdgeOver", - "placketBottomInnerEdgeFold", - "placketBottomInnerEdgeUnder" + 'placketBottomOuterEdgeUnder', + 'placketBottomOuterEdgeFold', + 'placketBottomOuterEdgeOver', + 'placketCfHem', + 'placketBottomInnerEdgeOver', + 'placketBottomInnerEdgeFold', + 'placketBottomInnerEdgeUnder' ]) { - offset += 15; - macro("hd", { + offset += 15 + macro('hd', { from: points.placketBottomEdge, to: points[pid], y: points.placketBottomEdge.y + offset + 3 * sa - }); + }) } - points.button0 = points.placketTopEdge; - let j; + points.button0 = points.placketTopEdge + let j for (let i = 0; i < options.buttons; i++) { - j = i + 1; - macro("vd", { - from: points["button" + j], - to: points["button" + i], + j = i + 1 + macro('vd', { + from: points['button' + j], + to: points['button' + i], x: points.placketTopEdge.x - 15 - }); + }) } - macro("vd", { + macro('vd', { from: points.placketBottomEdge, to: points.placketTopEdge, x: points.placketTopEdge.x - 30 - }); + }) } - return part; -}; + return part +} diff --git a/packages/simon/src/buttonplacket.js b/packages/simon/src/buttonplacket.js index c0a81a693fd..f2b0f442b59 100644 --- a/packages/simon/src/buttonplacket.js +++ b/packages/simon/src/buttonplacket.js @@ -1,4 +1,4 @@ -import { addButtons } from "./shared"; +import { addButtons } from './shared' export default part => { let { @@ -14,23 +14,20 @@ export default part => { paperless, macro, options - } = part.shorthand(); + } = part.shorthand() - if ( - !options.seperateButtonPlacket || - options.buttonPlacketStyle !== "classic" - ) { - part.paths = {}; - part.snippets = {}; - part.points = {}; - return part; + if (!options.seperateButtonPlacket || options.buttonPlacketStyle !== 'classic') { + part.paths = {} + part.snippets = {} + part.points = {} + return part } for (let id of Object.keys(part.paths)) { - if (id !== "seam") delete part.paths[id]; + if (id !== 'seam') delete part.paths[id] } - macro("flip"); - let width = options.buttonPlacketWidth; + macro('flip') + let width = options.buttonPlacketWidth points.placketTopIn = utils.lineIntersectsCurve( new Point(width / -2, points.cfNeck.y + 20), new Point(width / -2, points.cfNeck.y - 20), @@ -38,24 +35,24 @@ export default part => { points.cfNeckCp1, points.neckCp2Front, points.neck - ); - points.placketTopOut = points.cfNeck.shift(0, width / 2); - points.placketTopEdge = points.cfNeck.shift(0, width * 1.5); - points.placketBottomIn = points.cfHem.shift(180, width / 2); - points.placketBottomOut = points.cfHem.shift(0, width / 2); - points.placketBottomEdge = points.cfHem.shift(0, width * 1.5); + ) + points.placketTopOut = points.cfNeck.shift(0, width / 2) + points.placketTopEdge = points.cfNeck.shift(0, width * 1.5) + points.placketBottomIn = points.cfHem.shift(180, width / 2) + points.placketBottomOut = points.cfHem.shift(0, width / 2) + points.placketBottomEdge = points.cfHem.shift(0, width * 1.5) paths.saBase = new Path() .move(points.placketBottomIn) .line(points.placketTopIn) .join(paths.seam.split(points.placketTopIn)[1]) .line(points.placketTopEdge) - .line(points.placketBottomEdge); + .line(points.placketBottomEdge) paths.seam = paths.saBase .clone() .close() - .attr("class", "fabric"); + .attr('class', 'fabric') // Complete pattern? if (complete) { @@ -63,87 +60,77 @@ export default part => { paths.placketOuterFold = new Path() .move(points.placketTopOut) .line(points.placketBottomOut) - .attr("class", "dotted"); - macro("sprinkle", { - snippet: "notch", - on: ["placketTopOut", "placketBottomOut"] - }); + .attr('class', 'dotted') + macro('sprinkle', { + snippet: 'notch', + on: ['placketTopOut', 'placketBottomOut'] + }) // Buttons - addButtons(part); + addButtons(part) // Grainline - points.grainlineFrom = points.placketBottomEdge.shift(180, width / 2); - points.grainlineTo = points.placketTopEdge.shift(180, width / 2); - macro("grainline", { + points.grainlineFrom = points.placketBottomEdge.shift(180, width / 2) + points.grainlineTo = points.placketTopEdge.shift(180, width / 2) + macro('grainline', { from: points.grainlineFrom, to: points.grainlineTo - }); + }) // Title - points.title = new Point(points.placketTopOut.x, points.cfArmhole.y); - macro("title", { + points.title = new Point(points.placketTopOut.x, points.cfArmhole.y) + macro('title', { at: points.title, - nr: "1b", - title: "buttonPlacket", + nr: '1b', + title: 'buttonPlacket', scale: 0.75, rotation: -90 - }); + }) // Logo - points.logo = points.title.shift(-90, 120); - snippets.logo = new Snippet("logo", points.logo) - .attr("data-scale", 0.5) - .attr("data-rotate", -90); + points.logo = points.title.shift(-90, 120) + snippets.logo = new Snippet('logo', points.logo) + .attr('data-scale', 0.5) + .attr('data-rotate', -90) if (sa) { paths.sa = paths.saBase .offset(sa * -1) - .line( - new Point( - points.placketBottomEdge.x + sa, - points.placketBottomEdge.y + 3 * sa - ) - ) - .line( - new Point( - points.placketBottomIn.x - sa, - points.placketBottomIn.y + 3 * sa - ) - ) + .line(new Point(points.placketBottomEdge.x + sa, points.placketBottomEdge.y + 3 * sa)) + .line(new Point(points.placketBottomIn.x - sa, points.placketBottomIn.y + 3 * sa)) .close() - .attr("class", "fabric sa"); + .attr('class', 'fabric sa') } } // Paperless? if (paperless) { - macro("hd", { + macro('hd', { from: points.placketTopIn, to: points.placketTopOut, y: points.placketTopIn.y - 15 - sa - }); - macro("hd", { + }) + macro('hd', { from: points.placketTopIn, to: points.placketTopEdge, y: points.placketTopIn.y - 30 - sa - }); - macro("vd", { + }) + macro('vd', { from: points.placketBottomEdge, to: points.placketTopEdge, x: points.placketTopEdge.x + 15 + sa - }); - points.button0 = points.placketTopEdge; - let j; + }) + points.button0 = points.placketTopEdge + let j for (let i = 0; i < options.buttons; i++) { - j = i + 1; - macro("vd", { - from: points["button" + j], - to: points["button" + i], + j = i + 1 + macro('vd', { + from: points['button' + j], + to: points['button' + i], x: points.placketTopIn.x - 15 - sa - }); + }) } } - return part; -}; + return part +} diff --git a/packages/simon/src/collar.js b/packages/simon/src/collar.js index 0ef18669ed8..86184165fb3 100644 --- a/packages/simon/src/collar.js +++ b/packages/simon/src/collar.js @@ -11,67 +11,52 @@ export default part => { paperless, macro, options - } = part.shorthand(); + } = part.shorthand() const draft = function(tweak = 1) { let length = - measurements.neckCircumference * - (1 + options.collarEase - options.collarGap) * - tweak; - let width = options.collarStandWidth * (1 + options.collarRoll); + measurements.neckCircumference * (1 + options.collarEase - options.collarGap) * tweak + let width = options.collarStandWidth * (1 + options.collarRoll) // Draft right side - points.topMid = new Point(0, 0); - points.bottomMid = new Point(0, width); - points.bottomMidCp1 = points.bottomMid.shift(0, length * 0.35); - points.rightBottomEdge = new Point( - length / 2, - width + length * options.collarBend - ); - points.rightTopHinge = points.topMid.shift(0, length * 0.25); - points.rightTopEdgeDirection = points.rightTopHinge.shift( - options.collarFlare, - 10 - ); - points.rightBottomEdgeDirection = points.rightBottomEdge.shift( - options.collarAngle, - 10 - ); + points.topMid = new Point(0, 0) + points.bottomMid = new Point(0, width) + points.bottomMidCp1 = points.bottomMid.shift(0, length * 0.35) + points.rightBottomEdge = new Point(length / 2, width + length * options.collarBend) + points.rightTopHinge = points.topMid.shift(0, length * 0.25) + points.rightTopEdgeDirection = points.rightTopHinge.shift(options.collarFlare, 10) + points.rightBottomEdgeDirection = points.rightBottomEdge.shift(options.collarAngle, 10) points.rightTopEdge = utils.beamsIntersect( points.rightTopHinge, points.rightTopEdgeDirection, points.rightBottomEdge, points.rightBottomEdgeDirection - ); - points.rightTopHingeCp1 = points.rightTopHinge.shift(0, length * 0.1); + ) + points.rightTopHingeCp1 = points.rightTopHinge.shift(0, length * 0.1) // Draft left side - points.leftTopHinge = points.rightTopHinge.flipX(); - points.bottomMidCp2 = points.bottomMidCp1.flipX(); - points.leftTopHingeCp2 = points.rightTopHingeCp1.flipX(); - points.leftTopEdge = points.rightTopEdge.flipX(); - points.leftBottomEdge = points.rightBottomEdge.flipX(); + points.leftTopHinge = points.rightTopHinge.flipX() + points.bottomMidCp2 = points.bottomMidCp1.flipX() + points.leftTopHingeCp2 = points.rightTopHingeCp1.flipX() + points.leftTopEdge = points.rightTopEdge.flipX() + points.leftBottomEdge = points.rightBottomEdge.flipX() let len = new Path() .move(points.leftBottomEdge) ._curve(points.bottomMidCp2, points.bottomMid) - .length(); + .length() - return ( - len * 2 - - measurements.neckCircumference * - (1 + options.collarEase - options.collarGap) - ); - }; + return len * 2 - measurements.neckCircumference * (1 + options.collarEase - options.collarGap) + } - let delta, tweak, run; - tweak = 1; - run = 1; + let delta, tweak, run + tweak = 1 + run = 1 do { - delta = draft(tweak); - tweak = tweak * (1 - delta / 1000); - run++; - } while (Math.abs(delta) > 1 && run < 20); + delta = draft(tweak) + tweak = tweak * (1 - delta / 1000) + run++ + } while (Math.abs(delta) > 1 && run < 20) paths.seam = new Path() .move(points.bottomMid) @@ -84,117 +69,109 @@ export default part => { .line(points.leftBottomEdge) ._curve(points.bottomMidCp2, points.bottomMid) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') // Complete pattern? if (complete) { // Draw undercollar line - let uc = points.topMid.dist(points.bottomMid) * 0.05; - points.ucTopMid = points.topMid.shift(-90, uc); - points.ucRightTopHinge = points.rightTopHinge.shift(-90, uc); - points.ucRightTopHingeCp1 = points.rightTopHingeCp1.shift(-90, uc); - points.ucLeftTopHinge = points.ucRightTopHinge.flipX(); - points.ucLeftTopHingeCp2 = points.ucRightTopHingeCp1.flipX(); + let uc = points.topMid.dist(points.bottomMid) * 0.05 + points.ucTopMid = points.topMid.shift(-90, uc) + points.ucRightTopHinge = points.rightTopHinge.shift(-90, uc) + points.ucRightTopHingeCp1 = points.rightTopHingeCp1.shift(-90, uc) + points.ucLeftTopHinge = points.ucRightTopHinge.flipX() + points.ucLeftTopHingeCp2 = points.ucRightTopHingeCp1.flipX() paths.underCollar = new Path() .move(points.rightTopEdge) ._curve(points.ucRightTopHingeCp1, points.ucRightTopHinge) .line(points.ucLeftTopHinge) .curve_(points.ucLeftTopHingeCp2, points.leftTopEdge) - .attr("class", "dotted") - .attr("data-text", "cutUndercollarSlightlySmaller") - .attr("data-text-class", "center"); + .attr('class', 'dotted') + .attr('data-text', 'cutUndercollarSlightlySmaller') + .attr('data-text-class', 'center') // Helplines paths.help = new Path() .move(points.topMid) .line(points.bottomMid) - .attr("class", "dotted"); + .attr('class', 'dotted') // Grainline - macro("grainline", { + macro('grainline', { from: points.bottomMidCp2.shift(90, 10), to: points.bottomMidCp1.shift(90, 10) - }); + }) // Title - points.title = new Point(20, points.bottomMid.y / 2); - macro("title", { + points.title = new Point(20, points.bottomMid.y / 2) + macro('title', { at: points.title, - nr: "7 & 8", - title: "collarAndUndercollar", + nr: '7 & 8', + title: 'collarAndUndercollar', scale: 0.6, append: true - }); + }) // Indicate collar stand side paths.collarStandLeft = new Path() .move(points.leftBottomEdge) ._curve(points.bottomMidCp2, points.bottomMid) - .attr("data-text", "sideOfTheCollarStand") - .attr("data-text-class", "center"); + .attr('data-text', 'sideOfTheCollarStand') + .attr('data-text-class', 'center') paths.collarStandRight = new Path() .move(points.bottomMid) .curve_(points.bottomMidCp1, points.rightBottomEdge) - .attr("data-text", "sideOfTheCollarStand") - .attr("data-text-class", "center"); + .attr('data-text', 'sideOfTheCollarStand') + .attr('data-text-class', 'center') // Notches - macro("sprinkle", { - snippet: "notch", - on: [ - "bottomMid", - "rightBottomEdge", - "leftBottomEdge", - "rightTopEdge", - "leftTopEdge" - ] - }); + macro('sprinkle', { + snippet: 'notch', + on: ['bottomMid', 'rightBottomEdge', 'leftBottomEdge', 'rightTopEdge', 'leftTopEdge'] + }) if (sa) { - paths.sa = paths.seam.offset(sa).attr("class", "fabric sa"); - paths.saUndercollar = paths.underCollar - .offset(sa) - .attr("class", "dotted"); + paths.sa = paths.seam.offset(sa).attr('class', 'fabric sa') + paths.saUndercollar = paths.underCollar.offset(sa).attr('class', 'dotted') } } // Paperless? if (paperless) { - macro("vd", { + macro('vd', { from: points.bottomMid, to: points.topMid, x: points.rightTopEdge.x + 15 + sa - }); - macro("vd", { + }) + macro('vd', { from: points.bottomMid, to: points.rightTopEdge, x: points.rightTopEdge.x + 30 + sa - }); - macro("vd", { + }) + macro('vd', { from: points.rightBottomEdge, to: points.topMid, x: points.rightTopEdge.x + 45 + sa - }); - macro("vd", { + }) + macro('vd', { from: points.rightBottomEdge, to: points.rightTopEdge, x: points.rightTopEdge.x + 60 + sa - }); - macro("hd", { + }) + macro('hd', { from: points.leftTopHinge, to: points.rightTopHinge, y: points.leftTopEdge.y - 15 - sa - }); - macro("hd", { + }) + macro('hd', { from: points.leftTopEdge, to: points.rightTopEdge, y: points.leftTopEdge.y - 30 - sa - }); - macro("hd", { + }) + macro('hd', { from: points.leftBottomEdge, to: points.rightBottomEdge, y: points.leftBottomEdge.y + 15 + sa - }); + }) } - return part; -}; + return part +} diff --git a/packages/simon/src/collarstand.js b/packages/simon/src/collarstand.js index 186b781d0c5..929e9333e27 100644 --- a/packages/simon/src/collarstand.js +++ b/packages/simon/src/collarstand.js @@ -12,132 +12,83 @@ export default part => { paperless, macro, options - } = part.shorthand(); + } = part.shorthand() const draft = function(tweak = 1) { - let length = - measurements.neckCircumference * (1 + options.collarEase) * tweak; - let width = options.collarStandWidth; - let half = length / 2; - let bend = options.collarStandBend * -1; - let curve = options.collarStandCurve - options.collarStandBend; - let hinge = 90 + (bend + curve) / 2; + let length = measurements.neckCircumference * (1 + options.collarEase) * tweak + let width = options.collarStandWidth + let half = length / 2 + let bend = options.collarStandBend * -1 + let curve = options.collarStandCurve - options.collarStandBend + let hinge = 90 + (bend + curve) / 2 // Center line - points.center = new Point(0, 0); - points.hinge = points.center.shift(bend, half * 0.7); - points.rightCf = points.hinge.shift(curve, half * 0.3); + points.center = new Point(0, 0) + points.hinge = points.center.shift(bend, half * 0.7) + points.rightCf = points.hinge.shift(curve, half * 0.3) // Give it our collar width (right side only) - points.topMid = points.center.shift(90, width / 2); - points.bottomMid = points.topMid.flipY(); - points.rightTopHinge = points.hinge.shift(hinge, width / 2); - points.rightBottomHinge = points.hinge.shift(180 + hinge, width / 2); - points.rightTopCf = points.rightCf.shift(curve + 90, width / 2); - points.rightBottomCf = points.rightCf.shift(curve - 90, width / 2); - points.rightBottomEdge = points.rightBottomCf.shift( - curve, - options.buttonholePlacketWidth / 2 - ); + points.topMid = points.center.shift(90, width / 2) + points.bottomMid = points.topMid.flipY() + points.rightTopHinge = points.hinge.shift(hinge, width / 2) + points.rightBottomHinge = points.hinge.shift(180 + hinge, width / 2) + points.rightTopCf = points.rightCf.shift(curve + 90, width / 2) + points.rightBottomCf = points.rightCf.shift(curve - 90, width / 2) + points.rightBottomEdge = points.rightBottomCf.shift(curve, options.buttonholePlacketWidth / 2) // Add control points (right side only) - points.bottomMidCp2 = points.bottomMid.shift(0, half * 0.2); - points.rightBottomHingeCp1 = points.rightBottomHinge.shift( - 90 + hinge, - half * 0.2 - ); - points.rightBottomHingeCp2 = points.rightBottomHinge.shift( - hinge - 90, - half * 0.1 - ); - points.rightBottomCfCp1 = points.rightBottomCf.shift( - 180 + curve, - half * 0.1 - ); - points.rightBottomEdgeCp2 = points.rightBottomCf.rotate( - -90, - points.rightBottomEdge - ); - points.rightTopCfCp1 = points.rightTopCf.shift( - curve, - options.buttonholePlacketWidth / 2 - ); - points.topMidCp1 = points.topMid.shift(0, half * 0.2); - points.rightTopHingeCp2 = points.rightTopHinge.shift( - 90 + hinge, - half * 0.2 - ); - points.rightTopHingeCp1 = points.rightTopHinge.shift( - hinge - 90, - half * 0.1 - ); - points.topEdgeCp1 = points.rightTopCf.rotate(-90, points.rightBottomEdge); - points.rightTopCfCp2 = points.rightTopCf.shift( - 180 + curve, - options.buttonholePlacketWidth / 2 - ); + points.bottomMidCp2 = points.bottomMid.shift(0, half * 0.2) + points.rightBottomHingeCp1 = points.rightBottomHinge.shift(90 + hinge, half * 0.2) + points.rightBottomHingeCp2 = points.rightBottomHinge.shift(hinge - 90, half * 0.1) + points.rightBottomCfCp1 = points.rightBottomCf.shift(180 + curve, half * 0.1) + points.rightBottomEdgeCp2 = points.rightBottomCf.rotate(-90, points.rightBottomEdge) + points.rightTopCfCp1 = points.rightTopCf.shift(curve, options.buttonholePlacketWidth / 2) + points.topMidCp1 = points.topMid.shift(0, half * 0.2) + points.rightTopHingeCp2 = points.rightTopHinge.shift(90 + hinge, half * 0.2) + points.rightTopHingeCp1 = points.rightTopHinge.shift(hinge - 90, half * 0.1) + points.topEdgeCp1 = points.rightTopCf.rotate(-90, points.rightBottomEdge) + points.rightTopCfCp2 = points.rightTopCf.shift(180 + curve, options.buttonholePlacketWidth / 2) // Now do the left side - points.leftCf = points.rightCf.flipX(); - points.topMidCp2 = points.topMidCp1.flipX(); - points.leftTopHingeCp1 = points.rightTopHingeCp2.flipX(); - points.leftTopHinge = points.rightTopHinge.flipX(); - points.leftTopHingeCp2 = points.rightTopHingeCp1.flipX(); - points.leftTopCfCp1 = points.rightTopCfCp2.flipX(); - points.leftTopCf = points.rightTopCf.flipX(); - points.leftBottomCf = points.rightBottomCf.flipX(); - points.leftBottomEdge = points.leftBottomCf.shift( - bend + 180, - options.buttonPlacketWidth / 2 - ); - points.leftTopCfCp2 = points.leftTopCf.shift( - bend + 180, - options.buttonPlacketWidth / 2 - ); - points.leftBottomEdgeCp1 = points.leftBottomCf.rotate( - 90, - points.leftBottomEdge - ); - points.leftBottomCfCp2 = points.rightBottomCfCp1.flipX(); - points.leftBottomHingeCp1 = points.rightBottomHingeCp2.flipX(); - points.leftBottomHinge = points.rightBottomHinge.flipX(); - points.leftBottomHingeCp2 = points.rightBottomHingeCp1.flipX(); - points.bottomMidCp1 = points.bottomMidCp2.flipX(); + points.leftCf = points.rightCf.flipX() + points.topMidCp2 = points.topMidCp1.flipX() + points.leftTopHingeCp1 = points.rightTopHingeCp2.flipX() + points.leftTopHinge = points.rightTopHinge.flipX() + points.leftTopHingeCp2 = points.rightTopHingeCp1.flipX() + points.leftTopCfCp1 = points.rightTopCfCp2.flipX() + points.leftTopCf = points.rightTopCf.flipX() + points.leftBottomCf = points.rightBottomCf.flipX() + points.leftBottomEdge = points.leftBottomCf.shift(bend + 180, options.buttonPlacketWidth / 2) + points.leftTopCfCp2 = points.leftTopCf.shift(bend + 180, options.buttonPlacketWidth / 2) + points.leftBottomEdgeCp1 = points.leftBottomCf.rotate(90, points.leftBottomEdge) + points.leftBottomCfCp2 = points.rightBottomCfCp1.flipX() + points.leftBottomHingeCp1 = points.rightBottomHingeCp2.flipX() + points.leftBottomHinge = points.rightBottomHinge.flipX() + points.leftBottomHingeCp2 = points.rightBottomHingeCp1.flipX() + points.bottomMidCp1 = points.bottomMidCp2.flipX() let len = new Path() .move(points.leftBottomCf) - .curve( - points.leftBottomCfCp2, - points.leftBottomHingeCp1, - points.leftBottomHinge - ) + .curve(points.leftBottomCfCp2, points.leftBottomHingeCp1, points.leftBottomHinge) .curve(points.leftBottomHingeCp2, points.bottomMidCp1, points.bottomMid) - .length(); + .length() - return len * 2 - measurements.neckCircumference * (1 + options.collarEase); - }; + return len * 2 - measurements.neckCircumference * (1 + options.collarEase) + } - let delta, tweak, run; - tweak = 1; - run = 1; + let delta, tweak, run + tweak = 1 + run = 1 do { - delta = draft(tweak); - tweak = tweak * (1 - delta / 1000); - run++; - } while (Math.abs(delta) > 1 && run < 20); + delta = draft(tweak) + tweak = tweak * (1 - delta / 1000) + run++ + } while (Math.abs(delta) > 1 && run < 20) paths.seam = new Path() .move(points.bottomMid) - .curve( - points.bottomMidCp2, - points.rightBottomHingeCp1, - points.rightBottomHinge - ) - .curve( - points.rightBottomHingeCp2, - points.rightBottomCfCp1, - points.rightBottomCf - ) + .curve(points.bottomMidCp2, points.rightBottomHingeCp1, points.rightBottomHinge) + .curve(points.rightBottomHingeCp2, points.rightBottomCfCp1, points.rightBottomCf) .line(points.rightBottomEdge) .curve(points.rightBottomEdgeCp2, points.rightTopCfCp1, points.rightTopCf) .curve(points.rightTopCfCp2, points.rightTopHingeCp1, points.rightTopHinge) @@ -146,14 +97,10 @@ export default part => { .curve(points.leftTopHingeCp2, points.leftTopCfCp1, points.leftTopCf) .curve(points.leftTopCfCp2, points.leftBottomEdgeCp1, points.leftBottomEdge) .line(points.leftBottomCf) - .curve( - points.leftBottomCfCp2, - points.leftBottomHingeCp1, - points.leftBottomHinge - ) + .curve(points.leftBottomCfCp2, points.leftBottomHingeCp1, points.leftBottomHinge) .curve(points.leftBottomHingeCp2, points.bottomMidCp1, points.bottomMid) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') // Complete pattern? if (complete) { @@ -165,114 +112,102 @@ export default part => { .line(points.bottomMid) .move(points.leftTopCf) .line(points.leftBottomCf) - .attr("class", "dotted"); + .attr('class', 'dotted') // Grainline - macro("grainline", { + macro('grainline', { from: points.leftCf, to: points.rightCf - }); + }) // Title - points.title = points.center.shift(0, 20); - macro("title", { + points.title = points.center.shift(0, 20) + macro('title', { at: points.title, nr: 6, - title: "collarStand", + title: 'collarStand', scale: 0.6 - }); + }) // Notches - macro("sprinkle", { - snippet: "notch", + macro('sprinkle', { + snippet: 'notch', on: [ - "rightTopCf", - "rightBottomCf", - "leftBottomCf", - "leftTopCf", - "rightBottomEdge", - "leftBottomEdge" + 'rightTopCf', + 'rightBottomCf', + 'leftBottomCf', + 'leftTopCf', + 'rightBottomEdge', + 'leftBottomEdge' ] - }); + }) // Button and buttonhole - snippets.button = new Snippet("button", points.leftCf); - let angle = options.collarStandCurve - options.collarStandBend - 180; - points.buttonhole = points.rightCf.shift(angle, 3); - snippets.buttonhole = new Snippet("buttonhole", points.buttonhole).attr( - "data-rotate", + snippets.button = new Snippet('button', points.leftCf) + let angle = options.collarStandCurve - options.collarStandBend - 180 + points.buttonhole = points.rightCf.shift(angle, 3) + snippets.buttonhole = new Snippet('buttonhole', points.buttonhole).attr( + 'data-rotate', 90 - angle - ); + ) if (sa) { - paths.sa = paths.seam.offset(sa); + paths.sa = paths.seam.offset(sa) } } // Paperless? if (paperless) { - macro("hd", { + macro('hd', { from: points.topMid, to: points.rightTopCf, y: points.topMid.y - 15 - sa - }); - macro("hd", { + }) + macro('hd', { from: points.leftTopCf, to: points.topMid, y: points.topMid.y - 15 - sa - }); - macro("hd", { + }) + macro('hd', { from: points.topMid, to: points.rightBottomEdge, y: points.topMid.y - 30 - sa - }); - macro("hd", { + }) + macro('hd', { from: points.leftBottomEdge, to: points.topMid, y: points.topMid.y - 30 - sa - }); - macro("pd", { + }) + macro('pd', { path: new Path() .move(points.leftBottomCf) - .curve( - points.leftBottomCfCp2, - points.leftBottomHingeCp1, - points.leftBottomHinge - ) + .curve(points.leftBottomCfCp2, points.leftBottomHingeCp1, points.leftBottomHinge) .curve(points.leftBottomHingeCp2, points.bottomMidCp1, points.bottomMid) - .curve( - points.bottomMidCp2, - points.rightBottomHingeCp1, - points.rightBottomHinge - ) - .curve( - points.rightBottomHingeCp2, - points.rightBottomCfCp1, - points.rightBottomCf - ), + .curve(points.bottomMidCp2, points.rightBottomHingeCp1, points.rightBottomHinge) + .curve(points.rightBottomHingeCp2, points.rightBottomCfCp1, points.rightBottomCf), d: 15 + sa - }); - macro("ld", { + }) + macro('ld', { from: points.leftBottomEdge, to: points.leftBottomCf, d: -30 - sa - }); - macro("ld", { + }) + macro('ld', { from: points.rightBottomCf, to: points.rightBottomEdge, d: -30 - sa - }); - macro("ld", { + }) + macro('ld', { from: points.rightBottomCf, to: points.rightTopCf, d: -15 - sa - options.buttonholePlacketWidth / 2 - }); - macro("vd", { + }) + macro('vd', { from: points.rightBottomCf, to: points.topMid, x: points.rightBottomEdge.x + 30 + sa - }); + }) } - return part; -}; + return part +} diff --git a/packages/simon/src/cuff-barrel-angled.js b/packages/simon/src/cuff-barrel-angled.js index f5531ad1e28..e457a53c041 100644 --- a/packages/simon/src/cuff-barrel-angled.js +++ b/packages/simon/src/cuff-barrel-angled.js @@ -1,28 +1,15 @@ -import { - draftBarrelCuff, - decorateBarrelCuff, - paperlessBarrelCuff -} from "./shared"; +import { draftBarrelCuff, decorateBarrelCuff, paperlessBarrelCuff } from './shared' export default part => { - let { - store, - sa, - points, - Path, - paths, - complete, - paperless, - macro - } = part.shorthand(); + let { store, sa, points, Path, paths, complete, paperless, macro } = part.shorthand() - draftBarrelCuff(part); - let height = store.get("cuffHeight"); + draftBarrelCuff(part) + let height = store.get('cuffHeight') - points.leftAngleTop = points.topLeft.shift(0, height / 3); - points.leftAngleBottom = points.topLeft.shift(-90, height / 3); - points.rightAngleTop = points.topRight.shift(180, height / 3); - points.rightAngleBottom = points.topRight.shift(-90, height / 3); + points.leftAngleTop = points.topLeft.shift(0, height / 3) + points.leftAngleBottom = points.topLeft.shift(-90, height / 3) + points.rightAngleTop = points.topRight.shift(180, height / 3) + points.rightAngleBottom = points.topRight.shift(-90, height / 3) paths.seam = new Path() .move(points.leftAngleBottom) .line(points.bottomLeft) @@ -32,23 +19,23 @@ export default part => { .line(points.leftAngleTop) .line(points.leftAngleBottom) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') // Complete pattern? if (complete) { - decorateBarrelCuff(part); - if (sa) paths.sa = paths.seam.offset(sa); + decorateBarrelCuff(part) + if (sa) paths.sa = paths.seam.offset(sa) } // Paperless? if (paperless) { - paperlessBarrelCuff(part); - macro("vd", { + paperlessBarrelCuff(part) + macro('vd', { from: points.rightAngleBottom, to: points.rightAngleTop, x: points.rightAngleBottom.x + 15 + sa - }); + }) } - return part; -}; + return part +} diff --git a/packages/simon/src/cuff-barrel-rounded.js b/packages/simon/src/cuff-barrel-rounded.js index fc847f83363..091656f2311 100644 --- a/packages/simon/src/cuff-barrel-rounded.js +++ b/packages/simon/src/cuff-barrel-rounded.js @@ -1,74 +1,53 @@ -import { - draftBarrelCuff, - decorateBarrelCuff, - paperlessBarrelCuff -} from "./shared"; +import { draftBarrelCuff, decorateBarrelCuff, paperlessBarrelCuff } from './shared' export default part => { - let { - store, - sa, - points, - Path, - paths, - complete, - paperless, - macro - } = part.shorthand(); + let { store, sa, points, Path, paths, complete, paperless, macro } = part.shorthand() - draftBarrelCuff(part); - let height = store.get("cuffHeight"); - macro("round", { + draftBarrelCuff(part) + let height = store.get('cuffHeight') + macro('round', { from: points.topRight, to: points.bottomLeft, via: points.topLeft, radius: height / 3, - prefix: "topLeftRound" - }); - macro("round", { + prefix: 'topLeftRound' + }) + macro('round', { from: points.bottomRight, to: points.topLeft, via: points.topRight, radius: height / 3, - prefix: "topRightRound" - }); - points.leftAngleBottom = points.topLeft.shift(-90, height / 3); - points.rightAngleTop = points.topRight.shift(180, height / 3); - points.rightAngleBottom = points.topRight.shift(-90, height / 3); + prefix: 'topRightRound' + }) + points.leftAngleBottom = points.topLeft.shift(-90, height / 3) + points.rightAngleTop = points.topRight.shift(180, height / 3) + points.rightAngleBottom = points.topRight.shift(-90, height / 3) paths.seam = new Path() .move(points.topLeftRoundEnd) .line(points.bottomLeft) .line(points.bottomRight) .line(points.topRightRoundStart) - .curve( - points.topRightRoundCp1, - points.topRightRoundCp2, - points.topRightRoundEnd - ) + .curve(points.topRightRoundCp1, points.topRightRoundCp2, points.topRightRoundEnd) .line(points.topLeftRoundStart) - .curve( - points.topLeftRoundCp1, - points.topLeftRoundCp2, - points.topLeftRoundEnd - ) + .curve(points.topLeftRoundCp1, points.topLeftRoundCp2, points.topLeftRoundEnd) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') // Complete pattern? if (complete) { - decorateBarrelCuff(part); - if (sa) paths.sa = paths.seam.offset(sa); + decorateBarrelCuff(part) + if (sa) paths.sa = paths.seam.offset(sa) } // Paperless? if (paperless) { - paperlessBarrelCuff(part); - macro("vd", { + paperlessBarrelCuff(part) + macro('vd', { from: points.topRightRoundStart, to: points.topRightRoundEnd, x: points.topRightRoundStart.x + 15 + sa - }); + }) } - return part; -}; + return part +} diff --git a/packages/simon/src/cuff-barrel-straight.js b/packages/simon/src/cuff-barrel-straight.js index 2eaad934514..235f7aa9741 100644 --- a/packages/simon/src/cuff-barrel-straight.js +++ b/packages/simon/src/cuff-barrel-straight.js @@ -1,13 +1,9 @@ -import { - draftBarrelCuff, - decorateBarrelCuff, - paperlessBarrelCuff -} from "./shared"; +import { draftBarrelCuff, decorateBarrelCuff, paperlessBarrelCuff } from './shared' export default part => { - let { sa, points, Path, paths, complete, paperless } = part.shorthand(); + let { sa, points, Path, paths, complete, paperless } = part.shorthand() - draftBarrelCuff(part); + draftBarrelCuff(part) paths.seam = new Path() .move(points.topLeft) .line(points.bottomLeft) @@ -15,18 +11,18 @@ export default part => { .line(points.topRight) .line(points.topLeft) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') // Complete pattern? if (complete) { - decorateBarrelCuff(part); - if (sa) paths.sa = paths.seam.offset(sa); + decorateBarrelCuff(part) + if (sa) paths.sa = paths.seam.offset(sa) } // Paperless? if (paperless) { - paperlessBarrelCuff(part); + paperlessBarrelCuff(part) } - return part; -}; + return part +} diff --git a/packages/simon/src/cuff-french-angled.js b/packages/simon/src/cuff-french-angled.js index 7dd1583ccac..79b97ffe1f9 100644 --- a/packages/simon/src/cuff-french-angled.js +++ b/packages/simon/src/cuff-french-angled.js @@ -1,31 +1,19 @@ -import { - draftFrenchCuff, - decorateFrenchCuff, - paperlessFrenchCuff -} from "./shared"; +import { draftFrenchCuff, decorateFrenchCuff, paperlessFrenchCuff } from './shared' export default part => { - let { - store, - sa, - points, - Path, - paths, - complete, - paperless - } = part.shorthand(); + let { store, sa, points, Path, paths, complete, paperless } = part.shorthand() - draftFrenchCuff(part); - let height = store.get("cuffHeight"); - points.leftAngleTopTop = points.topLeft.shift(0, height / 3); - points.leftAngleTopBottom = points.topLeft.shift(-90, height / 3); - points.rightAngleTopTop = points.topRight.shift(180, height / 3); - points.rightAngleTopBottom = points.topRight.shift(-90, height / 3); + draftFrenchCuff(part) + let height = store.get('cuffHeight') + points.leftAngleTopTop = points.topLeft.shift(0, height / 3) + points.leftAngleTopBottom = points.topLeft.shift(-90, height / 3) + points.rightAngleTopTop = points.topRight.shift(180, height / 3) + points.rightAngleTopBottom = points.topRight.shift(-90, height / 3) - points.leftAngleBottomTop = points.bottomLeft.shift(90, height / 3); - points.leftAngleBottomBottom = points.bottomLeft.shift(0, height / 3); - points.rightAngleBottomTop = points.bottomRight.shift(90, height / 3); - points.rightAngleBottomBottom = points.bottomRight.shift(180, height / 3); + points.leftAngleBottomTop = points.bottomLeft.shift(90, height / 3) + points.leftAngleBottomBottom = points.bottomLeft.shift(0, height / 3) + points.rightAngleBottomTop = points.bottomRight.shift(90, height / 3) + points.rightAngleBottomBottom = points.bottomRight.shift(180, height / 3) paths.seam = new Path() .move(points.leftAngleTopBottom) @@ -38,21 +26,21 @@ export default part => { .line(points.leftAngleTopTop) .line(points.leftAngleTopBottom) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') paths.fold = new Path() .move(points.midLeft) .line(points.midRight) - .attr("class", "dotted"); + .attr('class', 'dotted') // Complete pattern? if (complete) { - decorateFrenchCuff(part); - if (sa) paths.sa = paths.seam.offset(sa).attr("class", "fabric sa"); + decorateFrenchCuff(part) + if (sa) paths.sa = paths.seam.offset(sa).attr('class', 'fabric sa') } // Paperless? - if (paperless) paperlessFrenchCuff(part); + if (paperless) paperlessFrenchCuff(part) - return part; -}; + return part +} diff --git a/packages/simon/src/cuff-french-rounded.js b/packages/simon/src/cuff-french-rounded.js index 5173d9c8f54..a03fad4fff8 100644 --- a/packages/simon/src/cuff-french-rounded.js +++ b/packages/simon/src/cuff-french-rounded.js @@ -1,50 +1,37 @@ -import { - draftFrenchCuff, - decorateFrenchCuff, - paperlessFrenchCuff -} from "./shared"; +import { draftFrenchCuff, decorateFrenchCuff, paperlessFrenchCuff } from './shared' export default part => { - let { - store, - sa, - points, - Path, - paths, - complete, - paperless, - macro - } = part.shorthand(); - draftFrenchCuff(part); - let height = store.get("cuffHeight"); - macro("round", { + let { store, sa, points, Path, paths, complete, paperless, macro } = part.shorthand() + draftFrenchCuff(part) + let height = store.get('cuffHeight') + macro('round', { from: points.topRight, to: points.bottomLeft, via: points.topLeft, radius: height / 3, - prefix: "topLeft" - }); - macro("round", { + prefix: 'topLeft' + }) + macro('round', { from: points.topLeft, to: points.bottomRight, via: points.bottomLeft, radius: height / 3, - prefix: "bottomLeft" - }); - macro("round", { + prefix: 'bottomLeft' + }) + macro('round', { from: points.bottomLeft, to: points.topRight, via: points.bottomRight, radius: height / 3, - prefix: "bottomRight" - }); - macro("round", { + prefix: 'bottomRight' + }) + macro('round', { from: points.bottomRight, to: points.topLeft, via: points.topRight, radius: height / 3, - prefix: "topRight" - }); + prefix: 'topRight' + }) paths.seam = new Path() .move(points.topLeftEnd) @@ -57,21 +44,21 @@ export default part => { .line(points.topLeftStart) .curve(points.topLeftCp1, points.topLeftCp2, points.topLeftEnd) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') paths.fold = new Path() .move(points.midLeft) .line(points.midRight) - .attr("class", "dotted"); + .attr('class', 'dotted') // Complete pattern? if (complete) { - decorateFrenchCuff(part); - if (sa) paths.sa = paths.seam.offset(sa).attr("class", "fabric sa"); + decorateFrenchCuff(part) + if (sa) paths.sa = paths.seam.offset(sa).attr('class', 'fabric sa') } // Paperless? - if (paperless) paperlessFrenchCuff(part); + if (paperless) paperlessFrenchCuff(part) - return part; -}; + return part +} diff --git a/packages/simon/src/cuff-french-straight.js b/packages/simon/src/cuff-french-straight.js index c749c21bc3a..fbed2df25ca 100644 --- a/packages/simon/src/cuff-french-straight.js +++ b/packages/simon/src/cuff-french-straight.js @@ -1,13 +1,9 @@ -import { - draftFrenchCuff, - decorateFrenchCuff, - paperlessFrenchCuff -} from "./shared"; +import { draftFrenchCuff, decorateFrenchCuff, paperlessFrenchCuff } from './shared' export default part => { - let { sa, points, Path, paths, complete, paperless } = part.shorthand(); + let { sa, points, Path, paths, complete, paperless } = part.shorthand() - draftFrenchCuff(part); + draftFrenchCuff(part) paths.seam = new Path() .move(points.topLeft) @@ -16,21 +12,21 @@ export default part => { .line(points.topRight) .line(points.topLeft) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') paths.fold = new Path() .move(points.midLeft) .line(points.midRight) - .attr("class", "dotted"); + .attr('class', 'dotted') // Complete pattern? if (complete) { - decorateFrenchCuff(part); - if (sa) paths.sa = paths.seam.offset(sa); + decorateFrenchCuff(part) + if (sa) paths.sa = paths.seam.offset(sa) } // Paperless? - if (paperless) paperlessFrenchCuff(part); + if (paperless) paperlessFrenchCuff(part) - return part; -}; + return part +} diff --git a/packages/simon/src/cuff.js b/packages/simon/src/cuff.js index bd1854aa0ed..1fb92ab15c4 100644 --- a/packages/simon/src/cuff.js +++ b/packages/simon/src/cuff.js @@ -1,24 +1,24 @@ -import straightBarrelCuff from "./cuff-barrel-straight"; -import roundedBarrelCuff from "./cuff-barrel-rounded"; -import angledBarrelCuff from "./cuff-barrel-angled"; -import straightFrenchCuff from "./cuff-french-straight"; -import angledFrenchCuff from "./cuff-french-angled"; -import roundedFrenchCuff from "./cuff-french-rounded"; +import straightBarrelCuff from './cuff-barrel-straight' +import roundedBarrelCuff from './cuff-barrel-rounded' +import angledBarrelCuff from './cuff-barrel-angled' +import straightFrenchCuff from './cuff-french-straight' +import angledFrenchCuff from './cuff-french-angled' +import roundedFrenchCuff from './cuff-french-rounded' export default part => { - let { options } = part.shorthand(); + let { options } = part.shorthand() switch (options.cuffStyle) { - case "roundedBarrelCuff": - return roundedBarrelCuff(part); - case "straightBarrelCuff": - return straightBarrelCuff(part); - case "roundedFrenchCuff": - return roundedFrenchCuff(part); - case "angledFrenchCuff": - return angledFrenchCuff(part); - case "straightFrenchCuff": - return straightFrenchCuff(part); + case 'roundedBarrelCuff': + return roundedBarrelCuff(part) + case 'straightBarrelCuff': + return straightBarrelCuff(part) + case 'roundedFrenchCuff': + return roundedFrenchCuff(part) + case 'angledFrenchCuff': + return angledFrenchCuff(part) + case 'straightFrenchCuff': + return straightFrenchCuff(part) default: - return angledBarrelCuff(part); + return angledBarrelCuff(part) } -}; +} diff --git a/packages/simon/src/front.js b/packages/simon/src/front.js index b2d3ad810c6..b0091878e99 100644 --- a/packages/simon/src/front.js +++ b/packages/simon/src/front.js @@ -1,7 +1,7 @@ -import { calculateReduction } from "./shared"; +import { calculateReduction } from './shared' export default part => { - part.paths = {}; + part.paths = {} let { store, measurements, @@ -14,138 +14,126 @@ export default part => { paperless, macro, options - } = part.shorthand(); + } = part.shorthand() // Populare store with data we need - calculateReduction(part); + calculateReduction(part) store.set( - "frontArmholeLength", + 'frontArmholeLength', new Path() .move(points.armhole) .curve(points.armholeCp2, points.armholeHollowCp1, points.armholeHollow) - .curve( - points.armholeHollowCp2, - points.armholePitchCp1, - points.armholePitch - ) + .curve(points.armholeHollowCp2, points.armholePitchCp1, points.armholePitch) .curve(points.armholePitchCp2, points.shoulderCp1, points.shoulder) .length() - ); + ) // Hip shaping - points.hips = points.hips.shift(180, store.get("hipsReduction") / 4); - points.hem = points.hem.shift(180, store.get("hipsReduction") / 4); + points.hips = points.hips.shift(180, store.get('hipsReduction') / 4) + points.hem = points.hem.shift(180, store.get('hipsReduction') / 4) // Waist shaping - let reduce = store.get("waistReduction"); - if (reduce / 4 > options.minimalDartShaping) reduce = reduce / 8; - else reduce = reduce / 4; - points.waist = points.waist.shift(180, reduce); - points.waistCp1 = points.waist.shift( - -90, - measurements.naturalWaistToHip * 0.5 - ); - points.waistCp2 = points.waist.shift(90, points.armhole.dy(points.waist) / 2); - points.hipsCp2 = points.hips.shift(90, points.waist.dy(points.hips) / 4); + let reduce = store.get('waistReduction') + if (reduce / 4 > options.minimalDartShaping) reduce = reduce / 8 + else reduce = reduce / 4 + points.waist = points.waist.shift(180, reduce) + points.waistCp1 = points.waist.shift(-90, measurements.naturalWaistToHip * 0.5) + points.waistCp2 = points.waist.shift(90, points.armhole.dy(points.waist) / 2) + points.hipsCp2 = points.hips.shift(90, points.waist.dy(points.hips) / 4) // Draft hem paths.saBaseFromHips = new Path() .move(points.hips) .curve(points.hipsCp2, points.waistCp1, points.waist) - .curve_(points.waistCp2, points.armhole); + .curve_(points.waistCp2, points.armhole) paths.saBaseFromArmhole = new Path() .move(points.armhole) .curve(points.armholeCp2, points.armholeHollowCp1, points.armholeHollow) .curve(points.armholeHollowCp2, points.armholePitchCp1, points.armholePitch) .curve(points.armholePitchCp2, points.shoulderCp1, points.shoulder) .line(points.neck) - .curve(points.neckCp2Front, points.cfNeckCp1, points.cfNeck); + .curve(points.neckCp2Front, points.cfNeckCp1, points.cfNeck) switch (options.hemStyle) { - case "baseball": - points.bballStart = points.cfHem.shiftFractionTowards(points.hem, 0.5); - points.bballEnd = points.hem.shiftFractionTowards( - points.hips, - options.hemCurve - ); - points.bballCp1 = points.bballStart.shiftFractionTowards(points.hem, 0.5); - points.bballCp2 = new Point(points.bballCp1.x, points.bballEnd.y); + case 'baseball': + points.bballStart = points.cfHem.shiftFractionTowards(points.hem, 0.5) + points.bballEnd = points.hem.shiftFractionTowards(points.hips, options.hemCurve) + points.bballCp1 = points.bballStart.shiftFractionTowards(points.hem, 0.5) + points.bballCp2 = new Point(points.bballCp1.x, points.bballEnd.y) paths.saBase = new Path() .move(points.bballEnd) .line(points.hips) - .join(paths.saBaseFromHips); + .join(paths.saBaseFromHips) paths.hemBase = new Path() .move(points.cfHem) .line(points.bballStart) - .curve(points.bballCp1, points.bballCp2, points.bballEnd); - break; - case "slashed": - macro("round", { + .curve(points.bballCp1, points.bballCp2, points.bballEnd) + break + case 'slashed': + macro('round', { from: points.hips, to: points.cfHem, via: points.hem, radius: points.hips.dist(points.hem) * options.hemCurve, - prefix: "slash" - }); - paths.saBase = new Path().move(points.hips).join(paths.saBaseFromHips); + prefix: 'slash' + }) + paths.saBase = new Path().move(points.hips).join(paths.saBaseFromHips) paths.hemBase = new Path() .move(points.cfHem) .line(points.slashEnd) - .curve(points.slashCp2, points.slashCp1, points.slashStart); - break; + .curve(points.slashCp2, points.slashCp1, points.slashStart) + break default: paths.saBase = new Path() .move(points.hem) .line(points.hips) - .join(paths.saBaseFromHips); - paths.hemBase = new Path().move(points.cfHem).line(points.hem); + .join(paths.saBaseFromHips) + paths.hemBase = new Path().move(points.cfHem).line(points.hem) } // Paths - paths.saBase.render = false; - paths.saBaseFromHips.render = false; - paths.saBaseFromArmhole.render = false; - paths.hemBase.render = false; + paths.saBase.render = false + paths.saBaseFromHips.render = false + paths.saBaseFromArmhole.render = false + paths.hemBase.render = false paths.seam = paths.hemBase .join(paths.saBase) .join(paths.saBaseFromArmhole) - .attr("class", "fabric"); + .attr('class', 'fabric') // Complete pattern? if (complete) { - delete paths.cutonfold; - macro("grainline", { + delete paths.cutonfold + macro('grainline', { from: points.cfHem.shift(0, 45), to: points.cfNeck.shift(0, 45) - }); - macro("title", { at: points.title, nr: "X", title: "front" }); - macro("sprinkle", { - snippet: "notch", + }) + macro('title', { at: points.title, nr: 'X', title: 'front' }) + macro('sprinkle', { + snippet: 'notch', on: [ - "waist", - "armholePitch", - "shoulder", - "neck", - "hips", - "cfHips", - "cfWaist", - "armhole", - "cfArmhole" + 'waist', + 'armholePitch', + 'shoulder', + 'neck', + 'hips', + 'cfHips', + 'cfWaist', + 'armhole', + 'cfArmhole' ] - }); + }) if (sa) { - paths.saFrench = paths.saBase.offset(sa * 2).attr("class", "fabric sa"); - paths.saFromArmhole = paths.saBaseFromArmhole - .offset(sa) - .attr("class", "fabric sa"); - paths.hemSa = paths.hemBase.offset(sa * 3).attr("class", "fabric sa"); + paths.saFrench = paths.saBase.offset(sa * 2).attr('class', 'fabric sa') + paths.saFromArmhole = paths.saBaseFromArmhole.offset(sa).attr('class', 'fabric sa') + paths.hemSa = paths.hemBase.offset(sa * 3).attr('class', 'fabric sa') paths.saConnect = new Path() .move(paths.hemSa.end()) .line(paths.saFrench.start()) .move(paths.saFrench.end()) .line(paths.saFromArmhole.start()) - .attr("class", "fabric sa"); - delete paths.sa; + .attr('class', 'fabric sa') + delete paths.sa } } @@ -153,5 +141,5 @@ export default part => { if (paperless) { } - return part; -}; + return part +} diff --git a/packages/simon/src/frontleft-classic-cuton.js b/packages/simon/src/frontleft-classic-cuton.js index 178ed1faec1..09934bc853b 100644 --- a/packages/simon/src/frontleft-classic-cuton.js +++ b/packages/simon/src/frontleft-classic-cuton.js @@ -1,4 +1,4 @@ -import { addButtonHoles } from "./shared"; +import { addButtonHoles } from './shared' export default part => { let { @@ -12,58 +12,31 @@ export default part => { paperless, macro, options - } = part.shorthand(); + } = part.shorthand() - let fold = options.buttonholePlacketFoldWidth; - let width = options.buttonholePlacketWidth; - points.placketCfNeck = points.cfNeck.shift(180, fold * 2); - points.placketTopInnerEdgeFold = points.placketCfNeck.shift(0, width / 2); - points.placketTopInnerEdgeOver = points.placketCfNeck.shift( - 0, - width / 2 - fold - ); - points.placketTopInnerEdgeUnder = points.placketCfNeck.shift( - 0, - width / 2 + fold - ); - points.placketTopOuterEdgeFold = points.placketCfNeck.shift(180, width / 2); - points.placketTopOuterEdgeOver = points.placketCfNeck.shift( - 180, - width / 2 - fold - ); - points.placketTopOuterEdgeUnder = points.placketCfNeck.shift( - 180, - width / 2 + fold - ); - points.placketCfHem = points.cfHem.shift(180, fold * 2); - points.placketBottomInnerEdgeFold = points.placketCfHem.shift(0, width / 2); - points.placketBottomInnerEdgeOver = points.placketCfHem.shift( - 0, - width / 2 - fold - ); - points.placketBottomInnerEdgeUnder = points.placketCfHem.shift( - 0, - width / 2 + fold - ); - points.placketBottomOuterEdgeFold = points.placketCfHem.shift(180, width / 2); - points.placketBottomOuterEdgeOver = points.placketCfHem.shift( - 180, - width / 2 - fold - ); - points.placketBottomOuterEdgeUnder = points.placketCfHem.shift( - 180, - width / 2 + fold - ); - points.placketTopEdge = points.placketTopOuterEdgeFold.shift(180, width); - points.placketBottomEdge = points.placketBottomOuterEdgeFold.shift( - 180, - width - ); + let fold = options.buttonholePlacketFoldWidth + let width = options.buttonholePlacketWidth + points.placketCfNeck = points.cfNeck.shift(180, fold * 2) + points.placketTopInnerEdgeFold = points.placketCfNeck.shift(0, width / 2) + points.placketTopInnerEdgeOver = points.placketCfNeck.shift(0, width / 2 - fold) + points.placketTopInnerEdgeUnder = points.placketCfNeck.shift(0, width / 2 + fold) + points.placketTopOuterEdgeFold = points.placketCfNeck.shift(180, width / 2) + points.placketTopOuterEdgeOver = points.placketCfNeck.shift(180, width / 2 - fold) + points.placketTopOuterEdgeUnder = points.placketCfNeck.shift(180, width / 2 + fold) + points.placketCfHem = points.cfHem.shift(180, fold * 2) + points.placketBottomInnerEdgeFold = points.placketCfHem.shift(0, width / 2) + points.placketBottomInnerEdgeOver = points.placketCfHem.shift(0, width / 2 - fold) + points.placketBottomInnerEdgeUnder = points.placketCfHem.shift(0, width / 2 + fold) + points.placketBottomOuterEdgeFold = points.placketCfHem.shift(180, width / 2) + points.placketBottomOuterEdgeOver = points.placketCfHem.shift(180, width / 2 - fold) + points.placketBottomOuterEdgeUnder = points.placketCfHem.shift(180, width / 2 + fold) + points.placketTopEdge = points.placketTopOuterEdgeFold.shift(180, width) + points.placketBottomEdge = points.placketBottomOuterEdgeFold.shift(180, width) paths.seam .line(points.placketTopEdge) .line(points.placketBottomEdge) - .close(); + .close() // Complete pattern? if (complete) { @@ -71,73 +44,64 @@ export default part => { paths.frontCenter = new Path() .move(points.placketCfNeck) .line(points.placketCfHem) - .attr("class", "help"); + .attr('class', 'help') paths.placketInnerEdgeFold = new Path() .move(points.placketTopInnerEdgeFold) .line(points.placketBottomInnerEdgeFold) - .attr("class", "dotted"); + .attr('class', 'dotted') paths.placketInnerEdgeOver = new Path() .move(points.placketTopInnerEdgeOver) .line(points.placketBottomInnerEdgeOver) - .attr("class", "dotted"); + .attr('class', 'dotted') paths.placketInnerEdgeUnder = new Path() .move(points.placketTopInnerEdgeUnder) .line(points.placketBottomInnerEdgeUnder) - .attr("class", "dotted"); + .attr('class', 'dotted') paths.placketOuterEdgeFold = new Path() .move(points.placketTopOuterEdgeFold) .line(points.placketBottomOuterEdgeFold) - .attr("class", "dotted"); + .attr('class', 'dotted') paths.placketOuterEdgeOver = new Path() .move(points.placketTopOuterEdgeOver) .line(points.placketBottomOuterEdgeOver) - .attr("class", "dotted"); + .attr('class', 'dotted') paths.placketOuterEdgeUnder = new Path() .move(points.placketTopOuterEdgeUnder) .line(points.placketBottomOuterEdgeUnder) - .attr("class", "dotted"); - points.placketEdgeWaist = new Point( - points.placketBottomEdge.x, - points.waist.y - ); - points.placketEdgeArmhole = new Point( - points.placketBottomEdge.x, - points.armhole.y - ); - points.placketEdgeHips = new Point( - points.placketBottomEdge.x, - points.hips.y - ); - macro("sprinkle", { - snippet: "notch", + .attr('class', 'dotted') + points.placketEdgeWaist = new Point(points.placketBottomEdge.x, points.waist.y) + points.placketEdgeArmhole = new Point(points.placketBottomEdge.x, points.armhole.y) + points.placketEdgeHips = new Point(points.placketBottomEdge.x, points.hips.y) + macro('sprinkle', { + snippet: 'notch', on: [ - "placketCfNeck", - "placketCfHem", - "placketEdgeArmhole", - "placketEdgeWaist", - "placketEdgeHips", - "placketTopInnerEdgeFold", - "placketTopInnerEdgeOver", - "placketTopInnerEdgeUnder", - "placketTopOuterEdgeFold", - "placketTopOuterEdgeOver", - "placketTopOuterEdgeUnder", - "placketBottomInnerEdgeFold", - "placketBottomInnerEdgeOver", - "placketBottomInnerEdgeUnder", - "placketBottomOuterEdgeFold", - "placketBottomOuterEdgeOver", - "placketBottomOuterEdgeUnder" + 'placketCfNeck', + 'placketCfHem', + 'placketEdgeArmhole', + 'placketEdgeWaist', + 'placketEdgeHips', + 'placketTopInnerEdgeFold', + 'placketTopInnerEdgeOver', + 'placketTopInnerEdgeUnder', + 'placketTopOuterEdgeFold', + 'placketTopOuterEdgeOver', + 'placketTopOuterEdgeUnder', + 'placketBottomInnerEdgeFold', + 'placketBottomInnerEdgeOver', + 'placketBottomInnerEdgeUnder', + 'placketBottomOuterEdgeFold', + 'placketBottomOuterEdgeOver', + 'placketBottomOuterEdgeUnder' ] - }); - delete snippets["cfWaist-notch"]; - delete snippets["cfHips-notch"]; - delete snippets["cfArmhole-notch"]; + }) + delete snippets['cfWaist-notch'] + delete snippets['cfHips-notch'] + delete snippets['cfArmhole-notch'] // Buttons - addButtonHoles(part, "placketCfNeck"); + addButtonHoles(part, 'placketCfNeck') // Title - macro("title", { at: points.title, nr: 2, title: "frontLeft" }); + macro('title', { at: points.title, nr: 2, title: 'frontLeft' }) if (sa) { paths.saFromArmhole @@ -145,66 +109,66 @@ export default part => { .line(points.placketTopEdge) .move(points.placketBottomEdge) .line(points.placketBottomEdge.shift(-90, 3 * sa)) - .line(paths.hemSa.start()); + .line(paths.hemSa.start()) } } // Paperless? if (paperless) { - macro("hd", { + macro('hd', { from: points.placketEdgeArmhole, to: points.armhole - }); - macro("hd", { + }) + macro('hd', { from: points.placketEdgeWaist, to: points.waist - }); - macro("hd", { + }) + macro('hd', { from: points.placketEdgeHips, to: points.hips - }); - let offset = 0; + }) + let offset = 0 for (let pid of [ - "placketTopOuterEdgeUnder", - "placketTopOuterEdgeFold", - "placketTopOuterEdgeOver", - "placketCfNeck", - "placketTopInnerEdgeOver", - "placketTopInnerEdgeFold", - "placketTopInnerEdgeUnder" + 'placketTopOuterEdgeUnder', + 'placketTopOuterEdgeFold', + 'placketTopOuterEdgeOver', + 'placketCfNeck', + 'placketTopInnerEdgeOver', + 'placketTopInnerEdgeFold', + 'placketTopInnerEdgeUnder' ]) { - offset += 15; - macro("hd", { + offset += 15 + macro('hd', { from: points.placketTopEdge, to: points[pid], y: points.placketTopEdge.y - offset - sa - }); + }) } - macro("hd", { + macro('hd', { from: points.placketTopEdge, to: points.neck, y: points.placketTopEdge.y - offset - sa - 15 - }); - macro("hd", { + }) + macro('hd', { from: points.placketTopEdge, to: points.shoulder, y: points.placketTopEdge.y - offset - sa - 30 - }); - points.button0 = points.placketTopEdge; - let j; + }) + points.button0 = points.placketTopEdge + let j for (let i = 0; i < options.buttons; i++) { - j = i + 1; - macro("vd", { - from: points["button" + j], - to: points["button" + i], + j = i + 1 + macro('vd', { + from: points['button' + j], + to: points['button' + i], x: points.placketTopEdge.x - 15 - }); + }) } - macro("vd", { + macro('vd', { from: points.placketBottomEdge, to: points.placketTopEdge, x: points.placketTopEdge.x - 30 - }); + }) } - return part; -}; + return part +} diff --git a/packages/simon/src/frontleft-classic-seperate.js b/packages/simon/src/frontleft-classic-seperate.js index 874c247b234..5aadcc5b316 100644 --- a/packages/simon/src/frontleft-classic-seperate.js +++ b/packages/simon/src/frontleft-classic-seperate.js @@ -11,9 +11,9 @@ export default part => { paperless, macro, options - } = part.shorthand(); + } = part.shorthand() - let fold = options.buttonholePlacketFoldWidth; + let fold = options.buttonholePlacketFoldWidth points.neckEdge = utils.lineIntersectsCurve( new Point(points.cfNeck.x + fold * 2, points.cfNeck.y + 20), new Point(points.cfNeck.x + fold * 2, points.cfNeck.y - 20), @@ -21,66 +21,66 @@ export default part => { points.cfNeckCp1, points.neckCp2Front, points.neck - ); - points.hemEdge = new Point(points.neckEdge.x, points.cfHem.y); + ) + points.hemEdge = new Point(points.neckEdge.x, points.cfHem.y) - paths.seam = paths.seam.split(points.neckEdge)[0]; - paths.seam.ops[0].to = points.hemEdge; - paths.seam.close().attr("class", "fabric"); + paths.seam = paths.seam.split(points.neckEdge)[0] + paths.seam.ops[0].to = points.hemEdge + paths.seam.close().attr('class', 'fabric') // Complete pattern? if (complete) { // Title - macro("title", { at: points.title, nr: "2a", title: "frontLeft" }); + macro('title', { at: points.title, nr: '2a', title: 'frontLeft' }) - delete snippets["cfWaist-notch"]; - delete snippets["cfHips-notch"]; - delete snippets["cfArmhole-notch"]; - points.edgeArmhole = new Point(points.neckEdge.x, points.armhole.y); - points.edgeWaist = new Point(points.neckEdge.x, points.waist.y); - points.edgeHips = new Point(points.neckEdge.x, points.hips.y); - macro("sprinkle", { - snippet: "notch", - on: ["edgeArmhole", "edgeWaist", "edgeHips"] - }); + delete snippets['cfWaist-notch'] + delete snippets['cfHips-notch'] + delete snippets['cfArmhole-notch'] + points.edgeArmhole = new Point(points.neckEdge.x, points.armhole.y) + points.edgeWaist = new Point(points.neckEdge.x, points.waist.y) + points.edgeHips = new Point(points.neckEdge.x, points.hips.y) + macro('sprinkle', { + snippet: 'notch', + on: ['edgeArmhole', 'edgeWaist', 'edgeHips'] + }) if (sa) { - paths.saFromArmhole.end().x = points.neckEdge.x - sa; - paths.hemSa.start().x = points.neckEdge.x - sa; + paths.saFromArmhole.end().x = points.neckEdge.x - sa + paths.hemSa.start().x = points.neckEdge.x - sa paths.saClosure = new Path() .move(paths.saFromArmhole.end()) .line(paths.hemSa.start()) - .attr("class", "fabric sa"); + .attr('class', 'fabric sa') } } // Paperless? if (paperless) { - macro("hd", { + macro('hd', { from: points.neckEdge, to: points.neck, y: points.neck.y - sa - 15 - }); - macro("hd", { + }) + macro('hd', { from: points.neckEdge, to: points.shoulder, y: points.neck.y - sa - 30 - }); - macro("vd", { + }) + macro('vd', { from: points.neckEdge, to: points.neck, x: points.neckEdge.x - sa - 15 - }); - macro("vd", { + }) + macro('vd', { from: points.hemEdge, to: points.neck, x: points.neckEdge.x - sa - 30 - }); - for (let pid of ["Armhole", "Waist", "Hips"]) { - macro("hd", { - from: points["edge" + pid], + }) + for (let pid of ['Armhole', 'Waist', 'Hips']) { + macro('hd', { + from: points['edge' + pid], to: points[pid.toLowerCase()] - }); + }) } } - return part; -}; + return part +} diff --git a/packages/simon/src/frontleft-seamless.js b/packages/simon/src/frontleft-seamless.js index 5967948bc7b..9dee4ae72f2 100644 --- a/packages/simon/src/frontleft-seamless.js +++ b/packages/simon/src/frontleft-seamless.js @@ -1,29 +1,20 @@ -import { addButtonHoles } from "./shared"; +import { addButtonHoles } from './shared' export default part => { - let { - sa, - points, - Path, - paths, - complete, - paperless, - macro, - options - } = part.shorthand(); - let width = options.buttonholePlacketWidth; - points.placketCfNeck = points.cfNeck; - points.placketTopFold1 = points.cfNeck.shift(180, width / 2); - points.placketTopFold2 = points.cfNeck.shift(180, width * 1.5); - points.placketTopEdge = points.cfNeck.shift(180, width * 2.5); - points.placketBottomFold1 = points.cfHem.shift(180, width / 2); - points.placketBottomFold2 = points.cfHem.shift(180, width * 1.5); - points.placketBottomEdge = points.cfHem.shift(180, width * 2.5); + let { sa, points, Path, paths, complete, paperless, macro, options } = part.shorthand() + let width = options.buttonholePlacketWidth + points.placketCfNeck = points.cfNeck + points.placketTopFold1 = points.cfNeck.shift(180, width / 2) + points.placketTopFold2 = points.cfNeck.shift(180, width * 1.5) + points.placketTopEdge = points.cfNeck.shift(180, width * 2.5) + points.placketBottomFold1 = points.cfHem.shift(180, width / 2) + points.placketBottomFold2 = points.cfHem.shift(180, width * 1.5) + points.placketBottomEdge = points.cfHem.shift(180, width * 2.5) paths.seam .line(points.placketTopEdge) .line(points.placketBottomEdge) - .close(); + .close() // Complete pattern? if (complete) { @@ -31,32 +22,32 @@ export default part => { paths.frontCenter = new Path() .move(points.cfNeck) .line(points.cfHem) - .attr("class", "help"); + .attr('class', 'help') paths.placketFold1 = new Path() .move(points.placketTopFold1) .line(points.placketBottomFold1) - .attr("class", "dotted"); + .attr('class', 'dotted') paths.placketFold2 = new Path() .move(points.placketTopFold2) .line(points.placketBottomFold2) - .attr("class", "dotted"); - macro("sprinkle", { - snippet: "notch", + .attr('class', 'dotted') + macro('sprinkle', { + snippet: 'notch', on: [ - "cfNeck", - "cfHem", - "placketTopFold1", - "placketTopFold2", - "placketBottomFold1", - "placketBottomFold2" + 'cfNeck', + 'cfHem', + 'placketTopFold1', + 'placketTopFold2', + 'placketBottomFold1', + 'placketBottomFold2' ] - }); + }) // Buttons - addButtonHoles(part, "cfNeck"); + addButtonHoles(part, 'cfNeck') // Title - macro("title", { at: points.title, nr: 2, title: "frontLeft" }); + macro('title', { at: points.title, nr: 2, title: 'frontLeft' }) if (sa) { paths.saFromArmhole @@ -64,46 +55,41 @@ export default part => { .line(points.placketTopEdge) .move(points.placketBottomEdge) .line(points.placketBottomEdge.shift(-90, 3 * sa)) - .line(paths.hemSa.start()); + .line(paths.hemSa.start()) } } // Paperless? if (paperless) { - let offset = 0; - for (let pid of [ - "placketBottomFold2", - "placketBottomFold1", - "cfHem", - "hips" - ]) { - offset += 15; - macro("hd", { + let offset = 0 + for (let pid of ['placketBottomFold2', 'placketBottomFold1', 'cfHem', 'hips']) { + offset += 15 + macro('hd', { from: points.placketBottomEdge, to: points[pid], y: points.placketBottomEdge.y + offset + 3 * sa - }); + }) } - macro("hd", { + macro('hd', { from: points.placketTopEdge, to: points.neck, y: points.neck.y - 15 - sa - }); - points.button0 = points.placketTopEdge; - let j; + }) + points.button0 = points.placketTopEdge + let j for (let i = 0; i < options.buttons; i++) { - j = i + 1; - macro("vd", { - from: points["button" + j], - to: points["button" + i], + j = i + 1 + macro('vd', { + from: points['button' + j], + to: points['button' + i], x: points.placketTopEdge.x - 15 - }); + }) } - macro("vd", { + macro('vd', { from: points.placketBottomEdge, to: points.placketTopEdge, x: points.placketTopEdge.x - 30 - }); + }) } - return part; -}; + return part +} diff --git a/packages/simon/src/frontleft.js b/packages/simon/src/frontleft.js index f1857d42ed5..68ad31e24c6 100644 --- a/packages/simon/src/frontleft.js +++ b/packages/simon/src/frontleft.js @@ -1,23 +1,23 @@ -import { frontDimensions } from "./shared"; -import frontLeftClassicSeperate from "./frontleft-classic-seperate"; -import frontLeftClassicCuton from "./frontleft-classic-cuton"; -import frontLeftSeamless from "./frontleft-seamless"; +import { frontDimensions } from './shared' +import frontLeftClassicSeperate from './frontleft-classic-seperate' +import frontLeftClassicCuton from './frontleft-classic-cuton' +import frontLeftSeamless from './frontleft-seamless' export default part => { - let { sa, options, complete, paperless, points, macro } = part.shorthand(); + let { sa, options, complete, paperless, points, macro } = part.shorthand() if (complete && paperless) { - frontDimensions(part, "left"); - macro("ld", { + frontDimensions(part, 'left') + macro('ld', { from: points.neck, to: points.shoulder, d: 15 + sa - }); + }) } - return options.buttonholePlacketStyle === "seamless" + return options.buttonholePlacketStyle === 'seamless' ? frontLeftSeamless(part) : options.seperateButtonholePlacket ? frontLeftClassicSeperate(part) - : frontLeftClassicCuton(part); -}; + : frontLeftClassicCuton(part) +} diff --git a/packages/simon/src/frontright-classic-cuton.js b/packages/simon/src/frontright-classic-cuton.js index 3edb6db1032..76d6e1490b9 100644 --- a/packages/simon/src/frontright-classic-cuton.js +++ b/packages/simon/src/frontright-classic-cuton.js @@ -1,4 +1,4 @@ -import { addButtons } from "./shared"; +import { addButtons } from './shared' export default part => { let { @@ -12,9 +12,9 @@ export default part => { paperless, macro, options - } = part.shorthand(); + } = part.shorthand() - let width = options.buttonPlacketWidth; + let width = options.buttonPlacketWidth points.placketTopIn = utils.lineIntersectsCurve( new Point(width / -2, points.cfNeck.y + 20), new Point(width / -2, points.cfNeck.y - 20), @@ -22,18 +22,18 @@ export default part => { points.cfNeckCp1, points.neckCp2Front, points.neck - ); - points.placketTopOut = points.cfNeck.shift(0, width / 2); - points.placketTopEdge = points.cfNeck.shift(0, width * 1.5); - points.placketBottomIn = points.cfHem.shift(180, width / 2); - points.placketBottomOut = points.cfHem.shift(0, width / 2); - points.placketBottomEdge = points.cfHem.shift(0, width * 1.5); + ) + points.placketTopOut = points.cfNeck.shift(0, width / 2) + points.placketTopEdge = points.cfNeck.shift(0, width * 1.5) + points.placketBottomIn = points.cfHem.shift(180, width / 2) + points.placketBottomOut = points.cfHem.shift(0, width / 2) + points.placketBottomEdge = points.cfHem.shift(0, width * 1.5) paths.seam .line(points.placketTopEdge) .line(points.placketBottomEdge) .line(points.cfHem) - .close(); + .close() // Complete pattern? if (complete) { @@ -41,91 +41,84 @@ export default part => { paths.frontCenter = new Path() .move(points.cfNeck) .line(points.cfHem) - .attr("class", "help"); + .attr('class', 'help') paths.placketInnerFold = new Path() .move(points.placketTopIn) .line(points.placketBottomIn) - .attr("class", "dotted"); + .attr('class', 'dotted') paths.placketOuterFold = new Path() .move(points.placketTopOut) .line(points.placketBottomOut) - .attr("class", "dotted"); - macro("sprinkle", { - snippet: "notch", + .attr('class', 'dotted') + macro('sprinkle', { + snippet: 'notch', on: [ - "placketTopIn", - "placketTopOut", - "cfNeck", - "placketBottomIn", - "placketBottomOut", - "cfHem" + 'placketTopIn', + 'placketTopOut', + 'cfNeck', + 'placketBottomIn', + 'placketBottomOut', + 'cfHem' ] - }); + }) // Buttons - addButtons(part); + addButtons(part) // Title - macro("title", { at: points.title, nr: 1, title: "frontRight" }); + macro('title', { at: points.title, nr: 1, title: 'frontRight' }) if (sa) { paths.saFromArmhole - .line( - new Point(points.placketTopEdge.x + sa, points.placketTopEdge.y - sa) - ) - .line( - new Point( - points.placketBottomEdge.x + sa, - points.placketBottomEdge.y + sa * 3 - ) - ) - .line(paths.hemSa.start()); + .line(new Point(points.placketTopEdge.x + sa, points.placketTopEdge.y - sa)) + .line(new Point(points.placketBottomEdge.x + sa, points.placketBottomEdge.y + sa * 3)) + .line(paths.hemSa.start()) } } // Paperless? if (paperless) { - macro("hd", { + macro('hd', { from: points.placketTopOut, to: points.placketTopEdge, y: points.placketTopEdge.y - 15 - sa - }); - macro("hd", { + }) + macro('hd', { from: points.cfNeck, to: points.placketTopEdge, y: points.placketTopEdge.y - 30 - sa - }); - macro("hd", { + }) + macro('hd', { from: points.placketTopIn, to: points.placketTopEdge, y: points.placketTopEdge.y - 45 - sa - }); - macro("hd", { + }) + macro('hd', { from: points.neck, to: points.placketTopEdge, y: points.neck.y - 15 - sa - }); - macro("hd", { + }) + macro('hd', { from: points.shoulder, to: points.placketTopEdge, y: points.neck.y - 30 - sa - }); - points.button0 = points.placketTopEdge; - let j; + }) + points.button0 = points.placketTopEdge + let j for (let i = 0; i < options.buttons; i++) { - j = i + 1; - macro("vd", { - from: points["button" + j], - to: points["button" + i], + j = i + 1 + macro('vd', { + from: points['button' + j], + to: points['button' + i], x: points.placketTopEdge.x + 15 + sa - }); + }) } - macro("vd", { + macro('vd', { from: points.placketBottomEdge, to: points.placketTopEdge, x: points.placketTopEdge.x + 30 + sa - }); + }) } - return part; -}; + return part +} diff --git a/packages/simon/src/frontright-classic-seperate.js b/packages/simon/src/frontright-classic-seperate.js index 0796b4d4eb5..f016465f949 100644 --- a/packages/simon/src/frontright-classic-seperate.js +++ b/packages/simon/src/frontright-classic-seperate.js @@ -1,17 +1,7 @@ export default part => { - let { - utils, - sa, - Point, - points, - paths, - complete, - paperless, - macro, - options - } = part.shorthand(); + let { utils, sa, Point, points, paths, complete, paperless, macro, options } = part.shorthand() - let width = options.buttonPlacketWidth; + let width = options.buttonPlacketWidth points.placketTopIn = utils.lineIntersectsCurve( new Point(width / -2, points.cfNeck.y + 20), new Point(width / -2, points.cfNeck.y - 20), @@ -19,55 +9,55 @@ export default part => { points.cfNeckCp1, points.neckCp2Front, points.neck - ); - points.placketBottomIn = points.cfHem.shift(180, width / 2); - paths.seam = paths.seam.split(points.placketTopIn)[0]; - paths.seam.ops[0].to = points.placketBottomIn; - paths.seam.close().attr("class", "fabric"); + ) + points.placketBottomIn = points.cfHem.shift(180, width / 2) + paths.seam = paths.seam.split(points.placketTopIn)[0] + paths.seam.ops[0].to = points.placketBottomIn + paths.seam.close().attr('class', 'fabric') // Complete pattern? if (complete) { // Title - macro("title", { at: points.title, nr: "1a", title: "rightFront" }); - delete snippets["cfWaist-notch"]; - delete snippets["cfHips-notch"]; - delete snippets["cfArmhole-notch"]; - points.edgeArmhole = new Point(points.placketTopIn.x, points.armhole.y); - points.edgeWaist = new Point(points.placketTopIn.x, points.waist.y); - points.edgeHips = new Point(points.placketTopIn.x, points.hips.y); + macro('title', { at: points.title, nr: '1a', title: 'rightFront' }) + delete snippets['cfWaist-notch'] + delete snippets['cfHips-notch'] + delete snippets['cfArmhole-notch'] + points.edgeArmhole = new Point(points.placketTopIn.x, points.armhole.y) + points.edgeWaist = new Point(points.placketTopIn.x, points.waist.y) + points.edgeHips = new Point(points.placketTopIn.x, points.hips.y) - if (sa) paths.saFromArmhole.line(paths.hemSa.start()); + if (sa) paths.saFromArmhole.line(paths.hemSa.start()) } // Paperless? if (paperless) { - macro("hd", { + macro('hd', { from: points.neck, to: points.placketTopIn, y: points.neck.y - sa - 15 - }); - macro("hd", { + }) + macro('hd', { from: points.shoulder, to: points.placketTopIn, y: points.neck.y - sa - 30 - }); - macro("vd", { + }) + macro('vd', { from: points.placketTopIn, to: points.neck, x: points.placketTopIn.x + sa + 15 - }); - macro("vd", { + }) + macro('vd', { from: points.placketBottomIn, to: points.placketTopIn, x: points.placketTopIn.x + sa + 15 - }); - for (let pid of ["Armhole", "Waist", "Hips"]) { - macro("hd", { - from: points["edge" + pid], + }) + for (let pid of ['Armhole', 'Waist', 'Hips']) { + macro('hd', { + from: points['edge' + pid], to: points[pid.toLowerCase()] - }); + }) } } - return part; -}; + return part +} diff --git a/packages/simon/src/frontright-seamless.js b/packages/simon/src/frontright-seamless.js index 61fa796b2ff..b3b6ea1afb3 100644 --- a/packages/simon/src/frontright-seamless.js +++ b/packages/simon/src/frontright-seamless.js @@ -1,30 +1,20 @@ -import { addButtons } from "./shared"; +import { addButtons } from './shared' export default part => { - let { - sa, - Point, - points, - Path, - paths, - complete, - paperless, - macro, - options - } = part.shorthand(); + let { sa, Point, points, Path, paths, complete, paperless, macro, options } = part.shorthand() - let width = options.buttonPlacketWidth; - points.placketTopFold1 = points.cfNeck.shift(0, width / 2); - points.placketTopFold2 = points.cfNeck.shift(0, width * 1.5); - points.placketTopEdge = points.cfNeck.shift(0, width * 2.5); - points.placketBottomFold1 = points.cfHem.shift(0, width / 2); - points.placketBottomFold2 = points.cfHem.shift(0, width * 1.5); - points.placketBottomEdge = points.cfHem.shift(0, width * 2.5); + let width = options.buttonPlacketWidth + points.placketTopFold1 = points.cfNeck.shift(0, width / 2) + points.placketTopFold2 = points.cfNeck.shift(0, width * 1.5) + points.placketTopEdge = points.cfNeck.shift(0, width * 2.5) + points.placketBottomFold1 = points.cfHem.shift(0, width / 2) + points.placketBottomFold2 = points.cfHem.shift(0, width * 1.5) + points.placketBottomEdge = points.cfHem.shift(0, width * 2.5) paths.seam .line(points.placketTopEdge) .line(points.placketBottomEdge) .line(points.cfHem) - .close(); + .close() // Complete pattern? if (complete) { @@ -32,32 +22,32 @@ export default part => { paths.frontCenter = new Path() .move(points.cfNeck) .line(points.cfHem) - .attr("class", "help"); + .attr('class', 'help') paths.placketFold1 = new Path() .move(points.placketTopFold1) .line(points.placketBottomFold1) - .attr("class", "dotted"); + .attr('class', 'dotted') paths.placketFold2 = new Path() .move(points.placketTopFold2) .line(points.placketBottomFold2) - .attr("class", "dotted"); - macro("sprinkle", { - snippet: "notch", + .attr('class', 'dotted') + macro('sprinkle', { + snippet: 'notch', on: [ - "placketTopFold1", - "placketTopFold2", - "placketBottomFold1", - "placketBottomFold2", - "cfNeck", - "cfHem" + 'placketTopFold1', + 'placketTopFold2', + 'placketBottomFold1', + 'placketBottomFold2', + 'cfNeck', + 'cfHem' ] - }); + }) // Buttons - addButtons(part); + addButtons(part) // Title - macro("title", { at: points.title, nr: 1, title: "frontRight" }); + macro('title', { at: points.title, nr: 1, title: 'frontRight' }) if (sa) { paths.saFromArmhole @@ -65,7 +55,7 @@ export default part => { .line(points.placketTopEdge) .move(points.placketBottomEdge) .line(points.placketBottomEdge.shift(-90, sa * 3)) - .line(paths.hemSa.start()); + .line(paths.hemSa.start()) } } @@ -73,5 +63,5 @@ export default part => { if (paperless) { } - return part; -}; + return part +} diff --git a/packages/simon/src/frontright.js b/packages/simon/src/frontright.js index 974c8eabf46..3dab4cf5b97 100644 --- a/packages/simon/src/frontright.js +++ b/packages/simon/src/frontright.js @@ -1,37 +1,29 @@ -import { frontDimensions } from "./shared"; -import frontRightClassicSeperate from "./frontright-classic-seperate"; -import frontRightClassicCuton from "./frontright-classic-cuton"; -import frontRightSeamless from "./frontright-seamless"; +import { frontDimensions } from './shared' +import frontRightClassicSeperate from './frontright-classic-seperate' +import frontRightClassicCuton from './frontright-classic-cuton' +import frontRightSeamless from './frontright-seamless' export default part => { - let { - sa, - options, - complete, - paperless, - points, - macro, - paths - } = part.shorthand(); - macro("flip"); + let { sa, options, complete, paperless, points, macro, paths } = part.shorthand() + macro('flip') if (complete) { - points.scalebox = points.waist.shiftFractionTowards(points.cfWaist, 0.5); - macro("scalebox", { at: points.scalebox }); + points.scalebox = points.waist.shiftFractionTowards(points.cfWaist, 0.5) + macro('scalebox', { at: points.scalebox }) if (paperless) { - frontDimensions(part, "right"); - macro("ld", { + frontDimensions(part, 'right') + macro('ld', { from: points.shoulder, to: points.neck, d: 15 + sa - }); - paths.hemSa.attr("data-text-dy", 7, true); - paths.saFrench.attr("data-text-dy", 7, true); + }) + paths.hemSa.attr('data-text-dy', 7, true) + paths.saFrench.attr('data-text-dy', 7, true) } } - return options.buttonPlacketStyle === "seamless" + return options.buttonPlacketStyle === 'seamless' ? frontRightSeamless(part) : options.seperateButtonPlacket ? frontRightClassicSeperate(part) - : frontRightClassicCuton(part); -}; + : frontRightClassicCuton(part) +} diff --git a/packages/simon/src/index.js b/packages/simon/src/index.js index 0f35d2725ae..8e7b0f6ba38 100644 --- a/packages/simon/src/index.js +++ b/packages/simon/src/index.js @@ -1,57 +1,53 @@ -import freesewing from "@freesewing/core"; -import Brian from "@freesewing/brian"; -import plugins from "@freesewing/plugin-bundle"; -import flipPlugin from "@freesewing/plugin-flip"; -import buttonPlugin from "@freesewing/plugin-buttons"; -import config from "../config"; +import freesewing from '@freesewing/core' +import Brian from '@freesewing/brian' +import plugins from '@freesewing/plugin-bundle' +import flipPlugin from '@freesewing/plugin-flip' +import buttonPlugin from '@freesewing/plugin-buttons' +import config from '../config' // Parts -import draftBack from "./back"; -import draftFront from "./front"; -import draftFrontRight from "./frontright"; -import draftButtonPlacket from "./buttonplacket"; -import draftFrontLeft from "./frontleft"; -import draftButtonholePlacket from "./buttonholeplacket"; -import draftYoke from "./yoke"; -import draftSleeve from "./sleeve"; -import draftCollarStand from "./collarstand"; -import draftCollar from "./collar"; -import draftSleevePlacketUnderlap from "./sleeveplacket-underlap"; -import draftSleevePlacketOverlap from "./sleeveplacket-overlap"; -import draftCuff from "./cuff"; +import draftBack from './back' +import draftFront from './front' +import draftFrontRight from './frontright' +import draftButtonPlacket from './buttonplacket' +import draftFrontLeft from './frontleft' +import draftButtonholePlacket from './buttonholeplacket' +import draftYoke from './yoke' +import draftSleeve from './sleeve' +import draftCollarStand from './collarstand' +import draftCollar from './collar' +import draftSleevePlacketUnderlap from './sleeveplacket-underlap' +import draftSleevePlacketOverlap from './sleeveplacket-overlap' +import draftCuff from './cuff' // Create design -const Pattern = new freesewing.Design(config, [ - plugins, - flipPlugin, - buttonPlugin -]); +const Pattern = new freesewing.Design(config, [plugins, flipPlugin, buttonPlugin]) // Attach draft methods to prototype Pattern.prototype.draftBase = function(part) { - return new Brian(this.settings).draftBase(part); -}; + return new Brian(this.settings).draftBase(part) +} Pattern.prototype.draftFrontBase = function(part) { - return new Brian(this.settings).draftFront(part); -}; + return new Brian(this.settings).draftFront(part) +} Pattern.prototype.draftBackBase = function(part) { - return new Brian(this.settings).draftBack(part); -}; + return new Brian(this.settings).draftBack(part) +} Pattern.prototype.draftSleeveBase = function(part) { - let brian = new Brian(this.settings); - return brian.draftSleeve(brian.draftSleevecap(part)); -}; -Pattern.prototype.draftBack = draftBack; -Pattern.prototype.draftFront = draftFront; -Pattern.prototype.draftFrontRight = draftFrontRight; -Pattern.prototype.draftButtonPlacket = draftButtonPlacket; -Pattern.prototype.draftFrontLeft = draftFrontLeft; -Pattern.prototype.draftButtonholePlacket = draftButtonholePlacket; -Pattern.prototype.draftYoke = draftYoke; -Pattern.prototype.draftSleeve = draftSleeve; -Pattern.prototype.draftCollarStand = draftCollarStand; -Pattern.prototype.draftCollar = draftCollar; -Pattern.prototype.draftSleevePlacketUnderlap = draftSleevePlacketUnderlap; -Pattern.prototype.draftSleevePlacketOverlap = draftSleevePlacketOverlap; -Pattern.prototype.draftCuff = draftCuff; + let brian = new Brian(this.settings) + return brian.draftSleeve(brian.draftSleevecap(part)) +} +Pattern.prototype.draftBack = draftBack +Pattern.prototype.draftFront = draftFront +Pattern.prototype.draftFrontRight = draftFrontRight +Pattern.prototype.draftButtonPlacket = draftButtonPlacket +Pattern.prototype.draftFrontLeft = draftFrontLeft +Pattern.prototype.draftButtonholePlacket = draftButtonholePlacket +Pattern.prototype.draftYoke = draftYoke +Pattern.prototype.draftSleeve = draftSleeve +Pattern.prototype.draftCollarStand = draftCollarStand +Pattern.prototype.draftCollar = draftCollar +Pattern.prototype.draftSleevePlacketUnderlap = draftSleevePlacketUnderlap +Pattern.prototype.draftSleevePlacketOverlap = draftSleevePlacketOverlap +Pattern.prototype.draftCuff = draftCuff -export default Pattern; +export default Pattern diff --git a/packages/simon/src/shared.js b/packages/simon/src/shared.js index 84ebcd50a5a..9d8bbc51db7 100644 --- a/packages/simon/src/shared.js +++ b/packages/simon/src/shared.js @@ -1,357 +1,301 @@ export const calculateReduction = function(part) { - let { store, measurements, options } = part.shorthand(); - if (store.get("reduction") === true) return; + let { store, measurements, options } = part.shorthand() + if (store.get('reduction') === true) return - let chest = measurements.chestCircumference * (1 + options.chestEase); - let waist = measurements.naturalWaist * (1 + options.waistEase); - let hips = measurements.hipsCircumference * (1 + options.hipsEase); - let waistReduction = chest - waist; - let hipsReduction = chest - hips; + let chest = measurements.chestCircumference * (1 + options.chestEase) + let waist = measurements.naturalWaist * (1 + options.waistEase) + let hips = measurements.hipsCircumference * (1 + options.hipsEase) + let waistReduction = chest - waist + let hipsReduction = chest - hips // If your waist > chest, this pattern is not going to work for you as-is. - if (waistReduction < 0) waistReduction = 0; - if (hipsReduction < 0) hipsReduction = 0; - store.set("waistReduction", waistReduction); - store.set("hipsReduction", hipsReduction); - store.set("reduction", true); -}; + if (waistReduction < 0) waistReduction = 0 + if (hipsReduction < 0) hipsReduction = 0 + store.set('waistReduction', waistReduction) + store.set('hipsReduction', hipsReduction) + store.set('reduction', true) +} -export const addButtons = function( - part, - origin = "cfNeck", - snippet = "button" -) { - let { points, options, snippets, Snippet } = part.shorthand(); - let len = points.cfNeck.dist(points.cfHips) * (1 - options.buttonFreeLength); +export const addButtons = function(part, origin = 'cfNeck', snippet = 'button') { + let { points, options, snippets, Snippet } = part.shorthand() + let len = points.cfNeck.dist(points.cfHips) * (1 - options.buttonFreeLength) for (let i = 1; i <= options.buttons; i++) { - points["button" + i] = points[origin].shift( - -90, - (len / options.buttons) * i - ); - snippets[snippet + i] = new Snippet(snippet, points["button" + i]); + points['button' + i] = points[origin].shift(-90, (len / options.buttons) * i) + snippets[snippet + i] = new Snippet(snippet, points['button' + i]) } if (options.extraTopButton) - snippets["top" + snippet] = new Snippet( + snippets['top' + snippet] = new Snippet( snippet, points[origin].shift(-90, len / options.buttons / 2) - ); -}; + ) +} -export const addButtonHoles = (part, origin) => - addButtons(part, origin, "buttonhole"); +export const addButtonHoles = (part, origin) => addButtons(part, origin, 'buttonhole') export const draftBarrelCuff = part => { - let { store, points, measurements, options, Point } = part.shorthand(); - let height = measurements.shoulderToWrist * options.cuffLength; - let width = - measurements.wristCircumference * - (1 + options.cuffEase + options.cuffOverlap); - store.set("cuffHeight", height); - points.topLeft = new Point(0, 0); - points.topRight = new Point(width, 0); - points.bottomLeft = new Point(0, height); - points.bottomRight = new Point(width, height); + let { store, points, measurements, options, Point } = part.shorthand() + let height = measurements.shoulderToWrist * options.cuffLength + let width = measurements.wristCircumference * (1 + options.cuffEase + options.cuffOverlap) + store.set('cuffHeight', height) + points.topLeft = new Point(0, 0) + points.topRight = new Point(width, 0) + points.bottomLeft = new Point(0, height) + points.bottomRight = new Point(width, height) - return part; -}; + return part +} export const decorateBarrelCuff = part => { - let { - macro, - snippets, - Snippet, - points, - measurements, - options, - Point - } = part.shorthand(); + let { macro, snippets, Snippet, points, measurements, options, Point } = part.shorthand() // Title - points.title = new Point(points.bottomRight.x / 2, points.bottomRight.y / 2); - macro("title", { + points.title = new Point(points.bottomRight.x / 2, points.bottomRight.y / 2) + macro('title', { nr: 11, - title: "cuff", + title: 'cuff', at: points.title, scale: 0.8 - }); + }) // Button and buttonhole - let margin = measurements.wristCircumference * options.cuffOverlap; - points.buttonLineTop = points.topRight.shift(180, margin / 2); - points.buttonLineBottom = points.bottomRight.shift(180, margin / 2); - points.buttonholeLineTop = points.topLeft.shift(0, margin / 2); - points.buttonholeLineBottom = points.bottomLeft.shift(0, margin / 2); + let margin = measurements.wristCircumference * options.cuffOverlap + points.buttonLineTop = points.topRight.shift(180, margin / 2) + points.buttonLineBottom = points.bottomRight.shift(180, margin / 2) + points.buttonholeLineTop = points.topLeft.shift(0, margin / 2) + points.buttonholeLineBottom = points.bottomLeft.shift(0, margin / 2) for (let i = 1; i <= options.cuffButtonRows; i++) { - points["button" + i] = points.buttonLineTop.shiftFractionTowards( + points['button' + i] = points.buttonLineTop.shiftFractionTowards( points.buttonLineBottom, (1 / (options.cuffButtonRows + 1)) * i - ); - snippets["button" + i] = new Snippet("button", points["button" + i]); - points["buttonhole" + i] = new Point( - points.buttonholeLineTop.x, - points["button" + i].y - ); - snippets["buttonhole" + i] = new Snippet( - "buttonhole", - points["buttonhole" + i] - ).attr("data-rotate", 90); + ) + snippets['button' + i] = new Snippet('button', points['button' + i]) + points['buttonhole' + i] = new Point(points.buttonholeLineTop.x, points['button' + i].y) + snippets['buttonhole' + i] = new Snippet('buttonhole', points['buttonhole' + i]).attr( + 'data-rotate', + 90 + ) if (options.barrelCuffNarrowButton) { - points["narrowButton" + i] = points["button" + i].shift(180, margin); - snippets["narrowButton" + i] = new Snippet( - "button", - points["narrowButton" + i] - ); + points['narrowButton' + i] = points['button' + i].shift(180, margin) + snippets['narrowButton' + i] = new Snippet('button', points['narrowButton' + i]) } } - return part; -}; + return part +} export const draftFrenchCuff = part => { - let { store, points, measurements, options, Point } = part.shorthand(); - let margin = measurements.wristCircumference * options.cuffOverlap; - let height = measurements.shoulderToWrist * options.cuffLength; + let { store, points, measurements, options, Point } = part.shorthand() + let margin = measurements.wristCircumference * options.cuffOverlap + let height = measurements.shoulderToWrist * options.cuffLength let width = measurements.wristCircumference * (1 + options.cuffEase + options.cuffOverlap + options.cuffDrape) + - margin / 2; - store.set("cuffHeight", height); - points.topLeft = new Point(0, 0); - points.topRight = new Point(width, 0); - points.midLeft = new Point(0, height); - points.midRight = new Point(width, height); - points.bottomLeft = new Point(0, height * 2); - points.bottomRight = new Point(width, height * 2); + margin / 2 + store.set('cuffHeight', height) + points.topLeft = new Point(0, 0) + points.topRight = new Point(width, 0) + points.midLeft = new Point(0, height) + points.midRight = new Point(width, height) + points.bottomLeft = new Point(0, height * 2) + points.bottomRight = new Point(width, height * 2) - return part; -}; + return part +} export const decorateFrenchCuff = part => { - let { - macro, - snippets, - Snippet, - points, - measurements, - options, - Point - } = part.shorthand(); + let { macro, snippets, Snippet, points, measurements, options, Point } = part.shorthand() // Title - points.title = new Point(points.bottomRight.x / 2, points.bottomRight.y / 2); - macro("title", { + points.title = new Point(points.bottomRight.x / 2, points.bottomRight.y / 2) + macro('title', { nr: 11, - title: "cuff", + title: 'cuff', at: points.title, scale: 0.8 - }); + }) // Buttonholes - let margin = measurements.wristCircumference * options.cuffOverlap; - points.buttonLineTop = points.topRight.shift(180, margin * 0.75); - points.buttonLineBottom = points.bottomRight.shift(180, margin * 0.75); - points.buttonholeLineTop = points.topLeft.shift(0, margin * 0.75); - points.buttonholeLineBottom = points.bottomLeft.shift(0, margin * 0.75); + let margin = measurements.wristCircumference * options.cuffOverlap + points.buttonLineTop = points.topRight.shift(180, margin * 0.75) + points.buttonLineBottom = points.bottomRight.shift(180, margin * 0.75) + points.buttonholeLineTop = points.topLeft.shift(0, margin * 0.75) + points.buttonholeLineBottom = points.bottomLeft.shift(0, margin * 0.75) - points.button1 = points.buttonLineTop.shiftFractionTowards( - points.buttonLineBottom, - 0.2 - ); - points.button2 = points.buttonLineTop.shiftFractionTowards( - points.buttonLineBottom, - 0.8 - ); - points.button3 = points.buttonholeLineTop.shiftFractionTowards( - points.buttonholeLineBottom, - 0.2 - ); - points.button4 = points.buttonholeLineTop.shiftFractionTowards( - points.buttonholeLineBottom, - 0.8 - ); - snippets.buttonhole1 = new Snippet("buttonhole", points.button1).attr( - "data-rotate", - 90 - ); - snippets.buttonhole2 = new Snippet("buttonhole", points.button2).attr( - "data-rotate", - 90 - ); - snippets.buttonhole3 = new Snippet("buttonhole", points.button3).attr( - "data-rotate", - 90 - ); - snippets.buttonhole4 = new Snippet("buttonhole", points.button4).attr( - "data-rotate", - 90 - ); + points.button1 = points.buttonLineTop.shiftFractionTowards(points.buttonLineBottom, 0.2) + points.button2 = points.buttonLineTop.shiftFractionTowards(points.buttonLineBottom, 0.8) + points.button3 = points.buttonholeLineTop.shiftFractionTowards(points.buttonholeLineBottom, 0.2) + points.button4 = points.buttonholeLineTop.shiftFractionTowards(points.buttonholeLineBottom, 0.8) + snippets.buttonhole1 = new Snippet('buttonhole', points.button1).attr('data-rotate', 90) + snippets.buttonhole2 = new Snippet('buttonhole', points.button2).attr('data-rotate', 90) + snippets.buttonhole3 = new Snippet('buttonhole', points.button3).attr('data-rotate', 90) + snippets.buttonhole4 = new Snippet('buttonhole', points.button4).attr('data-rotate', 90) - return part; -}; + return part +} export const paperlessBarrelCuff = part => { - let { sa, macro, points, options } = part.shorthand(); - macro("hd", { + let { sa, macro, points, options } = part.shorthand() + macro('hd', { from: points.buttonhole1, to: points.button1, y: points.bottomLeft.y + 15 + sa - }); - macro("hd", { + }) + macro('hd', { from: points.bottomLeft, to: points.bottomRight, y: points.bottomLeft.y + 30 + sa - }); - macro("vd", { + }) + macro('vd', { from: points.bottomLeft, to: points.topLeft.shift(0, 40), x: points.bottomLeft.x - 15 - sa - }); + }) if (options.barrelCuffNarrowButton) { - macro("hd", { + macro('hd', { from: points.narrowButton1, to: points.button1, y: points.topRight.y - 15 - sa - }); + }) } if (options.cuffButtonRows === 2) { - macro("vd", { + macro('vd', { from: points.button2, to: points.button1, x: points.topRight.x + 15 + sa - }); + }) } - return part; -}; + return part +} export const paperlessFrenchCuff = part => { - let { sa, macro, points } = part.shorthand(); - macro("hd", { + let { sa, macro, points } = part.shorthand() + macro('hd', { from: points.button4, to: points.button2, y: points.bottomLeft.y + 15 + sa - }); - macro("hd", { + }) + macro('hd', { from: points.midLeft, to: points.midRight, y: points.bottomLeft.y + 30 + sa - }); - macro("vd", { + }) + macro('vd', { from: points.button2, to: points.button1, x: points.topRight.x + 15 + sa - }); - macro("vd", { + }) + macro('vd', { from: points.bottomRight.shift(180, 40), to: points.topRight.shift(180, 40), x: points.topRight.x + 30 + sa - }); + }) - return part; -}; + return part +} -export const frontDimensions = (part, side = "left") => { - let { sa, options, paperless, points, macro, Path } = part.shorthand(); - let factor = side === "right" ? -1 : 1; - macro("banner", { - path: "hemSa", - text: ["hem", ": 3x", "seamAllowance"] - }); - macro("banner", { - path: "saFrench", - text: ["frenchSeam", ": 2x", "seamAllowance"] - }); +export const frontDimensions = (part, side = 'left') => { + let { sa, options, paperless, points, macro, Path } = part.shorthand() + let factor = side === 'right' ? -1 : 1 + macro('banner', { + path: 'hemSa', + text: ['hem', ': 3x', 'seamAllowance'] + }) + macro('banner', { + path: 'saFrench', + text: ['frenchSeam', ': 2x', 'seamAllowance'] + }) if (paperless) { - macro("pd", { + macro('pd', { path: new Path() .move(points.armholePitch) .curve(points.armholePitchCp2, points.shoulderCp1, points.shoulder), d: -15 * factor - }); - macro("vd", { + }) + macro('vd', { from: points.armhole, to: points.armholePitch, x: points.armhole.x + (15 + sa * 2) * factor - }); - macro("vd", { + }) + macro('vd', { from: points.armhole, to: points.shoulder, x: points.armhole.x + (30 + sa * 2) * factor - }); - macro("vd", { + }) + macro('vd', { from: points.armhole, to: points.neck, x: points.armhole.x + (45 + sa * 2) * factor - }); - macro("vd", { + }) + macro('vd', { from: points.waist, to: points.armhole, x: points.armhole.x + (15 + sa * 2) * factor - }); - macro("vd", { + }) + macro('vd', { from: points.hips, to: points.armhole, x: points.armhole.x + (30 + sa * 2) * factor - }); - if (options.hemStyle === "baseball") { - macro("vd", { + }) + if (options.hemStyle === 'baseball') { + macro('vd', { from: points.bballStart, to: points.bballEnd, x: points.hips.x + (15 + 2 * sa) * factor - }); - macro("vd", { + }) + macro('vd', { from: points.bballStart, to: points.hips, x: points.hips.x + (30 + 2 * sa) * factor - }); - macro("vd", { + }) + macro('vd', { from: points.bballStart, to: points.armhole, x: points.hips.x + (45 + 2 * sa) * factor - }); - macro("vd", { + }) + macro('vd', { from: points.bballStart, to: points.neck, x: points.hips.x + (60 + 2 * sa) * factor - }); - macro("hd", { + }) + macro('hd', { from: points.bballStart, to: points.bballEnd, y: points.bballStart.y + 15 + 3 * sa - }); - } else if (options.hemStyle === "slashed") { - macro("vd", { + }) + } else if (options.hemStyle === 'slashed') { + macro('vd', { from: points.slashEnd, to: points.slashStart, x: points.hips.x + (15 + 3 * sa) * factor - }); - macro("vd", { + }) + macro('vd', { from: points.slashEnd, to: points.hips, x: points.hips.x + (30 + 3 * sa) * factor - }); - macro("vd", { + }) + macro('vd', { from: points.slashEnd, to: points.armhole, x: points.hips.x + (45 + 3 * sa) * factor - }); - macro("vd", { + }) + macro('vd', { from: points.slashEnd, to: points.neck, x: points.hips.x + (60 + 3 * sa) * factor - }); + }) } else { - macro("vd", { + macro('vd', { from: points.hem, to: points.armhole, x: points.armhole.x + (45 + 2 * sa) * factor - }); - macro("vd", { + }) + macro('vd', { from: points.hem, to: points.neck, x: points.armhole.x + (60 + 2 * sa) * factor - }); + }) } } - return part; -}; + return part +} diff --git a/packages/simon/src/sleeve.js b/packages/simon/src/sleeve.js index 7502674b771..c446847408e 100644 --- a/packages/simon/src/sleeve.js +++ b/packages/simon/src/sleeve.js @@ -1,14 +1,14 @@ export default part => { - part.paths = {}; // This removed paperless dimensions from brian block + part.paths = {} // This removed paperless dimensions from brian block for (let pid of [ - "__scaleboxLead", - "__scaleboxMetric", - "__scaleboxImperial", - "__scaleboxText", - "__scaleboxTitle", - "__scaleboxLink" + '__scaleboxLead', + '__scaleboxMetric', + '__scaleboxImperial', + '__scaleboxText', + '__scaleboxTitle', + '__scaleboxLink' ]) - delete part.points[pid]; + delete part.points[pid] let { measurements, sa, @@ -20,85 +20,67 @@ export default part => { paperless, macro, options - } = part.shorthand(); + } = part.shorthand() // Sleeve width depends on cuff style - let width = - measurements.wristCircumference * - (1 + options.cuffEase + options.cuffOverlap); + let width = measurements.wristCircumference * (1 + options.cuffEase + options.cuffOverlap) if ( - options.cuffStyle === "straightFrenchcuff" || - options.cuffStyle === "roundedFrenchcuff" || - options.cuffStyle === "angledFrenchCuff" + options.cuffStyle === 'straightFrenchcuff' || + options.cuffStyle === 'roundedFrenchcuff' || + options.cuffStyle === 'angledFrenchCuff' ) - width = - measurements.wristCircumference * - (1 + options.cuffEase + options.cuffOverlap * 1.5); - points.wristRight.x = width / 2; - points.wristLeft.x = width / -2; - let cuffLength = measurements.shoulderToWrist * options.cuffLength; - points.wristRight = points.wristRight.shift(90, cuffLength); - points.wristLeft = points.wristLeft.shift(90, cuffLength); + width = measurements.wristCircumference * (1 + options.cuffEase + options.cuffOverlap * 1.5) + points.wristRight.x = width / 2 + points.wristLeft.x = width / -2 + let cuffLength = measurements.shoulderToWrist * options.cuffLength + points.wristRight = points.wristRight.shift(90, cuffLength) + points.wristLeft = points.wristLeft.shift(90, cuffLength) - points.cuffMid = new Point(0, points.wristLeft.y); - points.cuffLeftMid = points.cuffMid.shiftFractionTowards( - points.wristLeft, - 0.5 - ); - points.cuffRightMid = points.cuffMid.shiftFractionTowards( - points.wristRight, - 0.5 - ); - points.cuffLeftCusp = points.cuffLeftMid.shift(90, width / 50); - points.cuffRightCusp = points.cuffRightMid.shift(-90, width / 50); - points.cuffLeftCuspCp1 = points.cuffLeftCusp.shift(180, width / 10); - points.cuffLeftCuspCp2 = points.cuffLeftCusp.shift(0, width / 10); - points.cuffRightCuspCp1 = points.cuffRightCusp.shift(180, width / 10); - points.cuffRightCuspCp2 = points.cuffRightCusp.shift(0, width / 10); + points.cuffMid = new Point(0, points.wristLeft.y) + points.cuffLeftMid = points.cuffMid.shiftFractionTowards(points.wristLeft, 0.5) + points.cuffRightMid = points.cuffMid.shiftFractionTowards(points.wristRight, 0.5) + points.cuffLeftCusp = points.cuffLeftMid.shift(90, width / 50) + points.cuffRightCusp = points.cuffRightMid.shift(-90, width / 50) + points.cuffLeftCuspCp1 = points.cuffLeftCusp.shift(180, width / 10) + points.cuffLeftCuspCp2 = points.cuffLeftCusp.shift(0, width / 10) + points.cuffRightCuspCp1 = points.cuffRightCusp.shift(180, width / 10) + points.cuffRightCuspCp2 = points.cuffRightCusp.shift(0, width / 10) // Cuff pleats - let drape = options.cuffDrape * measurements.shoulderToWrist; - let pleats = 0; - let pleatLength = measurements.shoulderToWrist * 0.15; + let drape = options.cuffDrape * measurements.shoulderToWrist + let pleats = 0 + let pleatLength = measurements.shoulderToWrist * 0.15 if (drape > 0) { - pl; + pl let shiftRight = [ - "cuffRightCuspCp1", - "cuffRightCusp", - "cuffRightCuspCp2", - "wristRight", - "cuffRightMid" - ]; - let shiftLeft = [ - "cuffLeftCuspCp1", - "cuffLeftCusp", - "cuffLeftCuspCp2", - "wristLeft" - ]; - if (drape > 20) pleats = 2; - else pleats = 1; - for (let id of shiftRight) - points[id] = points[id].shift(0, drape / (2 * pleats)); - for (let id of shiftLeft) - points[id] = points[id].shift(180, drape / (2 * pleats)); - points.cuffPleat1Fold = points.cuffMid.shift(0, drape / (2 * pleats)); - points.cuffPleat1Edge = points.cuffMid.shift(0, drape / pleats); - points.cuffMidTop = points.cuffMid.shift(90, pleatLength); - points.cuffPleat1FoldTop = points.cuffPleat1Fold.shift(90, pleatLength); - points.cuffPleat1EdgeTop = points.cuffPleat1Edge.shift(90, pleatLength); + 'cuffRightCuspCp1', + 'cuffRightCusp', + 'cuffRightCuspCp2', + 'wristRight', + 'cuffRightMid' + ] + let shiftLeft = ['cuffLeftCuspCp1', 'cuffLeftCusp', 'cuffLeftCuspCp2', 'wristLeft'] + if (drape > 20) pleats = 2 + else pleats = 1 + for (let id of shiftRight) points[id] = points[id].shift(0, drape / (2 * pleats)) + for (let id of shiftLeft) points[id] = points[id].shift(180, drape / (2 * pleats)) + points.cuffPleat1Fold = points.cuffMid.shift(0, drape / (2 * pleats)) + points.cuffPleat1Edge = points.cuffMid.shift(0, drape / pleats) + points.cuffMidTop = points.cuffMid.shift(90, pleatLength) + points.cuffPleat1FoldTop = points.cuffPleat1Fold.shift(90, pleatLength) + points.cuffPleat1EdgeTop = points.cuffPleat1Edge.shift(90, pleatLength) if (pleats === 2) { - let moreRight = ["cuffRightCuspCp2", "wristRight"]; - let shift = shiftRight.concat(shiftLeft); + let moreRight = ['cuffRightCuspCp2', 'wristRight'] + let shift = shiftRight.concat(shiftLeft) for (let id of shift) { - if (moreRight.indexOf(id) === -1) - points[id] = points[id].shift(180, drape / 4); - else points[id] = points[id].shift(0, drape / 4); + if (moreRight.indexOf(id) === -1) points[id] = points[id].shift(180, drape / 4) + else points[id] = points[id].shift(0, drape / 4) } - points.cuffPleat2Fold = points.cuffRightCusp.shift(0, drape / 4); - points.cuffPleat2Edge = points.cuffRightCusp.shift(0, drape / 2); - points.cuffPleat2FoldTop = points.cuffPleat2Fold.shift(90, pleatLength); - points.cuffPleat2EdgeTop = points.cuffPleat2Edge.shift(90, pleatLength); - points.cuffPleat2Top = points.cuffRightCusp.shift(90, pleatLength); + points.cuffPleat2Fold = points.cuffRightCusp.shift(0, drape / 4) + points.cuffPleat2Edge = points.cuffRightCusp.shift(0, drape / 2) + points.cuffPleat2FoldTop = points.cuffPleat2Fold.shift(90, pleatLength) + points.cuffPleat2EdgeTop = points.cuffPleat2Edge.shift(90, pleatLength) + points.cuffPleat2Top = points.cuffRightCusp.shift(90, pleatLength) } } @@ -109,41 +91,39 @@ export default part => { .curve(points.capQ1Cp2, points.capQ2Cp1, points.capQ2) .curve(points.capQ2Cp2, points.capQ3Cp1, points.capQ3) .curve(points.capQ3Cp2, points.capQ4Cp1, points.capQ4) - .curve_(points.capQ4Cp2, points.bicepsLeft); - paths.frenchBase.render = false; + .curve_(points.capQ4Cp2, points.bicepsLeft) + paths.frenchBase.render = false - paths.saBase = new Path().move(points.bicepsLeft).line(points.wristLeft); - paths.saBase.render = false; + paths.saBase = new Path().move(points.bicepsLeft).line(points.wristLeft) + paths.saBase.render = false paths.cuffBase = new Path() .move(points.wristLeft) - ._curve(points.cuffLeftCuspCp1, points.cuffLeftCusp); + ._curve(points.cuffLeftCuspCp1, points.cuffLeftCusp) if (pleats > 0) { - paths.cuffBase - .curve_(points.cuffLeftCuspCp2, points.cuffMid) - .line(points.cuffPleat1Edge); + paths.cuffBase.curve_(points.cuffLeftCuspCp2, points.cuffMid).line(points.cuffPleat1Edge) } - paths.cuffBase._curve(points.cuffRightCuspCp1, points.cuffRightCusp); - if (pleats === 2) paths.cuffBase.line(points.cuffPleat2Edge); - paths.cuffBase.curve_(points.cuffRightCuspCp2, points.wristRight); - paths.cuffBase.render = false; + paths.cuffBase._curve(points.cuffRightCuspCp1, points.cuffRightCusp) + if (pleats === 2) paths.cuffBase.line(points.cuffPleat2Edge) + paths.cuffBase.curve_(points.cuffRightCuspCp2, points.wristRight) + paths.cuffBase.render = false paths.seam = paths.frenchBase .clone() .line(points.wristLeft) .join(paths.cuffBase) - .attr("class", "fabric"); + .attr('class', 'fabric') // Complete pattern? if (complete) { points.placketEnd = points.cuffLeftCusp.shift( 90, options.sleevePlacketLength * measurements.shoulderToWrist - ); + ) paths.placketCut = new Path() .move(points.cuffLeftCusp) .line(points.placketEnd) - .attr("class", "fabric"); + .attr('class', 'fabric') if (pleats > 0) { paths.pleats = new Path() .move(points.cuffMid) @@ -151,7 +131,7 @@ export default part => { .move(points.cuffPleat1Fold) .line(points.cuffPleat1FoldTop) .move(points.cuffPleat1Edge) - .line(points.cuffPleat1EdgeTop); + .line(points.cuffPleat1EdgeTop) if (pleats === 2) { paths.pleats .move(points.cuffRightCusp) @@ -159,56 +139,56 @@ export default part => { .move(points.cuffPleat2Fold) .line(points.cuffPleat2FoldTop) .move(points.cuffPleat2Edge) - .line(points.cuffPleat2EdgeTop); + .line(points.cuffPleat2EdgeTop) } - paths.pleats.attr("class", "dotted"); + paths.pleats.attr('class', 'dotted') } - macro("title", { at: points.centerBiceps, nr: 5, title: "sleeve" }); - macro("grainline", { from: points.cuffMid, to: points.sleeveTip }); + macro('title', { at: points.centerBiceps, nr: 5, title: 'sleeve' }) + macro('grainline', { from: points.cuffMid, to: points.sleeveTip }) if (sa) { - paths.sa = paths.frenchBase.offset(sa * 2); - paths.frenchSa = paths.sa.clone(); + paths.sa = paths.frenchBase.offset(sa * 2) + paths.frenchSa = paths.sa.clone() paths.sa = paths.sa .join(paths.saBase.offset(sa)) .join(paths.cuffBase.offset(sa)) .close() - .attr("class", "fabric sa"); - macro("banner", { - path: "frenchSa", - text: ["frenchSean", ": 2x", "seamAllowance"] - }); + .attr('class', 'fabric sa') + macro('banner', { + path: 'frenchSa', + text: ['frenchSean', ': 2x', 'seamAllowance'] + }) } } // Paperless? if (paperless) { - macro("hd", { + macro('hd', { from: points.backNotch, to: points.sleeveTip, y: points.sleeveTip.y - 15 - sa * 2 - }); - macro("hd", { + }) + macro('hd', { from: points.sleeveTip, to: points.frontNotch, y: points.sleeveTip.y - 15 - sa * 2 - }); - macro("hd", { + }) + macro('hd', { from: points.bicepsLeft, to: points.sleeveTip, y: points.sleeveTip.y - 30 - sa * 2 - }); - macro("hd", { + }) + macro('hd', { from: points.sleeveTip, to: points.bicepsRight, y: points.sleeveTip.y - 30 - sa * 2 - }); - macro("hd", { + }) + macro('hd', { from: points.bicepsLeft, to: points.bicepsRight, y: points.sleeveTip.y - 45 - sa * 2 - }); - macro("pd", { + }) + macro('pd', { path: new Path() .move(points.bicepsRight) ._curve(points.capQ1Cp1, points.capQ1) @@ -218,52 +198,52 @@ export default part => { .curve_(points.capQ4Cp2, points.bicepsLeft) .reverse(), d: 15 - }); - macro("vd", { + }) + macro('vd', { from: points.wristRight, to: points.bicepsRight, x: points.bicepsRight.x + 15 + sa * 2 - }); - macro("vd", { + }) + macro('vd', { from: points.bicepsRight, to: points.frontNotch, x: points.bicepsRight.x + 15 + sa * 2 - }); - macro("vd", { + }) + macro('vd', { from: points.bicepsRight, to: points.sleeveTip, x: points.bicepsRight.x + 30 + sa * 2 - }); - macro("vd", { + }) + macro('vd', { from: points.bicepsLeft, to: points.backNotch, x: points.bicepsLeft.x - 15 - sa - }); - macro("vd", { + }) + macro('vd', { from: points.cuffLeftCusp, to: points.placketEnd, x: points.placketEnd.x - 15 - }); - macro("hd", { + }) + macro('hd', { from: points.wristLeft, to: points.wristRight, y: points.wristLeft.y + 15 + sa - }); + }) if (pleats > 0) { - macro("hd", { + macro('hd', { from: points.cuffMidTop, to: points.cuffPleat1EdgeTop, y: points.cuffMidTop.y - 15 - }); + }) if (pleats === 2) { - macro("hd", { + macro('hd', { from: points.cuffPleat2Top, to: points.cuffPleat2EdgeTop, y: points.cuffPleat2Top.y - 15 - }); + }) } } } - return part; -}; + return part +} diff --git a/packages/simon/src/sleeveplacket-overlap.js b/packages/simon/src/sleeveplacket-overlap.js index 192fbf09f1d..82dcf37d61d 100644 --- a/packages/simon/src/sleeveplacket-overlap.js +++ b/packages/simon/src/sleeveplacket-overlap.js @@ -12,37 +12,34 @@ export default part => { paperless, macro, options - } = part.shorthand(); + } = part.shorthand() - let width = options.sleevePlacketWidth; - let length = measurements.shoulderToWrist * options.sleevePlacketLength; + let width = options.sleevePlacketWidth + let length = measurements.shoulderToWrist * options.sleevePlacketLength - points.midLeft = new Point(0, 0); - points.midLen = points.midLeft.shift(0, length); - points.midRight = points.midLeft.shift(0, length + width * 1.25); - points.fold1Left = points.midLeft.shift(90, width / 2); - points.fold2Left = points.midLeft.shift(-90, width / 2); - points.boxTopRight = points.midRight.shift(90, width / 2); - points.boxBottomRight = points.midRight.shift(-90, width / 2); - points.boxTopLeft = points.midLen.shift(90, width / 2); - points.boxBottomLeft = points.midLen.shift(-90, width / 2); - points.boxTip = points.midLen.shift(0, width * 1.5); - points.fold1Right = points.boxTopRight.shift(0, width * 0.5); - points.fold2Right = points.boxBottomRight.shift(0, width * 0.5); - points.topLeft = points.fold1Left.shift(90, width / 2 - 1.5); - points.topRight = points.fold1Right.shift(90, width / 2 - 1.5); - points.bottomRight = points.fold2Right.shift(-90, width * 1.5 - 1.5); - points.bottomLeft = points.fold2Left.shift(-90, width * 1.5 - 1.5); - points.cutRight = points.fold2Right.shift(-90, width / 2 - 1.5); - points.zig = points.cutRight.shift(180, width * 0.6); - points.zag = new Point( - points.bottomRight.x - width, - points.bottomRight.y - width * 0.6 - ); - points.cutLeft = points.zag.shift(180, width / 2); - points.cutBottom = new Point(points.cutLeft.x, points.bottomLeft.y); - points.fold3Left = new Point(0, width * 1.5); - points.fold3Right = new Point(points.cutBottom.x, width * 1.5); + points.midLeft = new Point(0, 0) + points.midLen = points.midLeft.shift(0, length) + points.midRight = points.midLeft.shift(0, length + width * 1.25) + points.fold1Left = points.midLeft.shift(90, width / 2) + points.fold2Left = points.midLeft.shift(-90, width / 2) + points.boxTopRight = points.midRight.shift(90, width / 2) + points.boxBottomRight = points.midRight.shift(-90, width / 2) + points.boxTopLeft = points.midLen.shift(90, width / 2) + points.boxBottomLeft = points.midLen.shift(-90, width / 2) + points.boxTip = points.midLen.shift(0, width * 1.5) + points.fold1Right = points.boxTopRight.shift(0, width * 0.5) + points.fold2Right = points.boxBottomRight.shift(0, width * 0.5) + points.topLeft = points.fold1Left.shift(90, width / 2 - 1.5) + points.topRight = points.fold1Right.shift(90, width / 2 - 1.5) + points.bottomRight = points.fold2Right.shift(-90, width * 1.5 - 1.5) + points.bottomLeft = points.fold2Left.shift(-90, width * 1.5 - 1.5) + points.cutRight = points.fold2Right.shift(-90, width / 2 - 1.5) + points.zig = points.cutRight.shift(180, width * 0.6) + points.zag = new Point(points.bottomRight.x - width, points.bottomRight.y - width * 0.6) + points.cutLeft = points.zag.shift(180, width / 2) + points.cutBottom = new Point(points.cutLeft.x, points.bottomLeft.y) + points.fold3Left = new Point(0, width * 1.5) + points.fold3Right = new Point(points.cutBottom.x, width * 1.5) paths.seam = new Path() .move(points.topLeft) @@ -54,7 +51,7 @@ export default part => { .line(points.cutBottom) .line(points.bottomLeft) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') paths.outline = new Path() .move(points.fold1Left) @@ -64,7 +61,7 @@ export default part => { .line(points.fold2Left) .move(points.boxTopLeft) .line(points.boxBottomLeft) - .attr("class", "dashed"); + .attr('class', 'dashed') paths.folds = new Path() .move(points.fold3Left) @@ -74,25 +71,22 @@ export default part => { .line(points.boxTip) .line(points.fold1Right) .line(points.boxTopRight) - .attr("class", "dotted"); + .attr('class', 'dotted') // Complete pattern? if (complete) { // Title - points.title = new Point(length / 4, 0); - macro("title", { + points.title = new Point(length / 4, 0) + macro('title', { at: points.title, nr: 10, - title: "sleevePlacketOverlap", + title: 'sleevePlacketOverlap', scale: 0.6 - }); + }) // Button - points.buttonhole = new Point(length / 2, 0); - snippets.buttonhole = new Snippet("buttonhole", points.buttonhole).attr( - "data-rotate", - 90 - ); + points.buttonhole = new Point(length / 2, 0) + snippets.buttonhole = new Snippet('buttonhole', points.buttonhole).attr('data-rotate', 90) if (sa) { paths.sa = new Path() @@ -100,73 +94,73 @@ export default part => { .line(points.bottomLeft.shift(180, sa)) .line(points.topLeft.shift(180, sa)) .line(points.topLeft) - .attr("class", "fabric sa"); + .attr('class', 'fabric sa') } } // Paperless? if (paperless) { - macro("hd", { + macro('hd', { from: points.bottomLeft, to: points.cutBottom, y: points.bottomLeft.y + 15 - }); - macro("hd", { + }) + macro('hd', { from: points.bottomLeft, to: points.zag, y: points.bottomLeft.y + 30 - }); - macro("hd", { + }) + macro('hd', { from: points.bottomLeft, to: points.zig, y: points.bottomLeft.y + 45 - }); - macro("hd", { + }) + macro('hd', { from: points.bottomLeft, to: points.cutRight, y: points.bottomLeft.y + 60 - }); - macro("vd", { + }) + macro('vd', { from: points.fold1Right, to: points.topRight, x: points.topRight.x + 15 - }); - macro("vd", { + }) + macro('vd', { from: points.boxTip, to: points.topRight, x: points.topRight.x + 30 - }); - macro("vd", { + }) + macro('vd', { from: points.fold2Right, to: points.topRight, x: points.topRight.x + 45 - }); - macro("vd", { + }) + macro('vd', { from: points.cutRight, to: points.topRight, x: points.topRight.x + 60 - }); - macro("vd", { + }) + macro('vd', { from: points.zag, to: points.topRight, x: points.topRight.x + 75 - }); - macro("vd", { + }) + macro('vd', { from: points.cutBottom, to: points.topRight, x: points.topRight.x + 90 - }); - macro("hd", { + }) + macro('hd', { from: points.topLeft, to: points.boxTopLeft, y: points.topLeft.y - 15 - }); - macro("hd", { + }) + macro('hd', { from: points.topLeft, to: points.boxTopRight, y: points.topLeft.y - 30 - }); + }) } - return part; -}; + return part +} diff --git a/packages/simon/src/sleeveplacket-underlap.js b/packages/simon/src/sleeveplacket-underlap.js index 87710e18fb3..90e668f5cd5 100644 --- a/packages/simon/src/sleeveplacket-underlap.js +++ b/packages/simon/src/sleeveplacket-underlap.js @@ -12,22 +12,21 @@ export default part => { paperless, macro, options - } = part.shorthand(); + } = part.shorthand() - let width = - options.sleevePlacketWidth > 20 ? 10 : options.sleevePlacketWidth / 4; - let length = measurements.shoulderToWrist * options.sleevePlacketLength; + let width = options.sleevePlacketWidth > 20 ? 10 : options.sleevePlacketWidth / 4 + let length = measurements.shoulderToWrist * options.sleevePlacketLength - points.midLeft = new Point(0, 0); - points.midRight = points.midLeft.shift(0, length); - points.fold1Left = points.midLeft.shift(90, width); - points.fold2Left = points.midLeft.shift(-90, width); - points.fold1Right = points.fold1Left.shift(0, length); - points.fold2Right = points.fold2Left.shift(0, length); - points.topLeft = points.midLeft.shift(90, width * 2 - 1.5); - points.topRight = points.midRight.shift(90, width * 2 - 1.5); - points.bottomLeft = points.midLeft.shift(-90, width * 2 - 1.5); - points.bottomRight = points.midRight.shift(-90, width * 2 - 1.5); + points.midLeft = new Point(0, 0) + points.midRight = points.midLeft.shift(0, length) + points.fold1Left = points.midLeft.shift(90, width) + points.fold2Left = points.midLeft.shift(-90, width) + points.fold1Right = points.fold1Left.shift(0, length) + points.fold2Right = points.fold2Left.shift(0, length) + points.topLeft = points.midLeft.shift(90, width * 2 - 1.5) + points.topRight = points.midRight.shift(90, width * 2 - 1.5) + points.bottomLeft = points.midLeft.shift(-90, width * 2 - 1.5) + points.bottomRight = points.midRight.shift(-90, width * 2 - 1.5) paths.seam = new Path() .move(points.topLeft) @@ -35,7 +34,7 @@ export default part => { .line(points.bottomRight) .line(points.bottomLeft) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') paths.folds = new Path() .move(points.fold1Left) @@ -44,23 +43,23 @@ export default part => { .line(points.fold2Right) .move(points.midLeft) .line(points.midRight) - .attr("class", "help"); + .attr('class', 'help') // Complete pattern? if (complete) { // Title - points.title = new Point(length / 4, 0); - macro("title", { + points.title = new Point(length / 4, 0) + macro('title', { at: points.title, nr: 9, - title: "sleevePlacketUnderlap", + title: 'sleevePlacketUnderlap', scale: 0.6, append: true - }); + }) // Button - points.button = new Point(length / 2, width / 2); - snippets.button = new Snippet("button", points.button); + points.button = new Point(length / 2, width / 2) + snippets.button = new Snippet('button', points.button) if (sa) { paths.sa = new Path() @@ -68,33 +67,33 @@ export default part => { .line(points.bottomLeft.shift(180, sa)) .line(points.topLeft.shift(180, sa)) .line(points.topLeft) - .attr("class", "fabric sa"); + .attr('class', 'fabric sa') } } // Paperless? if (paperless) { - macro("vd", { + macro('vd', { from: points.fold2Right, to: points.fold1Right, x: points.topRight.x + 15 - }); - macro("vd", { + }) + macro('vd', { from: points.bottomRight, to: points.topRight, x: points.topRight.x + 30 - }); - macro("hd", { + }) + macro('hd', { from: points.bottomLeft, to: points.button, y: points.bottomRight.y + 15 - }); - macro("hd", { + }) + macro('hd', { from: points.bottomLeft, to: points.bottomRight, y: points.bottomRight.y + 30 - }); + }) } - return part; -}; + return part +} diff --git a/packages/simon/src/yoke.js b/packages/simon/src/yoke.js index 66b5a992de4..9205019b4ea 100644 --- a/packages/simon/src/yoke.js +++ b/packages/simon/src/yoke.js @@ -11,12 +11,12 @@ export default part => { paperless, macro, options - } = part.shorthand(); + } = part.shorthand() - for (let id of Object.keys(part.paths)) delete part.paths[id]; + for (let id of Object.keys(part.paths)) delete part.paths[id] // Cut off at yoke - points.cbYoke = new Point(0, points.armholePitch.y); + points.cbYoke = new Point(0, points.armholePitch.y) // Paths paths.saBase = new Path() @@ -24,95 +24,94 @@ export default part => { .line(points.armholePitch) .curve(points.armholePitchCp2, points.shoulderCp1, points.shoulder) .line(points.neck) - .curve_(points.neckCp2, points.cbNeck); - if (options.splitYoke) - paths.saBase = paths.saBase.line(points.cbYoke).close(); - paths.seam = paths.saBase.clone(); - paths.saBase.render = false; - paths.seam = paths.seam.close().attr("class", "fabric"); + .curve_(points.neckCp2, points.cbNeck) + if (options.splitYoke) paths.saBase = paths.saBase.line(points.cbYoke).close() + paths.seam = paths.saBase.clone() + paths.saBase.render = false + paths.seam = paths.seam.close().attr('class', 'fabric') // Complete pattern? if (complete) { - delete snippets.armholePitchNotch; - points.title = new Point(points.neck.x, points.cbYoke.y / 3); - macro("title", { at: points.title, nr: 4, title: "yoke", scale: 0.8 }); - points.logo = points.title.shift(-90, 50); - snippets.logo = new Snippet("logo", points.logo); - snippets.logo.attr("data-scale", 0.8); + delete snippets.armholePitchNotch + points.title = new Point(points.neck.x, points.cbYoke.y / 3) + macro('title', { at: points.title, nr: 4, title: 'yoke', scale: 0.8 }) + points.logo = points.title.shift(-90, 50) + snippets.logo = new Snippet('logo', points.logo) + snippets.logo.attr('data-scale', 0.8) if (options.splitYoke) { - points.grainlineFrom = points.cbYoke.shift(0, 20); - points.grainlineTo = points.cbNeck.shift(0, 20); - macro("grainline", { + points.grainlineFrom = points.cbYoke.shift(0, 20) + points.grainlineTo = points.cbNeck.shift(0, 20) + macro('grainline', { from: points.grainlineFrom, to: points.grainlineTo - }); + }) } else { - macro("cutonfold", { + macro('cutonfold', { from: points.cbNeck, to: points.cbYoke, grainline: true - }); + }) } - macro("sprinkle", { - snippet: "notch", - on: ["neck", "shoulder"] - }); + macro('sprinkle', { + snippet: 'notch', + on: ['neck', 'shoulder'] + }) if (sa) { - paths.sa = paths.saBase.offset(sa).attr("class", "fabric sa"); + paths.sa = paths.saBase.offset(sa).attr('class', 'fabric sa') if (options.splitYoke) { paths.sa = paths.sa .line(points.cbNeck) .move(points.cbYoke) - .line(paths.sa.start()); + .line(paths.sa.start()) } } } // Paperless? if (paperless) { - macro("pd", { + macro('pd', { path: new Path().move(points.cbNeck)._curve(points.neckCp2, points.neck), d: 15 - }); - macro("hd", { + }) + macro('hd', { from: points.cbNeck, to: points.neck, y: points.neck.y - 15 - sa - }); - macro("ld", { + }) + macro('ld', { from: points.neck, to: points.shoulder, d: 15 + sa - }); - macro("hd", { + }) + macro('hd', { from: points.cbYoke, to: points.armholePitch, y: points.cbYoke.y + 15 + sa - }); - macro("hd", { + }) + macro('hd', { from: points.cbYoke, to: points.shoulder, y: points.cbYoke.y + 30 + sa - }); - macro("vd", { + }) + macro('vd', { from: points.cbYoke, to: points.cbNeck, x: points.cbYoke.x - 15 - sa - }); - macro("pd", { + }) + macro('pd', { path: new Path() .move(points.armholePitch) .curve(points.armholePitchCp2, points.shoulderCp1, points.shoulder), d: 15 + sa - }); - macro("vd", { + }) + macro('vd', { from: points.armholePitch, to: points.shoulder, x: points.shoulder.x + 30 + sa - }); + }) } - return part; -}; + return part +} diff --git a/packages/sven/example/src/App.js b/packages/sven/example/src/App.js index e7936330e5d..115cdf683af 100644 --- a/packages/sven/example/src/App.js +++ b/packages/sven/example/src/App.js @@ -1,22 +1,15 @@ -import React from "react"; -import freesewing from "@freesewing/core"; -import Workbench from "@freesewing/components/Workbench"; -import "typeface-roboto-condensed"; -import "@freesewing/css-theme"; +import React from 'react' +import freesewing from '@freesewing/core' +import Workbench from '@freesewing/components/Workbench' +import 'typeface-roboto-condensed' +import '@freesewing/css-theme' -import Pattern from "pattern"; +import Pattern from 'pattern' const App = props => { - let instance = new Pattern(); - let config = instance.config; - return ( - - ); -}; + let instance = new Pattern() + let config = instance.config + return +} -export default App; +export default App diff --git a/packages/sven/example/src/index.js b/packages/sven/example/src/index.js index 7900787a4d2..9dd7ba788d4 100644 --- a/packages/sven/example/src/index.js +++ b/packages/sven/example/src/index.js @@ -1,11 +1,11 @@ -import React from "react"; -import ReactDOM from "react-dom"; -import App from "./App"; -import * as serviceWorker from "./serviceWorker"; +import React from 'react' +import ReactDOM from 'react-dom' +import App from './App' +import * as serviceWorker from './serviceWorker' -ReactDOM.render(, document.getElementById("root")); +ReactDOM.render(, document.getElementById('root')) // If you want your app to work offline and load faster, you can change // unregister() to register() below. Note this comes with some pitfalls. // Learn more about service workers: http://bit.ly/CRA-PWA -serviceWorker.unregister(); +serviceWorker.unregister() diff --git a/packages/sven/example/src/serviceWorker.js b/packages/sven/example/src/serviceWorker.js index 68fda5a0eb6..44e1b1b2f8c 100644 --- a/packages/sven/example/src/serviceWorker.js +++ b/packages/sven/example/src/serviceWorker.js @@ -9,46 +9,44 @@ // This link also includes instructions on opting out of this behavior. const isLocalhost = Boolean( - window.location.hostname === "localhost" || + window.location.hostname === 'localhost' || // [::1] is the IPv6 localhost address. - window.location.hostname === "[::1]" || + window.location.hostname === '[::1]' || // 127.0.0.1/8 is considered localhost for IPv4. - window.location.hostname.match( - /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ - ) -); + window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/) +) export function register(config) { - if (process.env.NODE_ENV === "production" && "serviceWorker" in navigator) { + if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) { // The URL constructor is available in all browsers that support SW. - const publicUrl = new URL(process.env.PUBLIC_URL, window.location); + const publicUrl = new URL(process.env.PUBLIC_URL, window.location) if (publicUrl.origin !== window.location.origin) { // Our service worker won't work if PUBLIC_URL is on a different origin // from what our page is served on. This might happen if a CDN is used to // serve assets; see https://github.com/facebook/create-react-app/issues/2374 - return; + return } - window.addEventListener("load", () => { - const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; + window.addEventListener('load', () => { + const swUrl = `${process.env.PUBLIC_URL}/service-worker.js` if (isLocalhost) { // This is running on localhost. Let's check if a service worker still exists or not. - checkValidServiceWorker(swUrl, config); + checkValidServiceWorker(swUrl, config) // Add some additional logging to localhost, pointing developers to the // service worker/PWA documentation. navigator.serviceWorker.ready.then(() => { console.log( - "This web app is being served cache-first by a service " + - "worker. To learn more, visit https://goo.gl/SC7cgQ" - ); - }); + 'This web app is being served cache-first by a service ' + + 'worker. To learn more, visit https://goo.gl/SC7cgQ' + ) + }) } else { // Is not local host. Just register service worker - registerValidSW(swUrl, config); + registerValidSW(swUrl, config) } - }); + }) } } @@ -57,38 +55,38 @@ function registerValidSW(swUrl, config) { .register(swUrl) .then(registration => { registration.onupdatefound = () => { - const installingWorker = registration.installing; + const installingWorker = registration.installing installingWorker.onstatechange = () => { - if (installingWorker.state === "installed") { + if (installingWorker.state === 'installed') { if (navigator.serviceWorker.controller) { // At this point, the old content will have been purged and // the fresh content will have been added to the cache. // It's the perfect time to display a "New content is // available; please refresh." message in your web app. - console.log("New content is available; please refresh."); + console.log('New content is available; please refresh.') // Execute callback if (config.onUpdate) { - config.onUpdate(registration); + config.onUpdate(registration) } } else { // At this point, everything has been precached. // It's the perfect time to display a // "Content is cached for offline use." message. - console.log("Content is cached for offline use."); + console.log('Content is cached for offline use.') // Execute callback if (config.onSuccess) { - config.onSuccess(registration); + config.onSuccess(registration) } } } - }; - }; + } + } }) .catch(error => { - console.error("Error during service worker registration:", error); - }); + console.error('Error during service worker registration:', error) + }) } function checkValidServiceWorker(swUrl, config) { @@ -98,30 +96,28 @@ function checkValidServiceWorker(swUrl, config) { // Ensure service worker exists, and that we really are getting a JS file. if ( response.status === 404 || - response.headers.get("content-type").indexOf("javascript") === -1 + response.headers.get('content-type').indexOf('javascript') === -1 ) { // No service worker found. Probably a different app. Reload the page. navigator.serviceWorker.ready.then(registration => { registration.unregister().then(() => { - window.location.reload(); - }); - }); + window.location.reload() + }) + }) } else { // Service worker found. Proceed as normal. - registerValidSW(swUrl, config); + registerValidSW(swUrl, config) } }) .catch(() => { - console.log( - "No internet connection found. App is running in offline mode." - ); - }); + console.log('No internet connection found. App is running in offline mode.') + }) } export function unregister() { - if ("serviceWorker" in navigator) { + if ('serviceWorker' in navigator) { navigator.serviceWorker.ready.then(registration => { - registration.unregister(); - }); + registration.unregister() + }) } } diff --git a/packages/sven/src/cuff.js b/packages/sven/src/cuff.js index 14852979cfc..0fb6b980229 100644 --- a/packages/sven/src/cuff.js +++ b/packages/sven/src/cuff.js @@ -1,30 +1,20 @@ -import { draftRibbing } from "./shared"; +import { draftRibbing } from './shared' export default part => { - let { - measurements, - sa, - points, - complete, - paperless, - macro, - options - } = part.shorthand(); + let { measurements, sa, points, complete, paperless, macro, options } = part.shorthand() - if (!options.ribbing) return part; + if (!options.ribbing) return part let length = - measurements.wristCircumference * - (1 + options.cuffEase) * - (1 - options.ribbingStretch); - draftRibbing(part, length); + measurements.wristCircumference * (1 + options.cuffEase) * (1 - options.ribbingStretch) + draftRibbing(part, length) // Complete pattern? if (complete) { - macro("title", { + macro('title', { at: points.title, nr: 5, - title: "cuff" - }); + title: 'cuff' + }) if (sa) { // FIXME: Don't we need SA here? } @@ -34,5 +24,5 @@ export default part => { if (paperless) { } - return part; -}; + return part +} diff --git a/packages/sven/src/front.js b/packages/sven/src/front.js index b08225bc7c6..6c4bf0496e2 100644 --- a/packages/sven/src/front.js +++ b/packages/sven/src/front.js @@ -10,33 +10,30 @@ export default part => { paperless, macro, options - } = part.shorthand(); - let front = true; - if (typeof points.cfHem === "undefined") front = false; + } = part.shorthand() + let front = true + if (typeof points.cfHem === 'undefined') front = false // Waist shaping - points.waist.x = (measurements.naturalWaist * (1 + options.waistEase)) / 4; - points.hips.x = (measurements.hipsCircumference * (1 + options.hipsEase)) / 4; - points.hem.x = points.hips.x; - points.hipsCp2 = points.hips.shift(90, measurements.naturalWaistToHip / 3); - points.waistCp1 = points.waist.shift(-90, measurements.naturalWaistToHip / 3); - points.waistCp2 = points.waist.shift( - 90, - measurements.centerBackNeckToWaist / 4 - ); + points.waist.x = (measurements.naturalWaist * (1 + options.waistEase)) / 4 + points.hips.x = (measurements.hipsCircumference * (1 + options.hipsEase)) / 4 + points.hem.x = points.hips.x + points.hipsCp2 = points.hips.shift(90, measurements.naturalWaistToHip / 3) + points.waistCp1 = points.waist.shift(-90, measurements.naturalWaistToHip / 3) + points.waistCp2 = points.waist.shift(90, measurements.centerBackNeckToWaist / 4) if (options.ribbing) { // Adapt lengtht for ribbing - let ribbingHeight; - if (typeof store.get("ribbingHeight") === "undefined") { + let ribbingHeight + if (typeof store.get('ribbingHeight') === 'undefined') { ribbingHeight = (measurements.centerBackNeckToWaist + measurements.naturalWaistToHip) * - options.ribbingHeight; - store.set("ribbingHeight", ribbingHeight); - } else ribbingHeight = store.get("ribbingHeight"); - points.hem = points.hem.shift(90, ribbingHeight); - if (front) points.cfHem = points.cfHem.shift(90, ribbingHeight); - else points.cbHem = points.cbHem.shift(90, ribbingHeight); + options.ribbingHeight + store.set('ribbingHeight', ribbingHeight) + } else ribbingHeight = store.get('ribbingHeight') + points.hem = points.hem.shift(90, ribbingHeight) + if (front) points.cfHem = points.cfHem.shift(90, ribbingHeight) + else points.cbHem = points.cbHem.shift(90, ribbingHeight) } // Paths @@ -48,80 +45,73 @@ export default part => { .curve(points.armholeCp2, points.armholeHollowCp1, points.armholeHollow) .curve(points.armholeHollowCp2, points.armholePitchCp1, points.armholePitch) .curve(points.armholePitchCp2, points.shoulderCp1, points.shoulder) - .line(points.neck); - if (front) - paths.saBase.curve(points.neckCp2Front, points.cfNeckCp1, points.cfNeck); - else paths.saBase.curve_(points.neckCp2, points.cbNeck); - if (front) paths.hemBase = new Path().move(points.cfHem).line(points.hem); - else paths.hemBase = new Path().move(points.cbHem).line(points.hem); + .line(points.neck) + if (front) paths.saBase.curve(points.neckCp2Front, points.cfNeckCp1, points.cfNeck) + else paths.saBase.curve_(points.neckCp2, points.cbNeck) + if (front) paths.hemBase = new Path().move(points.cfHem).line(points.hem) + else paths.hemBase = new Path().move(points.cbHem).line(points.hem) - paths.saBase.render = false; - paths.hemBase.render = false; + paths.saBase.render = false + paths.hemBase.render = false - paths.seam = paths.hemBase.join(paths.saBase); - if (front) paths.seam.line(points.cfHem); - else paths.seam.line(points.cbHem); - paths.seam.attr("class", "fabric"); + paths.seam = paths.hemBase.join(paths.saBase) + if (front) paths.seam.line(points.cfHem) + else paths.seam.line(points.cbHem) + paths.seam.attr('class', 'fabric') // Seam allowance if (complete) { if (sa) { - paths.sa = paths.hemBase - .offset(sa * (options.ribbing ? 1 : 3)) - .join(paths.saBase.offset(sa)); - if (front) paths.sa.line(points.cfNeck).move(points.cfHem); - else paths.sa.line(points.cbNeck).move(points.cbHem); - paths.sa.line(paths.sa.start()); + paths.sa = paths.hemBase.offset(sa * (options.ribbing ? 1 : 3)).join(paths.saBase.offset(sa)) + if (front) paths.sa.line(points.cfNeck).move(points.cfHem) + else paths.sa.line(points.cbNeck).move(points.cbHem) + paths.sa.line(paths.sa.start()) } } // Paperless if (paperless) { - macro("pd", { + macro('pd', { path: new Path() .move(points.armhole) .curve(points.armholeCp2, points.armholeHollowCp1, points.armholeHollow) - .curve( - points.armholeHollowCp2, - points.armholePitchCp1, - points.armholePitch - ) + .curve(points.armholeHollowCp2, points.armholePitchCp1, points.armholePitch) .curve(points.armholePitchCp2, points.shoulderCp1, points.shoulder), d: sa + 15 - }); - macro("pd", { + }) + macro('pd', { path: new Path() .move(points.armholePitch) .curve(points.armholePitchCp2, points.shoulderCp1, points.shoulder), d: -15 - }); - macro("vd", { + }) + macro('vd', { from: points.hips, to: points.waist, x: points.hips.x + sa + 15 - }); - macro("vd", { + }) + macro('vd', { from: points.hips, to: points.armhole, x: points.hips.x + sa + 30 - }); - macro("vd", { + }) + macro('vd', { from: points.hips, to: points.armholePitch, x: points.hips.x + sa + 45 - }); - macro("vd", { + }) + macro('vd', { from: points.hips, to: points.shoulder, x: points.hips.x + sa + 60 - }); - macro("vd", { + }) + macro('vd', { from: points.hips, to: points.neck, x: points.hips.x + sa + 75 - }); - macro("ld", { from: points.neck, to: points.shoulder, d: sa + 15 }); + }) + macro('ld', { from: points.neck, to: points.shoulder, d: sa + 15 }) } - return part; -}; + return part +} diff --git a/packages/sven/src/index.js b/packages/sven/src/index.js index 4488809cb80..17c3cc82851 100644 --- a/packages/sven/src/index.js +++ b/packages/sven/src/index.js @@ -1,34 +1,34 @@ -import freesewing from "@freesewing/core"; -import Brian from "@freesewing/brian"; -import plugins from "@freesewing/plugin-bundle"; -import config from "../config"; +import freesewing from '@freesewing/core' +import Brian from '@freesewing/brian' +import plugins from '@freesewing/plugin-bundle' +import config from '../config' // Parts -import draftFront from "./front"; -import draftSleeve from "./sleeve"; -import draftCuff from "./cuff"; -import draftWaistband from "./waistband"; +import draftFront from './front' +import draftSleeve from './sleeve' +import draftCuff from './cuff' +import draftWaistband from './waistband' // Create design -const Pattern = new freesewing.Design(config, plugins); +const Pattern = new freesewing.Design(config, plugins) // Attach draft methods to prototype Pattern.prototype.draftBase = function(part) { - return new Brian(this.settings).draftBase(part); -}; + return new Brian(this.settings).draftBase(part) +} Pattern.prototype.draftFrontBase = function(part) { - return new Brian(this.settings).draftFront(part); -}; + return new Brian(this.settings).draftFront(part) +} Pattern.prototype.draftBackBase = function(part) { - return new Brian(this.settings).draftBack(part); -}; + return new Brian(this.settings).draftBack(part) +} Pattern.prototype.draftSleeveBase = function(part) { - let brian = new Brian(this.settings); - return brian.draftSleeve(brian.draftSleevecap(part)); -}; -Pattern.prototype.draftFront = draftFront; -Pattern.prototype.draftBack = draftFront; -Pattern.prototype.draftSleeve = draftSleeve; -Pattern.prototype.draftCuff = draftCuff; -Pattern.prototype.draftWaistband = draftWaistband; + let brian = new Brian(this.settings) + return brian.draftSleeve(brian.draftSleevecap(part)) +} +Pattern.prototype.draftFront = draftFront +Pattern.prototype.draftBack = draftFront +Pattern.prototype.draftSleeve = draftSleeve +Pattern.prototype.draftCuff = draftCuff +Pattern.prototype.draftWaistband = draftWaistband -export default Pattern; +export default Pattern diff --git a/packages/sven/src/shared.js b/packages/sven/src/shared.js index 221081bac4f..96b6c915a67 100644 --- a/packages/sven/src/shared.js +++ b/packages/sven/src/shared.js @@ -12,27 +12,26 @@ export const draftRibbing = function(part, length) { paperless, macro, units - } = part.shorthand(); - if (typeof store.get("ribbingHeight") === "undefined") { + } = part.shorthand() + if (typeof store.get('ribbingHeight') === 'undefined') { store.set( - "ribbingHeight", - (measurements.centerBackNeckToWaist + measurements.naturalWaistToHip) * - options.ribbingHeight - ); + 'ribbingHeight', + (measurements.centerBackNeckToWaist + measurements.naturalWaistToHip) * options.ribbingHeight + ) } - let height = store.get("ribbingHeight"); - let gap = 25; - let lead = 50; - if (length < 125) lead = length / 3; + let height = store.get('ribbingHeight') + let gap = 25 + let lead = 50 + if (length < 125) lead = length / 3 - points.topLeft = new Point(0, 0); - points.topRight = new Point(height * 2, 0); - points.leftGapStart = new Point(0, lead); - points.rightGapEnd = new Point(points.topRight.x, lead); - points.leftGapEnd = new Point(0, lead + gap); - points.rightGapStart = new Point(points.topRight.x, lead + gap); - points.bottomLeft = new Point(0, gap + 2 * lead); - points.bottomRight = new Point(points.topRight.x, gap + 2 * lead); + points.topLeft = new Point(0, 0) + points.topRight = new Point(height * 2, 0) + points.leftGapStart = new Point(0, lead) + points.rightGapEnd = new Point(points.topRight.x, lead) + points.leftGapEnd = new Point(0, lead + gap) + points.rightGapStart = new Point(points.topRight.x, lead + gap) + points.bottomLeft = new Point(0, gap + 2 * lead) + points.bottomRight = new Point(points.topRight.x, gap + 2 * lead) paths.seam = new Path() .move(points.rightGapEnd) @@ -43,20 +42,17 @@ export const draftRibbing = function(part, length) { .line(points.bottomLeft) .line(points.bottomRight) .line(points.rightGapStart) - .attr("class", "various"); + .attr('class', 'various') paths.hint = new Path() .move(points.leftGapStart) .line(points.leftGapEnd) .move(points.rightGapStart) .line(points.rightGapEnd) - .attr("class", "various dashed"); + .attr('class', 'various dashed') if (complete) { - points.title = new Point( - points.bottomRight.x / 2, - points.bottomRight.y / 2 - ); + points.title = new Point(points.bottomRight.x / 2, points.bottomRight.y / 2) if (sa) { paths.sa = new Path() .move(points.topLeft) @@ -66,21 +62,21 @@ export const draftRibbing = function(part, length) { .line(points.topLeft) .close() .offset(sa) - .attr("class", "various sa"); + .attr('class', 'various sa') } } if (paperless) { - macro("vd", { + macro('vd', { from: points.bottomRight, to: points.topRight, x: points.topRight.x + sa + 15, text: units(length) - }); - macro("hd", { + }) + macro('hd', { from: points.topLeft, to: points.topRight, y: points.topRight.y - sa - 15 - }); + }) } -}; +} diff --git a/packages/sven/src/sleeve.js b/packages/sven/src/sleeve.js index 2cabef15e25..4cfdd136f7a 100644 --- a/packages/sven/src/sleeve.js +++ b/packages/sven/src/sleeve.js @@ -1,21 +1,11 @@ export default part => { - let { - store, - sa, - points, - paths, - Path, - complete, - paperless, - macro, - options - } = part.shorthand(); + let { store, sa, points, paths, Path, complete, paperless, macro, options } = part.shorthand() if (options.ribbing) { - let ribbingHeight = store.get("ribbingHeight"); - points.wristLeft = points.wristLeft.shift(90, ribbingHeight); - points.wristRight = points.wristRight.shift(90, ribbingHeight); - points.centerWrist = points.centerWrist.shift(90, ribbingHeight); + let ribbingHeight = store.get('ribbingHeight') + points.wristLeft = points.wristLeft.shift(90, ribbingHeight) + points.wristRight = points.wristRight.shift(90, ribbingHeight) + points.centerWrist = points.centerWrist.shift(90, ribbingHeight) } paths.seam = new Path() @@ -25,60 +15,58 @@ export default part => { .line(points.wristLeft) .line(points.wristRight) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') // Complete pattern? if (complete) { - macro("grainline", { + macro('grainline', { from: points.centerWrist, to: points.grainlineTo - }); + }) if (sa) { paths.saBase = new Path() .move(points.wristRight) .line(points.bicepsRight) .join(paths.sleevecap) - .line(points.wristLeft); - paths.hemBase = new Path().move(points.wristLeft).line(points.wristRight); - paths.saBase.render = false; - paths.hemBase.render = false; - paths.sa = paths.saBase - .offset(sa) - .join(paths.hemBase.offset(sa * (options.ribbing ? 1 : 3))); + .line(points.wristLeft) + paths.hemBase = new Path().move(points.wristLeft).line(points.wristRight) + paths.saBase.render = false + paths.hemBase.render = false + paths.sa = paths.saBase.offset(sa).join(paths.hemBase.offset(sa * (options.ribbing ? 1 : 3))) paths.sa .line(paths.sa.start()) .close() - .attr("class", "fabric sa"); + .attr('class', 'fabric sa') } } // Paperless? if (paperless) { - macro("vd", { + macro('vd', { from: points.wristLeft, to: points.bicepsLeft, x: points.bicepsLeft.x - sa - 15 - }); - macro("vd", { + }) + macro('vd', { from: points.wristLeft, to: points.sleeveTip, x: points.bicepsLeft.x - sa - 30 - }); - macro("hd", { + }) + macro('hd', { from: points.bicepsLeft, to: points.bicepsRight, y: points.sleeveTip.y - sa - 30 - }); - macro("hd", { + }) + macro('hd', { from: points.wristLeft, to: points.wristRight, y: points.wristLeft.y + sa * (options.ribbing ? 1 : 3) + 15 - }); - macro("pd", { + }) + macro('pd', { path: paths.sleevecap.reverse(), d: -1 * sa - 15 - }); + }) } - return part; -}; + return part +} diff --git a/packages/sven/src/waistband.js b/packages/sven/src/waistband.js index 6388f363947..cf35db318bb 100644 --- a/packages/sven/src/waistband.js +++ b/packages/sven/src/waistband.js @@ -1,31 +1,21 @@ -import { draftRibbing } from "./shared"; +import { draftRibbing } from './shared' export default part => { - let { - measurements, - sa, - points, - complete, - paperless, - macro, - options - } = part.shorthand(); + let { measurements, sa, points, complete, paperless, macro, options } = part.shorthand() - if (!options.ribbing) return part; + if (!options.ribbing) return part let length = - measurements.hipsCircumference * - (1 + options.hipsEase) * - (1 - options.ribbingStretch); - draftRibbing(part, length); + measurements.hipsCircumference * (1 + options.hipsEase) * (1 - options.ribbingStretch) + draftRibbing(part, length) // Complete pattern? if (complete) { - macro("title", { + macro('title', { at: points.title, nr: 4, - title: "waistband" - }); + title: 'waistband' + }) if (sa) { // FIXME: Don't we need SA here? } @@ -35,5 +25,5 @@ export default part => { if (paperless) { } - return part; -}; + return part +} diff --git a/packages/tamiko/example/src/App.js b/packages/tamiko/example/src/App.js index e7936330e5d..115cdf683af 100644 --- a/packages/tamiko/example/src/App.js +++ b/packages/tamiko/example/src/App.js @@ -1,22 +1,15 @@ -import React from "react"; -import freesewing from "@freesewing/core"; -import Workbench from "@freesewing/components/Workbench"; -import "typeface-roboto-condensed"; -import "@freesewing/css-theme"; +import React from 'react' +import freesewing from '@freesewing/core' +import Workbench from '@freesewing/components/Workbench' +import 'typeface-roboto-condensed' +import '@freesewing/css-theme' -import Pattern from "pattern"; +import Pattern from 'pattern' const App = props => { - let instance = new Pattern(); - let config = instance.config; - return ( - - ); -}; + let instance = new Pattern() + let config = instance.config + return +} -export default App; +export default App diff --git a/packages/tamiko/example/src/index.js b/packages/tamiko/example/src/index.js index 7900787a4d2..9dd7ba788d4 100644 --- a/packages/tamiko/example/src/index.js +++ b/packages/tamiko/example/src/index.js @@ -1,11 +1,11 @@ -import React from "react"; -import ReactDOM from "react-dom"; -import App from "./App"; -import * as serviceWorker from "./serviceWorker"; +import React from 'react' +import ReactDOM from 'react-dom' +import App from './App' +import * as serviceWorker from './serviceWorker' -ReactDOM.render(, document.getElementById("root")); +ReactDOM.render(, document.getElementById('root')) // If you want your app to work offline and load faster, you can change // unregister() to register() below. Note this comes with some pitfalls. // Learn more about service workers: http://bit.ly/CRA-PWA -serviceWorker.unregister(); +serviceWorker.unregister() diff --git a/packages/tamiko/example/src/serviceWorker.js b/packages/tamiko/example/src/serviceWorker.js index 68fda5a0eb6..44e1b1b2f8c 100644 --- a/packages/tamiko/example/src/serviceWorker.js +++ b/packages/tamiko/example/src/serviceWorker.js @@ -9,46 +9,44 @@ // This link also includes instructions on opting out of this behavior. const isLocalhost = Boolean( - window.location.hostname === "localhost" || + window.location.hostname === 'localhost' || // [::1] is the IPv6 localhost address. - window.location.hostname === "[::1]" || + window.location.hostname === '[::1]' || // 127.0.0.1/8 is considered localhost for IPv4. - window.location.hostname.match( - /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ - ) -); + window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/) +) export function register(config) { - if (process.env.NODE_ENV === "production" && "serviceWorker" in navigator) { + if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) { // The URL constructor is available in all browsers that support SW. - const publicUrl = new URL(process.env.PUBLIC_URL, window.location); + const publicUrl = new URL(process.env.PUBLIC_URL, window.location) if (publicUrl.origin !== window.location.origin) { // Our service worker won't work if PUBLIC_URL is on a different origin // from what our page is served on. This might happen if a CDN is used to // serve assets; see https://github.com/facebook/create-react-app/issues/2374 - return; + return } - window.addEventListener("load", () => { - const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; + window.addEventListener('load', () => { + const swUrl = `${process.env.PUBLIC_URL}/service-worker.js` if (isLocalhost) { // This is running on localhost. Let's check if a service worker still exists or not. - checkValidServiceWorker(swUrl, config); + checkValidServiceWorker(swUrl, config) // Add some additional logging to localhost, pointing developers to the // service worker/PWA documentation. navigator.serviceWorker.ready.then(() => { console.log( - "This web app is being served cache-first by a service " + - "worker. To learn more, visit https://goo.gl/SC7cgQ" - ); - }); + 'This web app is being served cache-first by a service ' + + 'worker. To learn more, visit https://goo.gl/SC7cgQ' + ) + }) } else { // Is not local host. Just register service worker - registerValidSW(swUrl, config); + registerValidSW(swUrl, config) } - }); + }) } } @@ -57,38 +55,38 @@ function registerValidSW(swUrl, config) { .register(swUrl) .then(registration => { registration.onupdatefound = () => { - const installingWorker = registration.installing; + const installingWorker = registration.installing installingWorker.onstatechange = () => { - if (installingWorker.state === "installed") { + if (installingWorker.state === 'installed') { if (navigator.serviceWorker.controller) { // At this point, the old content will have been purged and // the fresh content will have been added to the cache. // It's the perfect time to display a "New content is // available; please refresh." message in your web app. - console.log("New content is available; please refresh."); + console.log('New content is available; please refresh.') // Execute callback if (config.onUpdate) { - config.onUpdate(registration); + config.onUpdate(registration) } } else { // At this point, everything has been precached. // It's the perfect time to display a // "Content is cached for offline use." message. - console.log("Content is cached for offline use."); + console.log('Content is cached for offline use.') // Execute callback if (config.onSuccess) { - config.onSuccess(registration); + config.onSuccess(registration) } } } - }; - }; + } + } }) .catch(error => { - console.error("Error during service worker registration:", error); - }); + console.error('Error during service worker registration:', error) + }) } function checkValidServiceWorker(swUrl, config) { @@ -98,30 +96,28 @@ function checkValidServiceWorker(swUrl, config) { // Ensure service worker exists, and that we really are getting a JS file. if ( response.status === 404 || - response.headers.get("content-type").indexOf("javascript") === -1 + response.headers.get('content-type').indexOf('javascript') === -1 ) { // No service worker found. Probably a different app. Reload the page. navigator.serviceWorker.ready.then(registration => { registration.unregister().then(() => { - window.location.reload(); - }); - }); + window.location.reload() + }) + }) } else { // Service worker found. Proceed as normal. - registerValidSW(swUrl, config); + registerValidSW(swUrl, config) } }) .catch(() => { - console.log( - "No internet connection found. App is running in offline mode." - ); - }); + console.log('No internet connection found. App is running in offline mode.') + }) } export function unregister() { - if ("serviceWorker" in navigator) { + if ('serviceWorker' in navigator) { navigator.serviceWorker.ready.then(registration => { - registration.unregister(); - }); + registration.unregister() + }) } } diff --git a/packages/tamiko/src/index.js b/packages/tamiko/src/index.js index 9281e727803..734b34046e5 100644 --- a/packages/tamiko/src/index.js +++ b/packages/tamiko/src/index.js @@ -1,13 +1,13 @@ -import freesewing from "@freesewing/core"; -import plugins from "@freesewing/plugin-bundle"; -import config from "../config"; +import freesewing from '@freesewing/core' +import plugins from '@freesewing/plugin-bundle' +import config from '../config' // Parts -import draftTop from "./top"; +import draftTop from './top' // Create design -const Pattern = new freesewing.Design(config, plugins); +const Pattern = new freesewing.Design(config, plugins) // Part draft method -Pattern.prototype.draftTop = part => draftTop(part); +Pattern.prototype.draftTop = part => draftTop(part) -export default Pattern; +export default Pattern diff --git a/packages/tamiko/src/top.js b/packages/tamiko/src/top.js index 10efc8b2c9d..5ddccdc4c59 100644 --- a/packages/tamiko/src/top.js +++ b/packages/tamiko/src/top.js @@ -12,74 +12,62 @@ export default function(part) { complete, paperless, macro - } = part.shorthand(); + } = part.shorthand() // Width at shoulders - let shoulders = measurements.shoulderToShoulder; + let shoulders = measurements.shoulderToShoulder // Width at chest - let chest = (measurements.chestCircumference / 2) * (1 + options.chestEase); + let chest = (measurements.chestCircumference / 2) * (1 + options.chestEase) // Length let length = (1 + options.lengthBonus) * - (measurements.centerBackNeckToWaist + measurements.naturalWaistToHip); + (measurements.centerBackNeckToWaist + measurements.naturalWaistToHip) // Armhole depth - let arm = shoulders * options.armholeDepthFactor; + let arm = shoulders * options.armholeDepthFactor // Shoulder seam length - let shoulderseam = shoulders * options.shoulderseamLength; + let shoulderseam = shoulders * options.shoulderseamLength // Right shoulder seam - points.shoulderEdge = new Point(0, 0); + points.shoulderEdge = new Point(0, 0) // Sew 5mm from edge, can't really scale this one with % - points.armgapTop = new Point(5, 0); - points.armgapNeck = points.armgapTop.shift(-90, shoulderseam); + points.armgapTop = new Point(5, 0) + points.armgapNeck = points.armgapTop.shift(-90, shoulderseam) // Armhole - points.bottomLeft = new Point(0, shoulders); - points.armholeTop = new Point(shoulders / 4, shoulders); - points.armholeBottom = points.armholeTop.shift(0, arm); - points.armholePitch = points.armholeTop.shift(0, arm / 2).shift(90, arm / 5); - points.armholePitchCp1 = points.armholePitch.shift(180, arm / 2.5); - points.armholePitchCp2 = points.armholePitchCp1.flipX(points.armholePitch); + points.bottomLeft = new Point(0, shoulders) + points.armholeTop = new Point(shoulders / 4, shoulders) + points.armholeBottom = points.armholeTop.shift(0, arm) + points.armholePitch = points.armholeTop.shift(0, arm / 2).shift(90, arm / 5) + points.armholePitchCp1 = points.armholePitch.shift(180, arm / 2.5) + points.armholePitchCp2 = points.armholePitchCp1.flipX(points.armholePitch) // Left shoulder seam points.armholeNeck = points.armholeTop .shiftTowards(points.armgapNeck, shoulders * options.shoulderseamLength) - .rotate(options.shoulderSlope, points.armholeTop); + .rotate(options.shoulderSlope, points.armholeTop) // Side seam - points.armgapBottom = points.armgapTop.shift(0, arm); - points.armgapBottom = points.armholeBottom.shiftTowards( - points.armgapBottom, - chest - ); - points.sideBottom = points.armgapTop.shiftTowards( - points.armgapBottom, - length - ); - points.sideEdge = points.armgapTop.shiftTowards(points.armgapBottom, length); + points.armgapBottom = points.armgapTop.shift(0, arm) + points.armgapBottom = points.armholeBottom.shiftTowards(points.armgapBottom, chest) + points.sideBottom = points.armgapTop.shiftTowards(points.armgapBottom, length) + points.sideEdge = points.armgapTop.shiftTowards(points.armgapBottom, length) // Rotate to reduce flare and balance garment - let angle = points.armgapTop.angle(points.armgapBottom) / -2; - points.sideBottom = points.sideBottom.rotate( - angle + options.flare, - points.armgapBottom - ); + let angle = points.armgapTop.angle(points.armgapBottom) / -2 + points.sideBottom = points.sideBottom.rotate(angle + options.flare, points.armgapBottom) // Top edge of garment - points.sideEdge = points.armgapBottom.shiftFractionTowards( - points.sideBottom, - 1.1 - ); + points.sideEdge = points.armgapBottom.shiftFractionTowards(points.sideBottom, 1.1) // Finish rectangle - points.bottomRight = points.armholeTop.shift(0, length); - points.topRight = new Point(points.bottomRight.x, points.sideEdge.y); - points.topLeft = new Point(0, points.topRight.y); - points.topRight = new Point(points.bottomRight.x, points.topLeft.y); + points.bottomRight = points.armholeTop.shift(0, length) + points.topRight = new Point(points.bottomRight.x, points.sideEdge.y) + points.topLeft = new Point(0, points.topRight.y) + points.topRight = new Point(points.bottomRight.x, points.topLeft.y) // Seamline paths.seam = new Path() @@ -98,36 +86,27 @@ export default function(part) { .line(points.armholeNeck) .move(points.armgapBottom) .line(points.sideBottom) - .attr("class", "fabric"); + .attr('class', 'fabric') // Complete pattern? if (complete) { - macro("cutonfold", { + macro('cutonfold', { from: points.bottomRight, to: points.bottomLeft, grainline: true, offset: points.armholeTop.dy(points.armholePitch) * 1.1, margin: 3 - }); - points.title = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5); - macro("title", { at: points.title, nr: 1, title: "top" }); - points.logo = points.topLeft.shiftFractionTowards(points.bottomRight, 0.15); - snippets.logo = new Snippet("logo", points.logo); - points.scalebox = points.topLeft.shiftFractionTowards( - points.bottomRight, - 0.65 - ); - macro("scalebox", { at: points.scalebox }); - macro("sprinkle", { - snippet: "notch", - on: [ - "armgapTop", - "armgapNeck", - "armgapBottom", - "armholeNeck", - "sideBottom" - ] - }); + }) + points.title = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5) + macro('title', { at: points.title, nr: 1, title: 'top' }) + points.logo = points.topLeft.shiftFractionTowards(points.bottomRight, 0.15) + snippets.logo = new Snippet('logo', points.logo) + points.scalebox = points.topLeft.shiftFractionTowards(points.bottomRight, 0.65) + macro('scalebox', { at: points.scalebox }) + macro('sprinkle', { + snippet: 'notch', + on: ['armgapTop', 'armgapNeck', 'armgapBottom', 'armholeNeck', 'sideBottom'] + }) if (sa) { paths.sa = new Path() @@ -135,73 +114,73 @@ export default function(part) { ._curve(points.armholePitchCp1, points.armholePitch) .curve_(points.armholePitchCp2, points.armholeBottom) .offset(sa) - .attr("class", "sa fabric"); + .attr('class', 'sa fabric') } } // Paperless? if (paperless) { - macro("hd", { + macro('hd', { from: points.topLeft, to: points.armgapBottom, y: points.topLeft.y - 15 - }); - macro("hd", { + }) + macro('hd', { from: points.topLeft, to: points.sideBottom, y: points.topLeft.y - 30 - }); - macro("hd", { + }) + macro('hd', { from: points.topLeft, to: points.topRight, y: points.topLeft.y - 45 - }); - macro("vd", { + }) + macro('vd', { from: points.sideBottom, to: points.topLeft, x: points.sideBottom.x + 15 - }); - macro("vd", { + }) + macro('vd', { from: points.armgapBottom, to: points.topLeft, x: points.topLeft.x - 15 - }); - macro("vd", { + }) + macro('vd', { from: points.armgapTop, to: points.topLeft, x: points.topLeft.x - 30 - }); - macro("vd", { + }) + macro('vd', { from: points.bottomLeft, to: points.topLeft, x: points.topLeft.x - 45 - }); - macro("vd", { + }) + macro('vd', { from: points.armgapNeck, to: points.armgapTop, x: points.armgapTop.x + 15 - }); - macro("hd", { + }) + macro('hd', { from: points.bottomLeft, to: points.armholeNeck, y: points.bottomLeft.y + 15 - }); - macro("hd", { + }) + macro('hd', { from: points.bottomLeft, to: points.armholeTop, y: points.bottomLeft.y + 30 - }); - macro("hd", { + }) + macro('hd', { from: points.armholeTop, to: points.armholeBottom, y: points.bottomLeft.y + 30 - }); - macro("vd", { + }) + macro('vd', { from: points.armholeTop, to: points.armholePitch, x: points.armholePitch.x - }); + }) } - return part; + return part } diff --git a/packages/theo/example/src/App.js b/packages/theo/example/src/App.js index e7936330e5d..115cdf683af 100644 --- a/packages/theo/example/src/App.js +++ b/packages/theo/example/src/App.js @@ -1,22 +1,15 @@ -import React from "react"; -import freesewing from "@freesewing/core"; -import Workbench from "@freesewing/components/Workbench"; -import "typeface-roboto-condensed"; -import "@freesewing/css-theme"; +import React from 'react' +import freesewing from '@freesewing/core' +import Workbench from '@freesewing/components/Workbench' +import 'typeface-roboto-condensed' +import '@freesewing/css-theme' -import Pattern from "pattern"; +import Pattern from 'pattern' const App = props => { - let instance = new Pattern(); - let config = instance.config; - return ( - - ); -}; + let instance = new Pattern() + let config = instance.config + return +} -export default App; +export default App diff --git a/packages/theo/example/src/index.js b/packages/theo/example/src/index.js index 7900787a4d2..9dd7ba788d4 100644 --- a/packages/theo/example/src/index.js +++ b/packages/theo/example/src/index.js @@ -1,11 +1,11 @@ -import React from "react"; -import ReactDOM from "react-dom"; -import App from "./App"; -import * as serviceWorker from "./serviceWorker"; +import React from 'react' +import ReactDOM from 'react-dom' +import App from './App' +import * as serviceWorker from './serviceWorker' -ReactDOM.render(, document.getElementById("root")); +ReactDOM.render(, document.getElementById('root')) // If you want your app to work offline and load faster, you can change // unregister() to register() below. Note this comes with some pitfalls. // Learn more about service workers: http://bit.ly/CRA-PWA -serviceWorker.unregister(); +serviceWorker.unregister() diff --git a/packages/theo/example/src/serviceWorker.js b/packages/theo/example/src/serviceWorker.js index 68fda5a0eb6..44e1b1b2f8c 100644 --- a/packages/theo/example/src/serviceWorker.js +++ b/packages/theo/example/src/serviceWorker.js @@ -9,46 +9,44 @@ // This link also includes instructions on opting out of this behavior. const isLocalhost = Boolean( - window.location.hostname === "localhost" || + window.location.hostname === 'localhost' || // [::1] is the IPv6 localhost address. - window.location.hostname === "[::1]" || + window.location.hostname === '[::1]' || // 127.0.0.1/8 is considered localhost for IPv4. - window.location.hostname.match( - /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ - ) -); + window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/) +) export function register(config) { - if (process.env.NODE_ENV === "production" && "serviceWorker" in navigator) { + if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) { // The URL constructor is available in all browsers that support SW. - const publicUrl = new URL(process.env.PUBLIC_URL, window.location); + const publicUrl = new URL(process.env.PUBLIC_URL, window.location) if (publicUrl.origin !== window.location.origin) { // Our service worker won't work if PUBLIC_URL is on a different origin // from what our page is served on. This might happen if a CDN is used to // serve assets; see https://github.com/facebook/create-react-app/issues/2374 - return; + return } - window.addEventListener("load", () => { - const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; + window.addEventListener('load', () => { + const swUrl = `${process.env.PUBLIC_URL}/service-worker.js` if (isLocalhost) { // This is running on localhost. Let's check if a service worker still exists or not. - checkValidServiceWorker(swUrl, config); + checkValidServiceWorker(swUrl, config) // Add some additional logging to localhost, pointing developers to the // service worker/PWA documentation. navigator.serviceWorker.ready.then(() => { console.log( - "This web app is being served cache-first by a service " + - "worker. To learn more, visit https://goo.gl/SC7cgQ" - ); - }); + 'This web app is being served cache-first by a service ' + + 'worker. To learn more, visit https://goo.gl/SC7cgQ' + ) + }) } else { // Is not local host. Just register service worker - registerValidSW(swUrl, config); + registerValidSW(swUrl, config) } - }); + }) } } @@ -57,38 +55,38 @@ function registerValidSW(swUrl, config) { .register(swUrl) .then(registration => { registration.onupdatefound = () => { - const installingWorker = registration.installing; + const installingWorker = registration.installing installingWorker.onstatechange = () => { - if (installingWorker.state === "installed") { + if (installingWorker.state === 'installed') { if (navigator.serviceWorker.controller) { // At this point, the old content will have been purged and // the fresh content will have been added to the cache. // It's the perfect time to display a "New content is // available; please refresh." message in your web app. - console.log("New content is available; please refresh."); + console.log('New content is available; please refresh.') // Execute callback if (config.onUpdate) { - config.onUpdate(registration); + config.onUpdate(registration) } } else { // At this point, everything has been precached. // It's the perfect time to display a // "Content is cached for offline use." message. - console.log("Content is cached for offline use."); + console.log('Content is cached for offline use.') // Execute callback if (config.onSuccess) { - config.onSuccess(registration); + config.onSuccess(registration) } } } - }; - }; + } + } }) .catch(error => { - console.error("Error during service worker registration:", error); - }); + console.error('Error during service worker registration:', error) + }) } function checkValidServiceWorker(swUrl, config) { @@ -98,30 +96,28 @@ function checkValidServiceWorker(swUrl, config) { // Ensure service worker exists, and that we really are getting a JS file. if ( response.status === 404 || - response.headers.get("content-type").indexOf("javascript") === -1 + response.headers.get('content-type').indexOf('javascript') === -1 ) { // No service worker found. Probably a different app. Reload the page. navigator.serviceWorker.ready.then(registration => { registration.unregister().then(() => { - window.location.reload(); - }); - }); + window.location.reload() + }) + }) } else { // Service worker found. Proceed as normal. - registerValidSW(swUrl, config); + registerValidSW(swUrl, config) } }) .catch(() => { - console.log( - "No internet connection found. App is running in offline mode." - ); - }); + console.log('No internet connection found. App is running in offline mode.') + }) } export function unregister() { - if ("serviceWorker" in navigator) { + if ('serviceWorker' in navigator) { navigator.serviceWorker.ready.then(registration => { - registration.unregister(); - }); + registration.unregister() + }) } } diff --git a/packages/theo/src/back-inner-pocket-bag.js b/packages/theo/src/back-inner-pocket-bag.js index e184ce56281..2a8d7343814 100644 --- a/packages/theo/src/back-inner-pocket-bag.js +++ b/packages/theo/src/back-inner-pocket-bag.js @@ -9,38 +9,32 @@ export default function(part) { complete, sa, paperless - } = part.shorthand(); + } = part.shorthand() - let width = measurements.hipsCircumference * 0.16; - let height = width * 1.43; + let width = measurements.hipsCircumference * 0.16 + let height = width * 1.43 - points.topRight = new Point(width / 2, 0); - points.topLeft = points.topRight.flipX(); - points.bottomRight = new Point(width / 2, height); - points.bottomLeft = points.bottomRight.flipX(); - points.weltLeft = new Point( - points.topLeft.x + 15, - points.topLeft.y + width / 3 - ); - points.weltRight = new Point( - points.topRight.x - 15, - points.topRight.y + width / 3 - ); + points.topRight = new Point(width / 2, 0) + points.topLeft = points.topRight.flipX() + points.bottomRight = new Point(width / 2, height) + points.bottomLeft = points.bottomRight.flipX() + points.weltLeft = new Point(points.topLeft.x + 15, points.topLeft.y + width / 3) + points.weltRight = new Point(points.topRight.x - 15, points.topRight.y + width / 3) - macro("round", { + macro('round', { from: points.topLeft, to: points.bottomRight, via: points.bottomLeft, radius: width / 12, - prefix: "left" - }); - macro("round", { + prefix: 'left' + }) + macro('round', { from: points.bottomLeft, to: points.topRight, via: points.bottomRight, radius: width / 12, - prefix: "right" - }); + prefix: 'right' + }) paths.seam = new Path() .move(points.topLeft) @@ -51,47 +45,47 @@ export default function(part) { .line(points.topRight) .line(points.topLeft) .close() - .attr("class", "lining"); + .attr('class', 'lining') paths.welt = new Path() .move(points.weltLeft) .line(points.weltRight) - .attr("class", "lining dashed"); + .attr('class', 'lining dashed') // Complete pattern? if (complete) { - if (sa) paths.sa = paths.seam.offset(sa).attr("class", "lining sa"); - points.title = new Point(0, height / 2); - macro("title", { at: points.title, title: "backInnerPocketBag", nr: 10 }); - points.grainlineTop = new Point(width / -3, 0); - points.grainlineBottom = new Point(width / -3, height); - macro("grainline", { + if (sa) paths.sa = paths.seam.offset(sa).attr('class', 'lining sa') + points.title = new Point(0, height / 2) + macro('title', { at: points.title, title: 'backInnerPocketBag', nr: 10 }) + points.grainlineTop = new Point(width / -3, 0) + points.grainlineBottom = new Point(width / -3, height) + macro('grainline', { from: points.grainlineBottom, to: points.grainlineTop - }); - macro("sprinkle", { - snippet: "notch", - on: ["weltLeft", "weltRight"] - }); + }) + macro('sprinkle', { + snippet: 'notch', + on: ['weltLeft', 'weltRight'] + }) } // Paperless? if (paperless) { - macro("hd", { + macro('hd', { from: points.weltLeft, to: points.weltRight, y: points.weltLeft.y + 15 - }); - macro("hd", { + }) + macro('hd', { from: points.leftStart, to: points.rightEnd, y: points.leftEnd.y + sa + 15 - }); - macro("vd", { + }) + macro('vd', { from: points.rightStart, to: points.topRight, x: points.topRight.x + sa + 15 - }); + }) } - return part; + return part } diff --git a/packages/theo/src/back-outer-pocket-bag.js b/packages/theo/src/back-outer-pocket-bag.js index 0d2a702d367..9eb1a8bc89a 100644 --- a/packages/theo/src/back-outer-pocket-bag.js +++ b/packages/theo/src/back-outer-pocket-bag.js @@ -1,17 +1,9 @@ export default function(part) { - let { - macro, - points, - Path, - paths, - complete, - sa, - paperless - } = part.shorthand(); + let { macro, points, Path, paths, complete, sa, paperless } = part.shorthand() // Make bag 2cm longer - points.topRight = points.topRight.shift(90, 20); - points.topLeft = points.topLeft.shift(90, 20); + points.topRight = points.topRight.shift(90, 20) + points.topLeft = points.topLeft.shift(90, 20) paths.seam = new Path() .move(points.topLeft) @@ -22,21 +14,21 @@ export default function(part) { .line(points.topRight) .line(points.topLeft) .close() - .attr("class", "lining"); + .attr('class', 'lining') paths.welt = new Path() .move(points.weltLeft) .line(points.weltRight) - .attr("class", "lining dashed"); + .attr('class', 'lining dashed') // Complete pattern? if (complete) { - if (sa) paths.sa = paths.seam.offset(sa).attr("class", "lining sa"); - macro("title", { at: points.title, title: "backInnerPocketBag", nr: 11 }); + if (sa) paths.sa = paths.seam.offset(sa).attr('class', 'lining sa') + macro('title', { at: points.title, title: 'backInnerPocketBag', nr: 11 }) } // Paperless? if (paperless) { } - return part; + return part } diff --git a/packages/theo/src/back-pocket-facing.js b/packages/theo/src/back-pocket-facing.js index 28c3aa73a34..a38ddf94825 100644 --- a/packages/theo/src/back-pocket-facing.js +++ b/packages/theo/src/back-pocket-facing.js @@ -1,30 +1,15 @@ export default function(part) { - let { - macro, - measurements, - Point, - points, - Path, - paths, - complete, - paperless - } = part.shorthand(); + let { macro, measurements, Point, points, Path, paths, complete, paperless } = part.shorthand() - let width = measurements.hipsCircumference * 0.16; - let height = width / 2; + let width = measurements.hipsCircumference * 0.16 + let height = width / 2 - points.topRight = new Point(width / 2, 0); - points.topLeft = points.topRight.flipX(); - points.bottomRight = new Point(width / 2, height); - points.bottomLeft = points.bottomRight.flipX(); - points.weltLeft = new Point( - points.topLeft.x + 15, - points.topLeft.y + height / 2 - ); - points.weltRight = new Point( - points.topRight.x - 15, - points.topRight.y + height / 2 - ); + points.topRight = new Point(width / 2, 0) + points.topLeft = points.topRight.flipX() + points.bottomRight = new Point(width / 2, height) + points.bottomLeft = points.bottomRight.flipX() + points.weltLeft = new Point(points.topLeft.x + 15, points.topLeft.y + height / 2) + points.weltRight = new Point(points.topRight.x - 15, points.topRight.y + height / 2) paths.seam = new Path() .move(points.topLeft) @@ -33,47 +18,41 @@ export default function(part) { .line(points.topRight) .line(points.topLeft) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') paths.welt = new Path() .move(points.weltLeft) .line(points.weltRight) - .attr("class", "fabric dashed"); + .attr('class', 'fabric dashed') // Complete pattern? if (complete) { - points.title = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5); - macro("title", { at: points.title, title: "backPocketFacing", nr: 12 }); - points.grainlineTop = points.topLeft.shiftFractionTowards( - points.topRight, - 0.2 - ); - points.grainlineBottom = new Point( - points.grainlineTop.x, - points.bottomLeft.y - ); - macro("grainline", { + points.title = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5) + macro('title', { at: points.title, title: 'backPocketFacing', nr: 12 }) + points.grainlineTop = points.topLeft.shiftFractionTowards(points.topRight, 0.2) + points.grainlineBottom = new Point(points.grainlineTop.x, points.bottomLeft.y) + macro('grainline', { from: points.grainlineBottom, to: points.grainlineTop - }); - macro("sprinkle", { - snippet: "notch", - on: ["weltLeft", "weltRight"] - }); + }) + macro('sprinkle', { + snippet: 'notch', + on: ['weltLeft', 'weltRight'] + }) } // Paperless? if (paperless) { - macro("hd", { + macro('hd', { from: points.bottomLeft, to: points.bottomRight, y: points.bottomLeft.y + 15 - }); - macro("vd", { + }) + macro('vd', { from: points.bottomRight, to: points.topRight, x: points.bottomRight.x + 15 - }); + }) } - return part; + return part } diff --git a/packages/theo/src/back-pocket-interfacing.js b/packages/theo/src/back-pocket-interfacing.js index fba8ffa4972..ff178fb4598 100644 --- a/packages/theo/src/back-pocket-interfacing.js +++ b/packages/theo/src/back-pocket-interfacing.js @@ -1,22 +1,22 @@ export default function(part) { - let { macro, points, paths, complete, paperless } = part.shorthand(); + let { macro, points, paths, complete, paperless } = part.shorthand() - paths.seam.attributes.set("class", "interfacing"); - paths.welt.attributes.set("class", "interfacing dashed"); + paths.seam.attributes.set('class', 'interfacing') + paths.welt.attributes.set('class', 'interfacing dashed') // Complete pattern? if (complete) { - macro("title", { + macro('title', { at: points.title, - title: "backPocketInterfacing", + title: 'backPocketInterfacing', nr: 13 - }); - macro("grainline", false); + }) + macro('grainline', false) } // Paperless? if (paperless) { } - return part; + return part } diff --git a/packages/theo/src/back.js b/packages/theo/src/back.js index 774ed37a68f..15e74caf5d1 100644 --- a/packages/theo/src/back.js +++ b/packages/theo/src/back.js @@ -14,262 +14,178 @@ export default function(part) { measurements, snippets, Snippet - } = part.shorthand(); + } = part.shorthand() const calculateSlashCorner = () => { - points[901] = utils.beamsIntersect( - points[20], - points[19], - points[26], - points[4] - ); - points[902] = points[901].clone(); - const step = -0.1; - let i = 0; + points[901] = utils.beamsIntersect(points[20], points[19], points[26], points[4]) + points[902] = points[901].clone() + const step = -0.1 + let i = 0 while (points[901].dist(points[902]) < 25) { - i++; - points[902] = points[901].rotate(i * step, points[26]); + i++ + points[902] = points[901].rotate(i * step, points[26]) } - return i * step; - }; + return i * step + } // Store - store.set("lengthBonus", measurements.inseam * options.lengthBonus); - store.set( - "backReduction", - (measurements.hipsCircumference / -4) * options.wedge - ); - store.set( - "legWidth", - (measurements.kneeCircumference * (1 + options.legWidth)) / 2 - ); - store.set("backRise", measurements.hipsCircumference * options.backRise); + store.set('lengthBonus', measurements.inseam * options.lengthBonus) + store.set('backReduction', (measurements.hipsCircumference / -4) * options.wedge) + store.set('legWidth', (measurements.kneeCircumference * (1 + options.legWidth)) / 2) + store.set('backRise', measurements.hipsCircumference * options.backRise) // Points - points[0] = new Point(0, 0); - points[1] = new Point(0, measurements.seatDepth - options.waistbandWidth); - points[2] = new Point( - 0, - points[1].y + measurements.inseam + store.get("lengthBonus") - ); - points[201] = points[2].shift(-90, 10); - points[202] = new Point(store.get("legWidth") / 4, points[201].y); - points[203] = points[202].flipX(); - points[3] = new Point(0, points[1].y + measurements.inseam / 2 + 50); - points[4] = new Point(0, points[1].y - measurements.seatDepth / 4); - points[5] = new Point(10 - measurements.seatCircumference / 8, points[1].y); + points[0] = new Point(0, 0) + points[1] = new Point(0, measurements.seatDepth - options.waistbandWidth) + points[2] = new Point(0, points[1].y + measurements.inseam + store.get('lengthBonus')) + points[201] = points[2].shift(-90, 10) + points[202] = new Point(store.get('legWidth') / 4, points[201].y) + points[203] = points[202].flipX() + points[3] = new Point(0, points[1].y + measurements.inseam / 2 + 50) + points[4] = new Point(0, points[1].y - measurements.seatDepth / 4) + points[5] = new Point(10 - measurements.seatCircumference / 8, points[1].y) points[9] = new Point( - points[5].x - - measurements.seatCircumference / 16 - - 5 + - store.get("backReduction"), + points[5].x - measurements.seatCircumference / 16 - 5 + store.get('backReduction'), points[5].y - ); - points[16] = new Point( - points[5].x - points[1].dx(points[5]) / 4, - points[5].y - ); - points[1601] = points[16].shift(135, 45); - points[1602] = points[1601].shift(45, 25); - points[1603] = points[1601].shift(-135, 45); - points[17] = new Point(points[16].x, points[4].y); - points[18] = new Point(points[16].x, 0); - points[19] = new Point( - points[16].x, - points[16].y + points[16].dy(points[18]) / 2 - ); - points[20] = new Point(points[18].x + 20, points[18].y); - points[1901] = points[20].shiftOutwards(points[19], 25); - points[21] = points[19].shiftOutwards(points[20], 10); + ) + points[16] = new Point(points[5].x - points[1].dx(points[5]) / 4, points[5].y) + points[1601] = points[16].shift(135, 45) + points[1602] = points[1601].shift(45, 25) + points[1603] = points[1601].shift(-135, 45) + points[17] = new Point(points[16].x, points[4].y) + points[18] = new Point(points[16].x, 0) + points[19] = new Point(points[16].x, points[16].y + points[16].dy(points[18]) / 2) + points[20] = new Point(points[18].x + 20, points[18].y) + points[1901] = points[20].shiftOutwards(points[19], 25) + points[21] = points[19].shiftOutwards(points[20], 10) points[22] = new Point( - points[9].x + points[5].dx(points[9]) / 2 - 5 + store.get("backReduction"), + points[9].x + points[5].dx(points[9]) / 2 - 5 + store.get('backReduction'), points[9].y - ); - points[23] = new Point(points[22].x, points[22].y + 5); - points[24] = new Point( - points[20].x + measurements.hipsCircumference / 4 + 45, - points[20].y - ); - points[25] = points[21].shiftFractionTowards(points[24], 0.5); - points[2501] = points[25].shiftTowards(points[24], 120); - points[2502] = points[2501].rotate(-90, points[25]); - points[2503] = points[25].shiftTowards(points[24], 12.5); - points[2504] = points[25].shiftTowards(points[21], 12.5); - points[26] = new Point( - points[17].x + measurements.seatCircumference / 4 + 30, - points[17].y - ); - points[2601] = points[24].shiftFractionTowards(points[26], 1, 4); - points[27] = new Point( - points[2].x + store.get("legWidth") / 2 + 20, - points[2].y - ); - points[2701] = new Point(points[27].x, points[27].y - 50); - points[2702] = points[2701].flipX(); - points[28] = points[27].flipX(); - points[29] = new Point( - points[3].x + store.get("legWidth") / 2 + 15 + 20, - points[3].y - ); - points[2901] = points[27].shiftFractionTowards(points[29], 1.6); - points[30] = points[29].flipX(); - points[3001] = points[28].shiftFractionTowards(points[30], 1.6); + ) + points[23] = new Point(points[22].x, points[22].y + 5) + points[24] = new Point(points[20].x + measurements.hipsCircumference / 4 + 45, points[20].y) + points[25] = points[21].shiftFractionTowards(points[24], 0.5) + points[2501] = points[25].shiftTowards(points[24], 120) + points[2502] = points[2501].rotate(-90, points[25]) + points[2503] = points[25].shiftTowards(points[24], 12.5) + points[2504] = points[25].shiftTowards(points[21], 12.5) + points[26] = new Point(points[17].x + measurements.seatCircumference / 4 + 30, points[17].y) + points[2601] = points[24].shiftFractionTowards(points[26], 1, 4) + points[27] = new Point(points[2].x + store.get('legWidth') / 2 + 20, points[2].y) + points[2701] = new Point(points[27].x, points[27].y - 50) + points[2702] = points[2701].flipX() + points[28] = points[27].flipX() + points[29] = new Point(points[3].x + store.get('legWidth') / 2 + 15 + 20, points[3].y) + points[2901] = points[27].shiftFractionTowards(points[29], 1.6) + points[30] = points[29].flipX() + points[3001] = points[28].shiftFractionTowards(points[30], 1.6) // Slash and rotate around point 26 - let corner = calculateSlashCorner(); - const rotateThese = [24, 2501, 2502, 2503, 2504, 25, 21, 20, 19, 1901, 2601]; + let corner = calculateSlashCorner() + const rotateThese = [24, 2501, 2502, 2503, 2504, 25, 21, 20, 19, 1901, 2601] for (let id of rotateThese) { - let newId = "90" + id; - points[newId] = points[id].rotate(corner, points[26]); + let newId = '90' + id + points[newId] = points[id].rotate(corner, points[26]) } // These need to be moved 1cm to the left as per instructions after slash - points[901601] = points[1601].shift(180, 10); - points[901602] = points[1602].shift(180, 10); - points[901603] = points[1603].shift(180, 10); + points[901601] = points[1601].shift(180, 10) + points[901602] = points[1602].shift(180, 10) + points[901603] = points[1603].shift(180, 10) // Add endpoint for pleat line - points[900] = utils.beamsIntersect( - points[9021], - points[9024], - points[0], - points[1] - ); + points[900] = utils.beamsIntersect(points[9021], points[9024], points[0], points[1]) // Points without seam allowance - points[-21] = points[9021].shiftTowards(points[902504], 10); - points[-2101] = points[-21].shift(points[9020].angle(points[9021]), -10); - points[-24] = points[9024].shiftTowards(points[9021], 10); - points[-2104] = points[-24].shift(points[9024].angle(points[26]), 10); - points[-2501] = points[902504].shiftTowards(points[902502], 10); - points[-2502] = points[902503].shiftTowards(points[902502], 10); - points[-2503] = points[902504].shiftTowards(points[902502], 60); - points[-2504] = points[902503].shiftTowards(points[902502], 60); - points[-26] = points[26].shift(points[9024].angle(points[9021]), 10); - points[-2601] = points[-2104].shiftFractionTowards(points[-26], 1.4); - points[-2901] = points[2901].shift(points[2901].angle(points[29]) - 90, 10); - points[-29] = points[29].shift(points[2901].angle(points[29]) - 90, 10); - points[-2701] = points[2701].shift(180, 10); + points[-21] = points[9021].shiftTowards(points[902504], 10) + points[-2101] = points[-21].shift(points[9020].angle(points[9021]), -10) + points[-24] = points[9024].shiftTowards(points[9021], 10) + points[-2104] = points[-24].shift(points[9024].angle(points[26]), 10) + points[-2501] = points[902504].shiftTowards(points[902502], 10) + points[-2502] = points[902503].shiftTowards(points[902502], 10) + points[-2503] = points[902504].shiftTowards(points[902502], 60) + points[-2504] = points[902503].shiftTowards(points[902502], 60) + points[-26] = points[26].shift(points[9024].angle(points[9021]), 10) + points[-2601] = points[-2104].shiftFractionTowards(points[-26], 1.4) + points[-2901] = points[2901].shift(points[2901].angle(points[29]) - 90, 10) + points[-29] = points[29].shift(points[2901].angle(points[29]) - 90, 10) + points[-2701] = points[2701].shift(180, 10) points[-27] = new Path() .move(points[27]) ._curve(points[202], points[201]) - .shiftAlong(10); - points[-28] = points[-27].flipX(); - points[-2702] = points[-2701].flipX(); - points[-30] = points[-29].flipX(); - points[-3001] = points[3001].shift(points[30].angle(points[3001]) + 90, -10); + .shiftAlong(10) + points[-28] = points[-27].flipX() + points[-2702] = points[-2701].flipX() + points[-30] = points[-29].flipX() + points[-3001] = points[3001].shift(points[30].angle(points[3001]) + 90, -10) points[-23] = new Path() .move(points[23]) ._curve(points[901603], points[901601]) - .shiftAlong(10); + .shiftAlong(10) points[-2301] = new Path() .move(points[-23]) ._curve(points[-3001], points[-30]) - .shiftAlong(10); - points[-900] = new Point(points[900].x, points[900].y + 10); - points[-901603] = points[901603].shift( - points[901603].angle(points[901601]) + 90, - -10 - ); - points[-901601] = points[901601].shift( - points[901603].angle(points[901601]) + 90, - -10 - ); - points[-901602] = points[901602].shift( - points[901603].angle(points[901601]) + 90, - -10 - ); - points[-901901] = points[901901].shift( - points[901601].angle(points[9019]) + 90, - -10 - ); - points[-9019] = points[9019].shift( - points[901901].angle(points[9019]) + 90, - -10 - ); + .shiftAlong(10) + points[-900] = new Point(points[900].x, points[900].y + 10) + points[-901603] = points[901603].shift(points[901603].angle(points[901601]) + 90, -10) + points[-901601] = points[901601].shift(points[901603].angle(points[901601]) + 90, -10) + points[-901602] = points[901602].shift(points[901603].angle(points[901601]) + 90, -10) + points[-901901] = points[901901].shift(points[901601].angle(points[9019]) + 90, -10) + points[-9019] = points[9019].shift(points[901901].angle(points[9019]) + 90, -10) // Extra SA at back seam - points[9021] = points[-21].shift(points[-2501].angle(points[-2101]), 40); + points[9021] = points[-21].shift(points[-2501].angle(points[-2101]), 40) // Extra SA at hem - points[-2710] = points[-27].shift(-90, 60); - points[-2810] = points[-2710].flipX(); - points[-20110] = points[201].shift(-90, 60); - points[-20210] = points[202].shift(-90, 60); - points[-20310] = points[203].shift(-90, 60); + points[-2710] = points[-27].shift(-90, 60) + points[-2810] = points[-2710].flipX() + points[-20110] = points[201].shift(-90, 60) + points[-20210] = points[202].shift(-90, 60) + points[-20310] = points[203].shift(-90, 60) // Raise waistband - points[66601] = points[-2101].shiftTowards( - points[-21], - store.get("backRise") - ); + points[66601] = points[-2101].shiftTowards(points[-21], store.get('backRise')) // Original dart without raise - points[66602] = utils.beamsIntersect( - points[66601], - points[-2104], - points[902502], - points[-2501] - ); - points[66603] = utils.beamsIntersect( - points[66601], - points[-2104], - points[902502], - points[-2502] - ); - points[66605] = points[-2101].shiftTowards( - points[-21], - store.get("backRise") + 10 - ); + points[66602] = utils.beamsIntersect(points[66601], points[-2104], points[902502], points[-2501]) + points[66603] = utils.beamsIntersect(points[66601], points[-2104], points[902502], points[-2502]) + points[66605] = points[-2101].shiftTowards(points[-21], store.get('backRise') + 10) points[66606] = new Point( points[66602].x + points[66601].dx(points[66605]), points[66602].y + points[66601].dy(points[66605]) - ); - points[66607] = utils.beamsIntersect( - points[66606], - points[66605], - points[901601], - points[9021] - ); + ) + points[66607] = utils.beamsIntersect(points[66606], points[66605], points[901601], points[9021]) // Construct the back dart with raise - points.dartTop = points[66601].shiftFractionTowards(points[-2104], 0.5); + points.dartTop = points[66601].shiftFractionTowards(points[-2104], 0.5) points.dartTip = points.dartTop.shift( points[-2104].angle(points[66601]) + 90, points.dartTop.dist(points[902502]) - ); + ) points.dartTopLeft = points.dartTop.shiftTowards( points[66601], points[66602].dist(points[66603]) / 2 - ); + ) points.dartTopRight = points.dartTop.shiftTowards( points[-2104], points[66602].dist(points[66603]) / 2 - ); + ) // Reconstruct back pocket with raise - points.pocketCenterLeft = points.dartTopLeft.shiftTowards(points.dartTip, 60); - points.pocketCenterRight = points.dartTopRight.shiftTowards( - points.dartTip, - 60 - ); + points.pocketCenterLeft = points.dartTopLeft.shiftTowards(points.dartTip, 60) + points.pocketCenterRight = points.dartTopRight.shiftTowards(points.dartTip, 60) points.pocketEdgeLeft = points.pocketCenterLeft.shift( points.pocketCenterLeft.angle(points.dartTip) - 90, 70 - ); + ) points.pocketEdgeRight = points.pocketCenterRight.shift( points.pocketCenterRight.angle(points.dartTip) + 90, 70 - ); + ) // Extend back pleat to include rise - points[-900] = utils.beamsIntersect( - points[900], - points[-900], - points[66601], - points[66602] - ); + points[-900] = utils.beamsIntersect(points[900], points[-900], points[66601], points[66602]) // Paths // This is the original Aldrich path, which includes seam allowance @@ -289,14 +205,14 @@ export default function(part) { .curve_(points[203], points[28]) .curve_(points[2702], points[30]) .curve_(points[3001], points[23]) - .close(); - paths.aldrich.render = false; + .close() + paths.aldrich.render = false // This is the path we use, no seam allowance paths.hemBase = new Path() .move(points[-27]) ._curve(points[202], points[201]) - .curve_(points[203], points[-28]); + .curve_(points[203], points[-28]) paths.saBase1 = new Path() .move(points[-28]) .curve_(points[-2702], points[-30]) @@ -304,13 +220,13 @@ export default function(part) { ._curve(points[-901603], points[-901601]) .curve(points[-901602], points[-901901], points[-9019]) .line(points[66601]) - .line(points.dartTopLeft); + .line(points.dartTopLeft) paths.saBase2 = new Path() .move(points.dartTopRight) .line(points[-2104]) .line(points[-26]) .curve(points[-2601], points[-2901], points[-29]) - .curve(points[-29], points[-2701], points[-27]); + .curve(points[-29], points[-2701], points[-27]) paths.seam = paths.saBase1 .clone() .line(points.dartTip) @@ -318,14 +234,14 @@ export default function(part) { .join(paths.saBase2) .join(paths.hemBase) .close() - .attr("class", "fabric"); - paths.hemBase.render = false; - paths.saBase1.render = false; - paths.saBase2.render = false; + .attr('class', 'fabric') + paths.hemBase.render = false + paths.saBase1.render = false + paths.saBase2.render = false // Store length of the inseam and side seam store.set( - "backInseamLength", + 'backInseamLength', new Path() .move(points[-2301]) .curve_(points[-3001], points[-30]) @@ -334,9 +250,9 @@ export default function(part) { .move(points[30]) ._curve(points[-2702], points[-28]) .length() - ); + ) store.set( - "backSideseamLength", + 'backSideseamLength', points[-2104].dist(points[-26]) + new Path() .move(points[-26]) @@ -346,7 +262,7 @@ export default function(part) { .move(points[-29]) ._curve(points[-2701], points[-27]) .length() - ); + ) // Complete pattern? if (complete) { @@ -356,111 +272,111 @@ export default function(part) { .join(paths.saBase2.offset(-1 * sa)) .join(paths.hemBase.offset(-3 * sa)) .close() - .attr("class", "fabric sa"); + .attr('class', 'fabric sa') } paths.pocket = new Path() .move(points.pocketEdgeLeft) .line(points.pocketCenterLeft) .move(points.pocketCenterRight) .line(points.pocketEdgeRight) - .attr("class", "fabric dashed"); + .attr('class', 'fabric dashed') - points.grainlineTop = new Point(0, points[-2104].y); - points.grainlineBottom = points[2].clone(); - macro("grainline", { + points.grainlineTop = new Point(0, points[-2104].y) + points.grainlineBottom = points[2].clone() + macro('grainline', { from: points.grainlineBottom, to: points.grainlineTop - }); - points.title = new Point(0, points[-2301].y); - macro("title", { at: points.title, title: "back", nr: 1 }); - points.logo = points.title.shift(-90, 70); - snippets.logo = new Snippet("logo", points.logo); - points.scalebox = points.logo.shift(-90, 70); - macro("scalebox", { at: points.scalebox }); - macro("sprinkle", { - snippet: "notch", - on: ["pocketEdgeLeft", "pocketEdgeRight"] - }); + }) + points.title = new Point(0, points[-2301].y) + macro('title', { at: points.title, title: 'back', nr: 1 }) + points.logo = points.title.shift(-90, 70) + snippets.logo = new Snippet('logo', points.logo) + points.scalebox = points.logo.shift(-90, 70) + macro('scalebox', { at: points.scalebox }) + macro('sprinkle', { + snippet: 'notch', + on: ['pocketEdgeLeft', 'pocketEdgeRight'] + }) } // Paperless? if (paperless) { - macro("ld", { + macro('ld', { from: points[66601], to: points.dartTopLeft, d: sa + 15 - }); - macro("ld", { + }) + macro('ld', { from: points.dartTopLeft, to: points.dartTopRight, d: sa + 15 - }); - macro("ld", { + }) + macro('ld', { from: points[66601], to: points[-2104], d: sa + 30 - }); - macro("ld", { + }) + macro('ld', { from: points.pocketEdgeLeft, to: points.pocketCenterLeft, d: 15 - }); - macro("ld", { + }) + macro('ld', { from: points.pocketCenterRight, to: points.pocketEdgeRight, d: 15 - }); - macro("ld", { + }) + macro('ld', { from: points.dartTip, to: points.dartTop, d: 30 - }); - macro("ld", { + }) + macro('ld', { from: points.dartTip, to: points.pocketCenterRight, d: -15 - }); - macro("hd", { + }) + macro('hd', { from: points[-2301], to: points[66601], y: points[66601].y - sa - 45 - }); - macro("hd", { + }) + macro('hd', { from: points[66601], to: points[-2104], y: points[66601].y - sa - 45 - }); - macro("hd", { + }) + macro('hd', { from: points[-2301], to: points[-2104], y: points[66601].y - sa - 60 - }); - macro("vd", { + }) + macro('vd', { from: points[-2301], to: points[66601], x: points[-2301].x - sa - 15 - }); - macro("vd", { + }) + macro('vd', { from: points[201], to: points[-2301], x: points[-2301].x - sa - 15 - }); - macro("vd", { + }) + macro('vd', { from: points[201], to: points[66601], x: points[-2301].x - sa - 30 - }); - macro("hd", { + }) + macro('hd', { from: points[-28], to: points[-27], y: points[201].y + 3 * sa + 15 - }); - macro("vd", { + }) + macro('vd', { from: points[-27], to: points[-2104], x: points[-2104].x + sa + 15 - }); + }) } - return part; + return part } diff --git a/packages/theo/src/belt-loop.js b/packages/theo/src/belt-loop.js index e8bd92a1c02..713290adb3b 100644 --- a/packages/theo/src/belt-loop.js +++ b/packages/theo/src/belt-loop.js @@ -1,22 +1,13 @@ export default function(part) { - let { - options, - Point, - points, - Path, - paths, - complete, - paperless, - macro - } = part.shorthand(); + let { options, Point, points, Path, paths, complete, paperless, macro } = part.shorthand() - let height = options.waistbandWidth + 30; - let width = (height - 30) / 2; + let height = options.waistbandWidth + 30 + let width = (height - 30) / 2 - points.topRight = new Point(width / 2, 0); - points.topLeft = points.topRight.flipX(); - points.bottomRight = new Point(width / 2, height); - points.bottomLeft = points.bottomRight.flipX(); + points.topRight = new Point(width / 2, 0) + points.topLeft = points.topRight.flipX() + points.bottomRight = new Point(width / 2, height) + points.bottomLeft = points.bottomRight.flipX() paths.seam = new Path() .move(points.topLeft) @@ -25,34 +16,28 @@ export default function(part) { .line(points.topRight) .line(points.topLeft) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') // Complete pattern? if (complete) { - points.title = new Point(0, height / 2); - macro("title", { + points.title = new Point(0, height / 2) + macro('title', { at: points.title, - title: "beltLoop", + title: 'beltLoop', nr: 14, scale: 0.4 - }); - points.grainlineTop = points.topLeft.shiftFractionTowards( - points.topRight, - 0.5 - ); - points.grainlineBottom = new Point( - points.grainlineTop.x, - points.bottomLeft.y - ); - macro("grainline", { + }) + points.grainlineTop = points.topLeft.shiftFractionTowards(points.topRight, 0.5) + points.grainlineBottom = new Point(points.grainlineTop.x, points.bottomLeft.y) + macro('grainline', { from: points.grainlineBottom, to: points.grainlineTop - }); + }) } // Paperless? if (paperless) { } - return part; + return part } diff --git a/packages/theo/src/fly-piece.js b/packages/theo/src/fly-piece.js index a2b5ec8d110..1532a4e1713 100644 --- a/packages/theo/src/fly-piece.js +++ b/packages/theo/src/fly-piece.js @@ -1,33 +1,21 @@ export default function(part) { - let { - snippets, - Point, - macro, - points, - Path, - paths, - complete, - sa, - paperless - } = part.shorthand(); + let { snippets, Point, macro, points, Path, paths, complete, sa, paperless } = part.shorthand() // Clean up paths from paperless dimensions - for (let id in paths) delete paths[id]; + for (let id in paths) delete paths[id] // We need to split the crotch curve at the bottom of the fly paths.fly = new Path() .move(points[-501]) - .curve(points[-502], points["-6cp"], points[-6]) + .curve(points[-502], points['-6cp'], points[-6]) .split(points[43]) - .pop(); - paths.fly.render = false; + .pop() + paths.fly.render = false // We need to split the waist curve at the edge of the fly - let waist = new Path() - .move(points[-100101]) - .curve_(points[-1002], points[-1102]); - points.splitWaist = waist.shiftAlong(points[-100101].dist(points[-40])); - paths.waist = waist.split(points.splitWaist).shift(); - paths.waist.render = false; + let waist = new Path().move(points[-100101]).curve_(points[-1002], points[-1102]) + points.splitWaist = waist.shiftAlong(points[-100101].dist(points[-40])) + paths.waist = waist.split(points.splitWaist).shift() + paths.waist.render = false paths.seam = paths.waist .clone() @@ -36,51 +24,48 @@ export default function(part) { .join(paths.fly) .line(points[-100101]) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') // Complete pattern? if (complete) { - if (sa) paths.sa = paths.seam.offset(sa * -1).attr("class", "fabric sa"); - points.title = points[9019].clone(); - macro("title", { + if (sa) paths.sa = paths.seam.offset(sa * -1).attr('class', 'fabric sa') + points.title = points[9019].clone() + macro('title', { at: points.title, - title: "flyPiece", + title: 'flyPiece', nr: 6, scale: 0.7 - }); - points.grainlineTop = points[-100101].shiftFractionTowards( - points.splitWaist, - 0.3 - ); - points.grainlineBottom = new Point(points.grainlineTop.x, points[41].y); - macro("grainline", { + }) + points.grainlineTop = points[-100101].shiftFractionTowards(points.splitWaist, 0.3) + points.grainlineBottom = new Point(points.grainlineTop.x, points[41].y) + macro('grainline', { from: points.grainlineBottom, to: points.grainlineTop - }); - delete paths.pocket; - delete paths.lining; - delete snippets.logo; - macro("scalebox", false); + }) + delete paths.pocket + delete paths.lining + delete snippets.logo + macro('scalebox', false) } // Paperless? if (paperless) { - macro("hd", { + macro('hd', { from: points[-100101], to: points.splitWaist, y: points.splitWaist.y - sa - 15 - }); - macro("hd", { + }) + macro('hd', { from: points.flyPretipX, to: points.splitWaist, y: points.splitWaist.y - sa - 30 - }); - macro("vd", { + }) + macro('vd', { from: points.flyPretipX, to: points.splitWaist, x: points.splitWaist.x + sa + 15 - }); + }) } - return part; + return part } diff --git a/packages/theo/src/fly-shield.js b/packages/theo/src/fly-shield.js index 7348ac0e4be..292353e7851 100644 --- a/packages/theo/src/fly-shield.js +++ b/packages/theo/src/fly-shield.js @@ -1,17 +1,9 @@ export default function(part) { - let { - macro, - points, - Path, - paths, - complete, - sa, - paperless - } = part.shorthand(); + let { macro, points, Path, paths, complete, sa, paperless } = part.shorthand() // Add points to make shift not impact curves - points.leftTop = points[-100101].shift(180, 20); - points.new43 = points[43].shift(180, 20); + points.leftTop = points[-100101].shift(180, 20) + points.new43 = points[43].shift(180, 20) // New path paths.seam = new Path() @@ -23,37 +15,37 @@ export default function(part) { .join(paths.fly.translate(-20, 0)) .line(points.leftTop) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') // Complete pattern? if (complete) { - if (sa) paths.sa = paths.seam.offset(sa * -1).attr("class", "fabric sa"); - macro("title", { + if (sa) paths.sa = paths.seam.offset(sa * -1).attr('class', 'fabric sa') + macro('title', { at: points.title, - title: "flyShield", + title: 'flyShield', nr: 7, scale: 0.7 - }); + }) } // Paperless? if (paperless) { - macro("hd", { + macro('hd', { from: points.leftTop, to: points.splitWaist, y: points.splitWaist.y - sa - 15 - }); - macro("hd", { + }) + macro('hd', { from: points.new43, to: points.splitWaist, y: points.splitWaist.y - sa - 30 - }); - macro("vd", { + }) + macro('vd', { from: points.new43, to: points.splitWaist, x: points.splitWaist.x + sa + 15 - }); + }) } - return part; + return part } diff --git a/packages/theo/src/front-pocket-bag.js b/packages/theo/src/front-pocket-bag.js index f62f93ed156..c0531db7b00 100644 --- a/packages/theo/src/front-pocket-bag.js +++ b/packages/theo/src/front-pocket-bag.js @@ -10,20 +10,20 @@ export default function(part) { macro, snippets, Snippet - } = part.shorthand(); + } = part.shorthand() // Clean up paths from paperless dimensions - for (let id in paths) delete paths[id]; + for (let id in paths) delete paths[id] // Additional points - points[810] = new Point(points[60].x, points[-1102].y + 300); - points[811] = new Point(points[-8].x, points[810].y); - points[812] = new Point(points[0].x, points[810].y); - points[813] = points[-100101].shiftTowards(points[-6], 70); - points[814] = points[813].shift(0, 40); - points[815] = new Point(points[0].x, points[814].y); - points[816] = new Point(points[-40].x - sa, points[-40].y - sa); - points[817] = points[813].shift(0, 30); - points[818] = new Point(points[814].x - sa, points[814].y + sa); + points[810] = new Point(points[60].x, points[-1102].y + 300) + points[811] = new Point(points[-8].x, points[810].y) + points[812] = new Point(points[0].x, points[810].y) + points[813] = points[-100101].shiftTowards(points[-6], 70) + points[814] = points[813].shift(0, 40) + points[815] = new Point(points[0].x, points[814].y) + points[816] = new Point(points[-40].x - sa, points[-40].y - sa) + points[817] = points[813].shift(0, 30) + points[818] = new Point(points[814].x - sa, points[814].y + sa) // Paths paths.seam = new Path() @@ -35,75 +35,75 @@ export default function(part) { .line(points[813]) .line(points[-100101]) .close() - .attr("class", "lining"); + .attr('class', 'lining') paths.flyEdge = new Path() .move(points[-40]) .line(points[814]) - .attr("class", "lining lashed"); + .attr('class', 'lining lashed') paths.pocket = new Path() .move(points[60]) .line(points[61]) - .attr("class", "lining lashed"); + .attr('class', 'lining lashed') // Complete pattern? if (complete) { if (sa) { - paths.sa = paths.seam.offset(-1 * sa).attr("class", "lining sa"); + paths.sa = paths.seam.offset(-1 * sa).attr('class', 'lining sa') paths.flyEdeSa = new Path() .move(points[816]) .line(points[818]) - .attr("class", "lining sa"); + .attr('class', 'lining sa') } - points.title = points.dartTip.clone(); - macro("title", { at: points.title, title: "frontPocketBag", nr: 9 }); - points.grainlineTop = points[60].clone(); - points.grainlineBottom = new Point(points.grainlineTop.x, points[810].y); - macro("grainline", { + points.title = points.dartTip.clone() + macro('title', { at: points.title, title: 'frontPocketBag', nr: 9 }) + points.grainlineTop = points[60].clone() + points.grainlineBottom = new Point(points.grainlineTop.x, points[810].y) + macro('grainline', { from: points.grainlineBottom, to: points.grainlineTop - }); - points.logo = new Point(points[60].x, points[61].y); - snippets.logo = new Snippet("logo", points.logo); - delete paths.fly; - delete paths.lining; - macro("scalebox", false); + }) + points.logo = new Point(points[60].x, points[61].y) + snippets.logo = new Snippet('logo', points.logo) + delete paths.fly + delete paths.lining + macro('scalebox', false) } // Paperless? if (paperless) { - macro("hd", { + macro('hd', { from: points[813], to: points[-8], y: points.grainlineBottom.y + sa + 15 - }); - macro("hd", { + }) + macro('hd', { from: points[-40], to: points[-8], y: points[-1102].y - sa - 15 - }); - macro("hd", { + }) + macro('hd', { from: points[-100101], to: points[-8], y: points[-1102].y - sa - 30 - }); - macro("vd", { + }) + macro('vd', { from: points.grainlineBottom, to: points[-1102], x: points[-8].x + sa + 15 - }); - macro("vd", { + }) + macro('vd', { from: points.grainlineBottom, to: points[813], x: points[813].x - sa - 15 - }); - macro("vd", { + }) + macro('vd', { from: points.grainlineBottom, to: points[-100101], x: points[813].x - sa - 30 - }); + }) } - return part; + return part } diff --git a/packages/theo/src/front.js b/packages/theo/src/front.js index dd49a501512..7bcf5b351ae 100644 --- a/packages/theo/src/front.js +++ b/packages/theo/src/front.js @@ -12,165 +12,129 @@ export default function(part) { macro, utils, measurements - } = part.shorthand(); + } = part.shorthand() // Clean up paths from paperless dimensions - for (let id in paths) delete paths[id]; + for (let id in paths) delete paths[id] - points[1] = new Point( - points[0].x, - measurements.seatDepth - options.waistbandWidth + 10 - ); - points[2] = new Point( - points[0].x, - points[1].y + measurements.inseam + store.get("lengthBonus") - ); - points[3] = new Point( - points[0].x, - points[1].y + measurements.inseam / 2 + 50 - ); - points[4] = new Point(points[0].x, points[1].y - measurements.seatDepth / 4); - points[5] = new Point( - points[0].x - measurements.seatCircumference / 8 + 10, - points[1].y - ); - points[501] = points[5].shift(135, 30); - points[502] = points[501].shift(45, 30); - points[503] = points[501].shift(-135, 30); - points[6] = new Point(points[5].x, points[4].y); - points[7] = new Point(points[5].x, points[0].y); - points[8] = new Point( - points[6].x + measurements.seatCircumference / 4 + 20, - points[6].y - ); - points[801] = new Point( - points[8].x, - points[8].y - measurements.seatDepth / 4 - ); - points[802] = new Point( - points[8].x, - points[8].y + measurements.seatDepth / 4 - ); + points[1] = new Point(points[0].x, measurements.seatDepth - options.waistbandWidth + 10) + points[2] = new Point(points[0].x, points[1].y + measurements.inseam + store.get('lengthBonus')) + points[3] = new Point(points[0].x, points[1].y + measurements.inseam / 2 + 50) + points[4] = new Point(points[0].x, points[1].y - measurements.seatDepth / 4) + points[5] = new Point(points[0].x - measurements.seatCircumference / 8 + 10, points[1].y) + points[501] = points[5].shift(135, 30) + points[502] = points[501].shift(45, 30) + points[503] = points[501].shift(-135, 30) + points[6] = new Point(points[5].x, points[4].y) + points[7] = new Point(points[5].x, points[0].y) + points[8] = new Point(points[6].x + measurements.seatCircumference / 4 + 20, points[6].y) + points[801] = new Point(points[8].x, points[8].y - measurements.seatDepth / 4) + points[802] = new Point(points[8].x, points[8].y + measurements.seatDepth / 4) points[9] = new Point( - points[5].x - - measurements.seatCircumference / 16 - - 5 + - store.get("backReduction"), + points[5].x - measurements.seatCircumference / 16 - 5 + store.get('backReduction'), points[5].y - ); - points[10] = new Point(points[7].x + 10, points[7].y); - points[1001] = points[10].shiftTowards(points[6], 10); - points[1002] = new Point(points[0].x, points[1001].y); - points[11] = new Point( - points[10].x + measurements.hipsCircumference / 4 + 25, - points[10].y - ); - points[12] = new Point(points[2].x + store.get("legWidth") / 2, points[2].y); - points[1201] = new Point(points[12].x, points[12].y - 50); - points[13] = points[12].flipX(); - points[1301] = points[1201].flipX(); - points[14] = new Point( - points[3].x + store.get("legWidth") / 2 + 15, - points[3].y - ); - points[1401] = points[12].shiftOutwards( - points[14], - points[1].dy(points[3]) / 2 - ); - points[1402] = points[1401].flipX(); + ) + points[10] = new Point(points[7].x + 10, points[7].y) + points[1001] = points[10].shiftTowards(points[6], 10) + points[1002] = new Point(points[0].x, points[1001].y) + points[11] = new Point(points[10].x + measurements.hipsCircumference / 4 + 25, points[10].y) + points[12] = new Point(points[2].x + store.get('legWidth') / 2, points[2].y) + points[1201] = new Point(points[12].x, points[12].y - 50) + points[13] = points[12].flipX() + points[1301] = points[1201].flipX() + points[14] = new Point(points[3].x + store.get('legWidth') / 2 + 15, points[3].y) + points[1401] = points[12].shiftOutwards(points[14], points[1].dy(points[3]) / 2) + points[1402] = points[1401].flipX() - points[15] = points[14].flipX(); + points[15] = points[14].flipX() points[40] = new Path() .move(points[1001]) .curve_(points[1002], points[11]) - .shiftAlong(50); + .shiftAlong(50) points[41] = new Point( points[40].x + points[1001].dx(points[6]), points[40].y + points[1001].dy(points[6]) - ); - let tmp = new Path().move(points[6])._curve(points[502], points[501]); - points[42] = tmp.shiftAlong(tmp.length() / 2); - points[43] = points[42].shift(-35, 10); - points["43beam"] = points[42].shift(-35, 40); // We use this to find curve intersection later - points[44] = points[43].shift(0, 20); - points[45] = points[40].shiftOutwards(points[41], 20); + ) + let tmp = new Path().move(points[6])._curve(points[502], points[501]) + points[42] = tmp.shiftAlong(tmp.length() / 2) + points[43] = points[42].shift(-35, 10) + points['43beam'] = points[42].shift(-35, 40) // We use this to find curve intersection later + points[44] = points[43].shift(0, 20) + points[45] = points[40].shiftOutwards(points[41], 20) points[-1001] = new Path() .move(points[1001]) .curve_(points[1002], points[11]) - .shiftAlong(10); - points[-100101] = points[-1001].shift(points[1001].angle(points[6]), 10); - points[-1002] = points[1002].shift(90, -10); + .shiftAlong(10) + points[-100101] = points[-1001].shift(points[1001].angle(points[6]), 10) + points[-1002] = points[1002].shift(90, -10) points[-11] = new Path() .move(points[11]) ._curve(points[801], points[8]) - .shiftAlong(10); + .shiftAlong(10) points[-1101] = new Path() .move(points[11]) ._curve(points[1002], points[1001]) - .shiftAlong(10); + .shiftAlong(10) points[-1102] = new Point( points[-1101].x + points[11].dx(points[-11]), points[-1101].y + points[11].dy(points[-11]) - ); - points[-801] = points[801].shift(0, -10); - points[-8] = points[8].shift(0, -10); - points[-802] = points[802].shift(0, -10); - points[-1401] = points[1401].shift(points[1401].angle(points[14]) + 90, -10); - points[-14] = points[14].shift(points[1401].angle(points[14]) + 90, -10); - points[-1201] = points[1201].shift(0, -10); - points[-12] = points[12].shift(0, -10); - points[-13] = points[13].shift(0, 10); - points[-1301] = points[1301].shift(0, 10); - points[-15] = points[-14].flipX(); - points[-1402] = points[-1401].flipX(); + ) + points[-801] = points[801].shift(0, -10) + points[-8] = points[8].shift(0, -10) + points[-802] = points[802].shift(0, -10) + points[-1401] = points[1401].shift(points[1401].angle(points[14]) + 90, -10) + points[-14] = points[14].shift(points[1401].angle(points[14]) + 90, -10) + points[-1201] = points[1201].shift(0, -10) + points[-12] = points[12].shift(0, -10) + points[-13] = points[13].shift(0, 10) + points[-1301] = points[1301].shift(0, 10) + points[-15] = points[-14].flipX() + points[-1402] = points[-1401].flipX() points[-901] = new Path() .move(points[9]) ._curve(points[503], points[501]) - .shiftAlong(10); + .shiftAlong(10) points[-902] = new Path() .move(points[9]) ._curve(points[1402], points[15]) - .shiftAlong(10); + .shiftAlong(10) points[-9] = new Point( points[-902].x + points[9].dx(points[-901]), points[-902].y + points[9].dy(points[-901]) - ); - points[-501] = points[501].shift(points[503].angle(points[502]) - 90, 10); - points[-502] = points[502].shift(points[503].angle(points[502]) - 90, 10); - points[-503] = points[503].shift(points[503].angle(points[502]) - 90, 10); - points[-6] = points[6].shift(points[6].angle(points[1001]) - 90, 10); - points[-40] = points[40].shiftTowards(points[41], 10); + ) + points[-501] = points[501].shift(points[503].angle(points[502]) - 90, 10) + points[-502] = points[502].shift(points[503].angle(points[502]) - 90, 10) + points[-503] = points[503].shift(points[503].angle(points[502]) - 90, 10) + points[-6] = points[6].shift(points[6].angle(points[1001]) - 90, 10) + points[-40] = points[40].shiftTowards(points[41], 10) // Smooth fly curve a bit at -6 - points["-6cp"] = points[-100101].shiftOutwards( - points[-6], - points[-6].dist(points[-502]) / 2 - ); + points['-6cp'] = points[-100101].shiftOutwards(points[-6], points[-6].dist(points[-502]) / 2) // Make sure fly ends on curve points.flyPretipX = utils.lineIntersectsCurve( points[42], - points["43beam"], + points['43beam'], points[-501], points[-502], - points["-6cp"], + points['-6cp'], points[-6] - ); - points[43] = points.flyPretipX.clone(); + ) + points[43] = points.flyPretipX.clone() // Slant pocket points[60] = new Path() .move(points[-1102]) ._curve(points[-1002], points[-100101]) - .shiftAlong(50); - let curve = new Path().move(points[-1102])._curve(points[-801], points[-8]); - let len = curve.length(); - if (len >= 190) points[61] = curve.shiftAlong(190); + .shiftAlong(50) + let curve = new Path().move(points[-1102])._curve(points[-801], points[-8]) + let len = curve.length() + if (len >= 190) points[61] = curve.shiftAlong(190) else points[61] = new Path() .move(points[-8]) .curve(points[-802], points[-1401], points[-14]) - .shiftAlong(190 - len); + .shiftAlong(190 - len) // Paths // This is the original Aldrich path, which includes seam allowance @@ -186,31 +150,31 @@ export default function(part) { .line(points[13]) .curve_(points[1301], points[15]) .curve_(points[1402], points[9]) - .close(); + .close() // This is the path we use, no seam allowance - paths.hemBase = new Path().move(points[-12]).line(points[-13]); + paths.hemBase = new Path().move(points[-12]).line(points[-13]) paths.saBase = new Path() .move(points[-13]) .curve_(points[-1301], points[-15]) .curve_(points[-1402], points[-9]) ._curve(points[-503], points[-501]) - .curve(points[-502], points["-6cp"], points[-6]) + .curve(points[-502], points['-6cp'], points[-6]) .line(points[-100101]) .curve_(points[-1002], points[-1102]) ._curve(points[-801], points[-8]) .curve(points[-802], points[-1401], points[-14]) - ._curve(points[-1201], points[-12]); + ._curve(points[-1201], points[-12]) paths.seam = paths.hemBase .clone() .join(paths.saBase) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') - paths.aldrich.render = false; - paths.hemBase.render = false; - paths.saBase.render = false; + paths.aldrich.render = false + paths.hemBase.render = false + paths.saBase.render = false // Complete pattern? if (complete) { @@ -219,76 +183,76 @@ export default function(part) { .offset(-3 * sa) .join(paths.saBase.offset(-1 * sa)) .close() - .attr("class", "fabric sa"); + .attr('class', 'fabric sa') } paths.fly = new Path() .move(points[43]) .curve(points[44], points[45], points[41]) .line(points[-40]) - .attr("class", "fabric dashed"); + .attr('class', 'fabric dashed') paths.pocket = new Path() .move(points[60]) .line(points[61]) - .attr("class", "fabric dashed"); + .attr('class', 'fabric dashed') paths.lining = new Path() .move(points[-14]) .line(points[-15]) - .attr("class", "lining dashed"); - macro("title", { at: points.title, title: "front", nr: 2 }); - macro("sprinkle", { - snippet: "notch", + .attr('class', 'lining dashed') + macro('title', { at: points.title, title: 'front', nr: 2 }) + macro('sprinkle', { + snippet: 'notch', on: [60, 61, 43] - }); + }) } // Paperless? if (paperless) { - macro("hd", { + macro('hd', { from: points[-9], to: points[-100101], y: points[-1102].y - sa - 15 - }); - macro("hd", { + }) + macro('hd', { from: points[-100101], to: points[-1102], y: points[-1102].y - sa - 15 - }); - macro("hd", { + }) + macro('hd', { from: points[-9], to: points[-1102], y: points[-1102].y - sa - 15 - }); - macro("hd", { + }) + macro('hd', { from: points[-9], to: points[-8], y: points[-1102].y - sa - 30 - }); - macro("vd", { + }) + macro('vd', { from: points[-9], to: points[-100101], x: points[-9].x - sa - 15 - }); - macro("vd", { + }) + macro('vd', { from: points[-9], to: points[-1102], x: points[-9].x - sa - 30 - }); - macro("vd", { + }) + macro('vd', { from: points[-13], to: points[-9], x: points[-9].x - sa - 30 - }); - macro("vd", { + }) + macro('vd', { from: points[-12], to: points[-1102], x: points[-8].x + sa + 15 - }); - macro("hd", { + }) + macro('hd', { from: points[-13], to: points[-12], y: points[-12].y + 3 * sa + 15 - }); + }) } - return part; + return part } diff --git a/packages/theo/src/index.js b/packages/theo/src/index.js index 0538c251e57..a64489f66be 100644 --- a/packages/theo/src/index.js +++ b/packages/theo/src/index.js @@ -1,52 +1,45 @@ -import freesewing from "@freesewing/core"; -import plugins from "@freesewing/plugin-bundle"; -import config from "../config"; +import freesewing from '@freesewing/core' +import plugins from '@freesewing/plugin-bundle' +import config from '../config' // Parts -import draftBack from "./back"; -import draftFront from "./front"; -import draftWaistbandInterfacingLeft from "./waistband-interfacing-left"; -import draftWaistbandInterfacingRight from "./waistband-interfacing-right"; -import draftWaistbandLeft from "./waistband-left"; -import draftWaistbandRight from "./waistband-right"; -import draftWaistbandLiningLeft from "./waistband-lining-left"; -import draftWaistbandLiningRight from "./waistband-lining-right"; -import draftFlyPiece from "./fly-piece"; -import draftFlyShield from "./fly-shield"; -import draftSidePiece from "./side-piece"; -import draftFrontPocketBag from "./front-pocket-bag"; -import draftBackInnerPocketBag from "./back-inner-pocket-bag"; -import draftBackOuterPocketBag from "./back-outer-pocket-bag"; -import draftBackPocketFacing from "./back-pocket-facing"; -import draftBackPocketInterfacing from "./back-pocket-interfacing"; -import draftBeltLoop from "./belt-loop"; +import draftBack from './back' +import draftFront from './front' +import draftWaistbandInterfacingLeft from './waistband-interfacing-left' +import draftWaistbandInterfacingRight from './waistband-interfacing-right' +import draftWaistbandLeft from './waistband-left' +import draftWaistbandRight from './waistband-right' +import draftWaistbandLiningLeft from './waistband-lining-left' +import draftWaistbandLiningRight from './waistband-lining-right' +import draftFlyPiece from './fly-piece' +import draftFlyShield from './fly-shield' +import draftSidePiece from './side-piece' +import draftFrontPocketBag from './front-pocket-bag' +import draftBackInnerPocketBag from './back-inner-pocket-bag' +import draftBackOuterPocketBag from './back-outer-pocket-bag' +import draftBackPocketFacing from './back-pocket-facing' +import draftBackPocketInterfacing from './back-pocket-interfacing' +import draftBeltLoop from './belt-loop' // Create design -const Pattern = new freesewing.Design(config, plugins); +const Pattern = new freesewing.Design(config, plugins) // Attach draft methods to prototype -Pattern.prototype.draftBack = part => draftBack(part); -Pattern.prototype.draftFront = part => draftFront(part); -Pattern.prototype.draftWaistbandInterfacingLeft = part => - draftWaistbandInterfacingLeft(part); -Pattern.prototype.draftWaistbandInterfacingRight = part => - draftWaistbandInterfacingRight(part); -Pattern.prototype.draftWaistbandLiningLeft = part => - draftWaistbandLiningLeft(part); -Pattern.prototype.draftWaistbandLiningRight = part => - draftWaistbandLiningRight(part); -Pattern.prototype.draftWaistbandLeft = part => draftWaistbandLeft(part); -Pattern.prototype.draftWaistbandRight = part => draftWaistbandRight(part); -Pattern.prototype.draftFlyPiece = part => draftFlyPiece(part); -Pattern.prototype.draftFlyShield = part => draftFlyShield(part); -Pattern.prototype.draftSidePiece = part => draftSidePiece(part); -Pattern.prototype.draftFrontPocketBag = part => draftFrontPocketBag(part); -Pattern.prototype.draftBackInnerPocketBag = part => - draftBackInnerPocketBag(part); -Pattern.prototype.draftBackOuterPocketBag = part => - draftBackOuterPocketBag(part); -Pattern.prototype.draftBackPocketFacing = part => draftBackPocketFacing(part); -Pattern.prototype.draftBackPocketInterfacing = part => - draftBackPocketInterfacing(part); -Pattern.prototype.draftBeltLoop = part => draftBeltLoop(part); +Pattern.prototype.draftBack = part => draftBack(part) +Pattern.prototype.draftFront = part => draftFront(part) +Pattern.prototype.draftWaistbandInterfacingLeft = part => draftWaistbandInterfacingLeft(part) +Pattern.prototype.draftWaistbandInterfacingRight = part => draftWaistbandInterfacingRight(part) +Pattern.prototype.draftWaistbandLiningLeft = part => draftWaistbandLiningLeft(part) +Pattern.prototype.draftWaistbandLiningRight = part => draftWaistbandLiningRight(part) +Pattern.prototype.draftWaistbandLeft = part => draftWaistbandLeft(part) +Pattern.prototype.draftWaistbandRight = part => draftWaistbandRight(part) +Pattern.prototype.draftFlyPiece = part => draftFlyPiece(part) +Pattern.prototype.draftFlyShield = part => draftFlyShield(part) +Pattern.prototype.draftSidePiece = part => draftSidePiece(part) +Pattern.prototype.draftFrontPocketBag = part => draftFrontPocketBag(part) +Pattern.prototype.draftBackInnerPocketBag = part => draftBackInnerPocketBag(part) +Pattern.prototype.draftBackOuterPocketBag = part => draftBackOuterPocketBag(part) +Pattern.prototype.draftBackPocketFacing = part => draftBackPocketFacing(part) +Pattern.prototype.draftBackPocketInterfacing = part => draftBackPocketInterfacing(part) +Pattern.prototype.draftBeltLoop = part => draftBeltLoop(part) -export default Pattern; +export default Pattern diff --git a/packages/theo/src/side-piece.js b/packages/theo/src/side-piece.js index beabd861fb7..cf290106009 100644 --- a/packages/theo/src/side-piece.js +++ b/packages/theo/src/side-piece.js @@ -1,33 +1,23 @@ export default function(part) { - let { - macro, - Point, - points, - Path, - paths, - complete, - sa, - paperless, - snippets - } = part.shorthand(); + let { macro, Point, points, Path, paths, complete, sa, paperless, snippets } = part.shorthand() // Clean up paths from paperless dimensions - for (let id in paths) delete paths[id]; - delete snippets.logo; + for (let id in paths) delete paths[id] + delete snippets.logo // Add points points.topLeft = new Path() .move(points[-1102]) ._curve(points[-1002], points[-100101]) - .shiftAlong(100); - points.bottomLeft = points[61].shift(180, 50); + .shiftAlong(100) + points.bottomLeft = points[61].shift(180, 50) // Split waist curve paths.waist = new Path() .move(points[-1102]) ._curve(points[-1002], points[-100101]) .split(points.topLeft) - .shift(); - paths.waist.render = false; + .shift() + paths.waist.render = false // Split side curve paths.side = new Path() @@ -35,8 +25,8 @@ export default function(part) { .curve(points[-802], points[-1401], points[-14]) .split(points[61]) .shift() - .reverse(); - paths.side.render = false; + .reverse() + paths.side.render = false paths.seam = new Path() .move(points.topLeft) @@ -46,64 +36,61 @@ export default function(part) { .curve_(points[-801], points[-1102]) .join(paths.waist) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') // Complete pattern? if (complete) { paths.pocket = new Path() .move(points[60]) .line(points[61]) - .attr("class", "fabric stroke-sm lashed"); - if (sa) paths.sa = paths.seam.offset(sa).attr("class", "fabric sa"); - macro("scalebox", false); - delete paths.fly; - delete paths.lining; - points.grainlineTop = points[60].clone(); - points.grainlineBottom = new Point( - points.grainlineTop.x, - points.bottomLeft.y - ); - macro("grainline", { + .attr('class', 'fabric stroke-sm lashed') + if (sa) paths.sa = paths.seam.offset(sa).attr('class', 'fabric sa') + macro('scalebox', false) + delete paths.fly + delete paths.lining + points.grainlineTop = points[60].clone() + points.grainlineBottom = new Point(points.grainlineTop.x, points.bottomLeft.y) + macro('grainline', { from: points.grainlineBottom, to: points.grainlineTop - }); - points.title = points[-801].shift(180, 40); - macro("title", { at: points.title, title: "sidePiece", nr: 8 }); + }) + points.title = points[-801].shift(180, 40) + macro('title', { at: points.title, title: 'sidePiece', nr: 8 }) } // Paperless? if (paperless) { - macro("hd", { + macro('hd', { from: points.topLeft, to: points[-1102], y: points[-1102].y - sa - 15 - }); - macro("hd", { + }) + macro('hd', { from: points.topLeft, to: points[-8], y: points[-1102].y - sa - 30 - }); - macro("hd", { + }) + macro('hd', { from: points.bottomLeft, to: points[61], y: points.bottomLeft.y + sa + 15 - }); - macro("hd", { + }) + macro('hd', { from: points.bottomLeft, to: points[-8], y: points.bottomLeft.y + sa + 30 - }); - macro("vd", { + }) + macro('vd', { from: points.bottomLeft, to: points.topLeft, x: points.topLeft.x - sa - 15 - }); - macro("vd", { + }) + macro('vd', { from: points.bottomLeft, to: points[-1102], x: points.topLeft.x - sa - 30 - }); + }) } - return part; + return part } diff --git a/packages/theo/src/waistband-interfacing-left.js b/packages/theo/src/waistband-interfacing-left.js index b2393cd1f84..ac538a2205f 100644 --- a/packages/theo/src/waistband-interfacing-left.js +++ b/packages/theo/src/waistband-interfacing-left.js @@ -11,15 +11,12 @@ export default function(part) { macro, snippets, Snippet - } = part.shorthand(); + } = part.shorthand() - points[0] = new Point(0, 0); - points[2] = new Point( - options.waistbandWidth, - measurements.hipsCircumference / 2 + 60 - ); - points[1] = new Point(points[2].x, points[0].y); - points[3] = new Point(points[0].x, points[2].y); + points[0] = new Point(0, 0) + points[2] = new Point(options.waistbandWidth, measurements.hipsCircumference / 2 + 60) + points[1] = new Point(points[2].x, points[0].y) + points[3] = new Point(points[0].x, points[2].y) paths.seam = new Path() .move(points[0]) @@ -28,35 +25,35 @@ export default function(part) { .line(points[3]) .line(points[0]) .close() - .attr("class", "interfacing"); + .attr('class', 'interfacing') // Complete pattern? if (complete) { - points.title = points[0].shiftFractionTowards(points[2], 0.5); - macro("title", { + points.title = points[0].shiftFractionTowards(points[2], 0.5) + macro('title', { at: points.title, - title: "waistbandInterfacingLeft", - nr: "3a", + title: 'waistbandInterfacingLeft', + nr: '3a', scale: 0.5, rotation: -90 - }); - points.logo = new Point(points[2].x / 2, 45); - snippets.logo = new Snippet("logo", points.logo).attr("data-scale", 0.7); + }) + points.logo = new Point(points[2].x / 2, 45) + snippets.logo = new Snippet('logo', points.logo).attr('data-scale', 0.7) } // Paperless? if (paperless) { - macro("hd", { + macro('hd', { from: points[3], to: points[2], y: points[2].y + 15 - }); - macro("vd", { + }) + macro('vd', { from: points[2], to: points[1], x: points[2].x + 15 - }); + }) } - return part; + return part } diff --git a/packages/theo/src/waistband-interfacing-right.js b/packages/theo/src/waistband-interfacing-right.js index cd8a3b0ce61..2a47551c8ea 100644 --- a/packages/theo/src/waistband-interfacing-right.js +++ b/packages/theo/src/waistband-interfacing-right.js @@ -11,15 +11,12 @@ export default function(part) { macro, snippets, Snippet - } = part.shorthand(); + } = part.shorthand() - points[0] = new Point(0, 0); - points[2] = new Point( - options.waistbandWidth, - measurements.hipsCircumference / 2 + 40 - ); - points[1] = new Point(points[2].x, points[0].y); - points[3] = new Point(points[0].x, points[2].y); + points[0] = new Point(0, 0) + points[2] = new Point(options.waistbandWidth, measurements.hipsCircumference / 2 + 40) + points[1] = new Point(points[2].x, points[0].y) + points[3] = new Point(points[0].x, points[2].y) paths.seam = new Path() .move(points[0]) @@ -28,35 +25,35 @@ export default function(part) { .line(points[3]) .line(points[0]) .close() - .attr("class", "interfacing"); + .attr('class', 'interfacing') // Complete pattern? if (complete) { - points.title = points[0].shiftFractionTowards(points[2], 0.5); - macro("title", { + points.title = points[0].shiftFractionTowards(points[2], 0.5) + macro('title', { at: points.title, - title: "waistbandInterfacingRight", - nr: "3b", + title: 'waistbandInterfacingRight', + nr: '3b', scale: 0.5, rotation: -90 - }); - points.logo = new Point(points[2].x / 2, 45); - snippets.logo = new Snippet("logo", points.logo).attr("data-scale", 0.7); + }) + points.logo = new Point(points[2].x / 2, 45) + snippets.logo = new Snippet('logo', points.logo).attr('data-scale', 0.7) } // Paperless? if (paperless) { - macro("hd", { + macro('hd', { from: points[3], to: points[2], y: points[2].y + 15 - }); - macro("vd", { + }) + macro('vd', { from: points[2], to: points[1], x: points[2].x + 15 - }); + }) } - return part; + return part } diff --git a/packages/theo/src/waistband-left.js b/packages/theo/src/waistband-left.js index cc0917333cc..cd0458b996c 100644 --- a/packages/theo/src/waistband-left.js +++ b/packages/theo/src/waistband-left.js @@ -1,48 +1,40 @@ export default function(part) { - let { - Point, - points, - macro, - paths, - complete, - sa, - paperless - } = part.shorthand(); + let { Point, points, macro, paths, complete, sa, paperless } = part.shorthand() - paths.seam.attributes.set("class", "fabric"); + paths.seam.attributes.set('class', 'fabric') // Complete pattern? if (complete) { - if (sa) paths.sa = paths.seam.offset(-1 * sa).attr("class", "fabric sa"); - points.title = points[0].shiftFractionTowards(points[2], 0.5); - macro("title", { + if (sa) paths.sa = paths.seam.offset(-1 * sa).attr('class', 'fabric sa') + points.title = points[0].shiftFractionTowards(points[2], 0.5) + macro('title', { at: points.title, - title: "waistbandLeft", - nr: "4a", + title: 'waistbandLeft', + nr: '4a', scale: 0.5, rotation: -90 - }); - points.grainlineTop = new Point(points[2].x / 2, 0); - points.grainlineBottom = new Point(points[2].x / 2, points[2].y, 0); - macro("grainline", { + }) + points.grainlineTop = new Point(points[2].x / 2, 0) + points.grainlineBottom = new Point(points[2].x / 2, points[2].y, 0) + macro('grainline', { from: points.grainlineBottom, to: points.grainlineTop - }); + }) } // Paperless? if (paperless) { - macro("hd", { + macro('hd', { from: points[3], to: points[2], y: points[2].y + sa + 15 - }); - macro("vd", { + }) + macro('vd', { from: points[2], to: points[1], x: points[2].x + sa + 15 - }); + }) } - return part; + return part } diff --git a/packages/theo/src/waistband-lining-left.js b/packages/theo/src/waistband-lining-left.js index faa1ee7e2d0..8821a0b1894 100644 --- a/packages/theo/src/waistband-lining-left.js +++ b/packages/theo/src/waistband-lining-left.js @@ -10,10 +10,10 @@ export default function(part) { complete, sa, paperless - } = part.shorthand(); + } = part.shorthand() - points[0] = points[0].shift(180, 80); - points[3] = points[3].shift(180, 80); + points[0] = points[0].shift(180, 80) + points[3] = points[3].shift(180, 80) paths.seam = new Path() .move(points[0]) @@ -22,42 +22,42 @@ export default function(part) { .line(points[3]) .line(points[0]) .close() - .attr("class", "lining"); + .attr('class', 'lining') // Complete pattern? if (complete) { - if (sa) paths.sa = paths.seam.offset(-1 * sa).attr("class", "lining sa"); - points.title = points[0].shiftFractionTowards(points[2], 0.5); - macro("title", { + if (sa) paths.sa = paths.seam.offset(-1 * sa).attr('class', 'lining sa') + points.title = points[0].shiftFractionTowards(points[2], 0.5) + macro('title', { at: points.title, - title: "waistbandLiningLeft", - nr: "5a", + title: 'waistbandLiningLeft', + nr: '5a', scale: 0.5, rotation: -90 - }); - points.logo = points.title.shift(90, 70); - snippets.logo = new Snippet("logo", points.logo); - points.grainlineTop = new Point(points[2].x / 2, 0); - points.grainlineBottom = new Point(points[2].x / 2, points[2].y, 0); - macro("grainline", { + }) + points.logo = points.title.shift(90, 70) + snippets.logo = new Snippet('logo', points.logo) + points.grainlineTop = new Point(points[2].x / 2, 0) + points.grainlineBottom = new Point(points[2].x / 2, points[2].y, 0) + macro('grainline', { from: points.grainlineBottom, to: points.grainlineTop - }); + }) } // Paperless? if (paperless) { - macro("hd", { + macro('hd', { from: points[3], to: points[2], y: points[2].y + sa + 15 - }); - macro("vd", { + }) + macro('vd', { from: points[2], to: points[1], x: points[2].x + sa + 15 - }); + }) } - return part; + return part } diff --git a/packages/theo/src/waistband-lining-right.js b/packages/theo/src/waistband-lining-right.js index 79a3ebd9cd9..52dde06cfa8 100644 --- a/packages/theo/src/waistband-lining-right.js +++ b/packages/theo/src/waistband-lining-right.js @@ -10,10 +10,10 @@ export default function(part) { complete, sa, paperless - } = part.shorthand(); + } = part.shorthand() - points[0] = points[0].shift(180, 80); - points[3] = points[3].shift(180, 80); + points[0] = points[0].shift(180, 80) + points[3] = points[3].shift(180, 80) paths.seam = new Path() .move(points[0]) @@ -22,42 +22,42 @@ export default function(part) { .line(points[3]) .line(points[0]) .close() - .attr("class", "lining"); + .attr('class', 'lining') // Complete pattern? if (complete) { - if (sa) paths.sa = paths.seam.offset(-1 * sa).attr("class", "lining sa"); - points.title = points[0].shiftFractionTowards(points[2], 0.5); - macro("title", { + if (sa) paths.sa = paths.seam.offset(-1 * sa).attr('class', 'lining sa') + points.title = points[0].shiftFractionTowards(points[2], 0.5) + macro('title', { at: points.title, - title: "waistbandLiningRight", - nr: "5b", + title: 'waistbandLiningRight', + nr: '5b', scale: 0.5, rotation: -90 - }); - points.logo = points.title.shift(90, 70); - snippets.logo = new Snippet("logo", points.logo); - points.grainlineTop = new Point(points[2].x / 2, 0); - points.grainlineBottom = new Point(points[2].x / 2, points[2].y, 0); - macro("grainline", { + }) + points.logo = points.title.shift(90, 70) + snippets.logo = new Snippet('logo', points.logo) + points.grainlineTop = new Point(points[2].x / 2, 0) + points.grainlineBottom = new Point(points[2].x / 2, points[2].y, 0) + macro('grainline', { from: points.grainlineBottom, to: points.grainlineTop - }); + }) } // Paperless? if (paperless) { - macro("hd", { + macro('hd', { from: points[3], to: points[2], y: points[2].y + sa + 15 - }); - macro("vd", { + }) + macro('vd', { from: points[2], to: points[1], x: points[2].x + sa + 15 - }); + }) } - return part; + return part } diff --git a/packages/theo/src/waistband-right.js b/packages/theo/src/waistband-right.js index a19d059b64b..cdff4725c3e 100644 --- a/packages/theo/src/waistband-right.js +++ b/packages/theo/src/waistband-right.js @@ -1,48 +1,40 @@ export default function(part) { - let { - Point, - points, - macro, - paths, - complete, - sa, - paperless - } = part.shorthand(); + let { Point, points, macro, paths, complete, sa, paperless } = part.shorthand() - paths.seam.attributes.set("class", "fabric"); + paths.seam.attributes.set('class', 'fabric') // Complete pattern? if (complete) { - if (sa) paths.sa = paths.seam.offset(-1 * sa).attr("class", "fabric sa"); - points.title = points[0].shiftFractionTowards(points[2], 0.5); - macro("title", { + if (sa) paths.sa = paths.seam.offset(-1 * sa).attr('class', 'fabric sa') + points.title = points[0].shiftFractionTowards(points[2], 0.5) + macro('title', { at: points.title, - title: "waistbandRight", - nr: "4b", + title: 'waistbandRight', + nr: '4b', scale: 0.5, rotation: -90 - }); - points.grainlineTop = new Point(points[2].x / 2, 0); - points.grainlineBottom = new Point(points[2].x / 2, points[2].y, 0); - macro("grainline", { + }) + points.grainlineTop = new Point(points[2].x / 2, 0) + points.grainlineBottom = new Point(points[2].x / 2, points[2].y, 0) + macro('grainline', { from: points.grainlineBottom, to: points.grainlineTop - }); + }) } // Paperless? if (paperless) { - macro("hd", { + macro('hd', { from: points[3], to: points[2], y: points[2].y + sa + 15 - }); - macro("vd", { + }) + macro('vd', { from: points[2], to: points[1], x: points[2].x + sa + 15 - }); + }) } - return part; + return part } diff --git a/packages/trayvon/example/src/App.js b/packages/trayvon/example/src/App.js index e7936330e5d..115cdf683af 100644 --- a/packages/trayvon/example/src/App.js +++ b/packages/trayvon/example/src/App.js @@ -1,22 +1,15 @@ -import React from "react"; -import freesewing from "@freesewing/core"; -import Workbench from "@freesewing/components/Workbench"; -import "typeface-roboto-condensed"; -import "@freesewing/css-theme"; +import React from 'react' +import freesewing from '@freesewing/core' +import Workbench from '@freesewing/components/Workbench' +import 'typeface-roboto-condensed' +import '@freesewing/css-theme' -import Pattern from "pattern"; +import Pattern from 'pattern' const App = props => { - let instance = new Pattern(); - let config = instance.config; - return ( - - ); -}; + let instance = new Pattern() + let config = instance.config + return +} -export default App; +export default App diff --git a/packages/trayvon/example/src/index.js b/packages/trayvon/example/src/index.js index 7900787a4d2..9dd7ba788d4 100644 --- a/packages/trayvon/example/src/index.js +++ b/packages/trayvon/example/src/index.js @@ -1,11 +1,11 @@ -import React from "react"; -import ReactDOM from "react-dom"; -import App from "./App"; -import * as serviceWorker from "./serviceWorker"; +import React from 'react' +import ReactDOM from 'react-dom' +import App from './App' +import * as serviceWorker from './serviceWorker' -ReactDOM.render(, document.getElementById("root")); +ReactDOM.render(, document.getElementById('root')) // If you want your app to work offline and load faster, you can change // unregister() to register() below. Note this comes with some pitfalls. // Learn more about service workers: http://bit.ly/CRA-PWA -serviceWorker.unregister(); +serviceWorker.unregister() diff --git a/packages/trayvon/example/src/serviceWorker.js b/packages/trayvon/example/src/serviceWorker.js index 68fda5a0eb6..44e1b1b2f8c 100644 --- a/packages/trayvon/example/src/serviceWorker.js +++ b/packages/trayvon/example/src/serviceWorker.js @@ -9,46 +9,44 @@ // This link also includes instructions on opting out of this behavior. const isLocalhost = Boolean( - window.location.hostname === "localhost" || + window.location.hostname === 'localhost' || // [::1] is the IPv6 localhost address. - window.location.hostname === "[::1]" || + window.location.hostname === '[::1]' || // 127.0.0.1/8 is considered localhost for IPv4. - window.location.hostname.match( - /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ - ) -); + window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/) +) export function register(config) { - if (process.env.NODE_ENV === "production" && "serviceWorker" in navigator) { + if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) { // The URL constructor is available in all browsers that support SW. - const publicUrl = new URL(process.env.PUBLIC_URL, window.location); + const publicUrl = new URL(process.env.PUBLIC_URL, window.location) if (publicUrl.origin !== window.location.origin) { // Our service worker won't work if PUBLIC_URL is on a different origin // from what our page is served on. This might happen if a CDN is used to // serve assets; see https://github.com/facebook/create-react-app/issues/2374 - return; + return } - window.addEventListener("load", () => { - const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; + window.addEventListener('load', () => { + const swUrl = `${process.env.PUBLIC_URL}/service-worker.js` if (isLocalhost) { // This is running on localhost. Let's check if a service worker still exists or not. - checkValidServiceWorker(swUrl, config); + checkValidServiceWorker(swUrl, config) // Add some additional logging to localhost, pointing developers to the // service worker/PWA documentation. navigator.serviceWorker.ready.then(() => { console.log( - "This web app is being served cache-first by a service " + - "worker. To learn more, visit https://goo.gl/SC7cgQ" - ); - }); + 'This web app is being served cache-first by a service ' + + 'worker. To learn more, visit https://goo.gl/SC7cgQ' + ) + }) } else { // Is not local host. Just register service worker - registerValidSW(swUrl, config); + registerValidSW(swUrl, config) } - }); + }) } } @@ -57,38 +55,38 @@ function registerValidSW(swUrl, config) { .register(swUrl) .then(registration => { registration.onupdatefound = () => { - const installingWorker = registration.installing; + const installingWorker = registration.installing installingWorker.onstatechange = () => { - if (installingWorker.state === "installed") { + if (installingWorker.state === 'installed') { if (navigator.serviceWorker.controller) { // At this point, the old content will have been purged and // the fresh content will have been added to the cache. // It's the perfect time to display a "New content is // available; please refresh." message in your web app. - console.log("New content is available; please refresh."); + console.log('New content is available; please refresh.') // Execute callback if (config.onUpdate) { - config.onUpdate(registration); + config.onUpdate(registration) } } else { // At this point, everything has been precached. // It's the perfect time to display a // "Content is cached for offline use." message. - console.log("Content is cached for offline use."); + console.log('Content is cached for offline use.') // Execute callback if (config.onSuccess) { - config.onSuccess(registration); + config.onSuccess(registration) } } } - }; - }; + } + } }) .catch(error => { - console.error("Error during service worker registration:", error); - }); + console.error('Error during service worker registration:', error) + }) } function checkValidServiceWorker(swUrl, config) { @@ -98,30 +96,28 @@ function checkValidServiceWorker(swUrl, config) { // Ensure service worker exists, and that we really are getting a JS file. if ( response.status === 404 || - response.headers.get("content-type").indexOf("javascript") === -1 + response.headers.get('content-type').indexOf('javascript') === -1 ) { // No service worker found. Probably a different app. Reload the page. navigator.serviceWorker.ready.then(registration => { registration.unregister().then(() => { - window.location.reload(); - }); - }); + window.location.reload() + }) + }) } else { // Service worker found. Proceed as normal. - registerValidSW(swUrl, config); + registerValidSW(swUrl, config) } }) .catch(() => { - console.log( - "No internet connection found. App is running in offline mode." - ); - }); + console.log('No internet connection found. App is running in offline mode.') + }) } export function unregister() { - if ("serviceWorker" in navigator) { + if ('serviceWorker' in navigator) { navigator.serviceWorker.ready.then(registration => { - registration.unregister(); - }); + registration.unregister() + }) } } diff --git a/packages/trayvon/src/fabrictail.js b/packages/trayvon/src/fabrictail.js index f0044719e45..adf5f970779 100644 --- a/packages/trayvon/src/fabrictail.js +++ b/packages/trayvon/src/fabrictail.js @@ -1,64 +1,44 @@ -import { - calculateHelpers, - draftTieShape, - seamAllowance, - tieShapeDimensions -} from "./shared"; +import { calculateHelpers, draftTieShape, seamAllowance, tieShapeDimensions } from './shared' export default part => { - let { - Path, - complete, - macro, - options, - paths, - points, - paperless, - sa, - store - } = part.shorthand(); + let { Path, complete, macro, options, paths, points, paperless, sa, store } = part.shorthand() - calculateHelpers(part); - draftTieShape( - part, - store.get("backTip") * 2.5, - options.knotWidth * 2.5, - true - ); - paths.seam.attributes.add("class", "fabric"); + calculateHelpers(part) + draftTieShape(part, store.get('backTip') * 2.5, options.knotWidth * 2.5, true) + paths.seam.attributes.add('class', 'fabric') // Complete pattern? if (complete) { - macro("title", { + macro('title', { at: points.title, nr: 4, - title: "fabricTail", + title: 'fabricTail', rotation: -90 - }); + }) - if (sa) seamAllowance(part, "fabric"); + if (sa) seamAllowance(part, 'fabric') } // Paperless? if (paperless) { - tieShapeDimensions(part); - macro("ld", { + tieShapeDimensions(part) + macro('ld', { from: points.tip, to: points.notch1, d: options.tipWidth / -2.5 - }); - macro("ld", { + }) + macro('ld', { from: points.notch2, to: points.tip, d: options.tipWidth / -2.5 - }); + }) paths.n45 = new Path() .move(points.midLeft) .line(points.midRight) - .attr("class", "hidden") - .attr("data-text", "45°") - .attr("data-text-class", "center"); + .attr('class', 'hidden') + .attr('data-text', '45°') + .attr('data-text-class', 'center') } - return part; -}; + return part +} diff --git a/packages/trayvon/src/fabrictip.js b/packages/trayvon/src/fabrictip.js index 5f6ee09da64..aca11899b8a 100644 --- a/packages/trayvon/src/fabrictip.js +++ b/packages/trayvon/src/fabrictip.js @@ -1,9 +1,4 @@ -import { - calculateHelpers, - draftTieShape, - seamAllowance, - tieShapeDimensions -} from "./shared"; +import { calculateHelpers, draftTieShape, seamAllowance, tieShapeDimensions } from './shared' export default part => { let { @@ -17,47 +12,47 @@ export default part => { points, sa, snippets - } = part.shorthand(); + } = part.shorthand() - calculateHelpers(part); - draftTieShape(part, options.tipWidth * 2.5, options.knotWidth * 2.5, true); - paths.seam.attributes.add("class", "fabric"); + calculateHelpers(part) + draftTieShape(part, options.tipWidth * 2.5, options.knotWidth * 2.5, true) + paths.seam.attributes.add('class', 'fabric') // Complete pattern? if (complete) { - macro("title", { + macro('title', { at: points.title, nr: 3, - title: "fabricTip", + title: 'fabricTip', rotation: -90 - }); + }) - points.logo = points.tip.shiftFractionTowards(points.mid, 0.4); - snippets.logo = new Snippet("logo", points.logo); + points.logo = points.tip.shiftFractionTowards(points.mid, 0.4) + snippets.logo = new Snippet('logo', points.logo) - if (sa) seamAllowance(part, "fabric"); + if (sa) seamAllowance(part, 'fabric') } // Paperless? if (paperless) { - tieShapeDimensions(part); - macro("ld", { + tieShapeDimensions(part) + macro('ld', { from: points.tip, to: points.notch1, d: options.tipWidth / -2.5 - }); - macro("ld", { + }) + macro('ld', { from: points.notch2, to: points.tip, d: options.tipWidth / -2.5 - }); + }) paths.n45 = new Path() .move(points.midLeft) .line(points.midRight) - .attr("class", "hidden") - .attr("data-text", "45°") - .attr("data-text-class", "center"); + .attr('class', 'hidden') + .attr('data-text', '45°') + .attr('data-text-class', 'center') } - return part; -}; + return part +} diff --git a/packages/trayvon/src/index.js b/packages/trayvon/src/index.js index fc44128b6b7..aebc6fef02c 100644 --- a/packages/trayvon/src/index.js +++ b/packages/trayvon/src/index.js @@ -1,25 +1,25 @@ -import freesewing from "@freesewing/core"; -import plugins from "@freesewing/plugin-bundle"; -import config from "../config"; +import freesewing from '@freesewing/core' +import plugins from '@freesewing/plugin-bundle' +import config from '../config' // Parts -import draftInterfacingTip from "./interfacingtip"; -import draftInterfacingTail from "./interfacingtail"; -import draftFabricTip from "./fabrictip"; -import draftFabricTail from "./fabrictail"; -import draftLiningTip from "./liningtip"; -import draftLiningTail from "./liningtail"; -import draftLoop from "./loop"; +import draftInterfacingTip from './interfacingtip' +import draftInterfacingTail from './interfacingtail' +import draftFabricTip from './fabrictip' +import draftFabricTail from './fabrictail' +import draftLiningTip from './liningtip' +import draftLiningTail from './liningtail' +import draftLoop from './loop' // Create design -const Pattern = new freesewing.Design(config, plugins); +const Pattern = new freesewing.Design(config, plugins) // Attach draft methods to prototype -Pattern.prototype.draftInterfacingTip = part => draftInterfacingTip(part); -Pattern.prototype.draftInterfacingTail = part => draftInterfacingTail(part); -Pattern.prototype.draftFabricTip = part => draftFabricTip(part); -Pattern.prototype.draftFabricTail = part => draftFabricTail(part); -Pattern.prototype.draftLiningTip = part => draftLiningTip(part); -Pattern.prototype.draftLiningTail = part => draftLiningTail(part); -Pattern.prototype.draftLoop = part => draftLoop(part); +Pattern.prototype.draftInterfacingTip = part => draftInterfacingTip(part) +Pattern.prototype.draftInterfacingTail = part => draftInterfacingTail(part) +Pattern.prototype.draftFabricTip = part => draftFabricTip(part) +Pattern.prototype.draftFabricTail = part => draftFabricTail(part) +Pattern.prototype.draftLiningTip = part => draftLiningTip(part) +Pattern.prototype.draftLiningTail = part => draftLiningTail(part) +Pattern.prototype.draftLoop = part => draftLoop(part) -export default Pattern; +export default Pattern diff --git a/packages/trayvon/src/interfacingtail.js b/packages/trayvon/src/interfacingtail.js index 936aab5d589..816a9900cad 100644 --- a/packages/trayvon/src/interfacingtail.js +++ b/packages/trayvon/src/interfacingtail.js @@ -1,41 +1,32 @@ -import { draftTieShape, tieShapeDimensions, calculateHelpers } from "./shared"; +import { draftTieShape, tieShapeDimensions, calculateHelpers } from './shared' export default part => { - let { - options, - paths, - points, - macro, - complete, - paperless, - Path, - store - } = part.shorthand(); + let { options, paths, points, macro, complete, paperless, Path, store } = part.shorthand() - calculateHelpers(part); - draftTieShape(part, store.get("backTip"), options.knotWidth); - paths.seam.attributes.add("class", "interfacing"); + calculateHelpers(part) + draftTieShape(part, store.get('backTip'), options.knotWidth) + paths.seam.attributes.add('class', 'interfacing') // Complete pattern? if (complete) { - macro("title", { + macro('title', { at: points.title, nr: 2, - title: "interfacingTail", + title: 'interfacingTail', rotation: -90 - }); + }) } // Paperless? if (paperless) { - tieShapeDimensions(part); + tieShapeDimensions(part) paths.n45 = new Path() .move(points.midLeft) .line(points.midRight) - .attr("class", "hidden") - .attr("data-text", "45°") - .attr("data-text-class", "center"); + .attr('class', 'hidden') + .attr('data-text', '45°') + .attr('data-text-class', 'center') } - return part; -}; + return part +} diff --git a/packages/trayvon/src/interfacingtip.js b/packages/trayvon/src/interfacingtip.js index b0a7bf20159..6659a8917cb 100644 --- a/packages/trayvon/src/interfacingtip.js +++ b/packages/trayvon/src/interfacingtip.js @@ -1,40 +1,32 @@ -import { draftTieShape, tieShapeDimensions, calculateHelpers } from "./shared"; +import { draftTieShape, tieShapeDimensions, calculateHelpers } from './shared' export default part => { - let { - options, - paths, - points, - macro, - complete, - paperless, - Path - } = part.shorthand(); + let { options, paths, points, macro, complete, paperless, Path } = part.shorthand() - calculateHelpers(part); - draftTieShape(part, options.tipWidth, options.knotWidth); - paths.seam.attributes.add("class", "interfacing"); + calculateHelpers(part) + draftTieShape(part, options.tipWidth, options.knotWidth) + paths.seam.attributes.add('class', 'interfacing') // Complete pattern? if (complete) { - macro("title", { + macro('title', { at: points.title, nr: 1, - title: "interfacingTip", + title: 'interfacingTip', rotation: -90 - }); + }) } // Paperless? if (paperless) { - tieShapeDimensions(part); + tieShapeDimensions(part) paths.n45 = new Path() .move(points.midLeft) .line(points.midRight) - .attr("class", "hidden") - .attr("data-text", "45°") - .attr("data-text-class", "center"); + .attr('class', 'hidden') + .attr('data-text', '45°') + .attr('data-text-class', 'center') } - return part; -}; + return part +} diff --git a/packages/trayvon/src/liningtail.js b/packages/trayvon/src/liningtail.js index 92421d80ee1..43af42df9a9 100644 --- a/packages/trayvon/src/liningtail.js +++ b/packages/trayvon/src/liningtail.js @@ -1,9 +1,4 @@ -import { - calculateHelpers, - draftTieShape, - seamAllowance, - tieShapeDimensions -} from "./shared"; +import { calculateHelpers, draftTieShape, seamAllowance, tieShapeDimensions } from './shared' export default part => { let { @@ -18,17 +13,14 @@ export default part => { sa, snippets, store - } = part.shorthand(); + } = part.shorthand() - calculateHelpers(part); - draftTieShape(part, store.get("backTip") * 2.5, options.knotWidth * 2.5); + calculateHelpers(part) + draftTieShape(part, store.get('backTip') * 2.5, options.knotWidth * 2.5) // Cut part short - points.cutRight = points.tipRight.shiftTowards( - points.midRight, - options.tipWidth * 2.5 - ); - points.cutLeft = points.cutRight.flipX(); + points.cutRight = points.tipRight.shiftTowards(points.midRight, options.tipWidth * 2.5) + points.cutLeft = points.cutRight.flipX() // Overwrite path paths.seam = new Path() @@ -39,23 +31,23 @@ export default part => { .line(points.tipRight) .line(points.tip) .close() - .attr("class", "lining"); + .attr('class', 'lining') // Complete pattern? if (complete) { - macro("title", { + macro('title', { at: points.title, nr: 6, - title: "liningTip", + title: 'liningTip', rotation: -90 - }); - snippets.notch = new Snippet("notch", points.tip); + }) + snippets.notch = new Snippet('notch', points.tip) - if (sa) seamAllowance(part, "lining"); + if (sa) seamAllowance(part, 'lining') } // Paperless? - if (paperless) tieShapeDimensions(part, true); + if (paperless) tieShapeDimensions(part, true) - return part; -}; + return part +} diff --git a/packages/trayvon/src/liningtip.js b/packages/trayvon/src/liningtip.js index d7a860ffa29..e83cd4b0c3a 100644 --- a/packages/trayvon/src/liningtip.js +++ b/packages/trayvon/src/liningtip.js @@ -1,9 +1,4 @@ -import { - calculateHelpers, - draftTieShape, - tieShapeDimensions, - seamAllowance -} from "./shared"; +import { calculateHelpers, draftTieShape, tieShapeDimensions, seamAllowance } from './shared' export default part => { let { @@ -17,17 +12,14 @@ export default part => { points, sa, snippets - } = part.shorthand(); + } = part.shorthand() - calculateHelpers(part); - draftTieShape(part, options.tipWidth * 2.5, options.knotWidth * 2.5); + calculateHelpers(part) + draftTieShape(part, options.tipWidth * 2.5, options.knotWidth * 2.5) // Cut part short - points.cutRight = points.tipRight.shiftTowards( - points.midRight, - options.tipWidth * 2.5 - ); - points.cutLeft = points.cutRight.flipX(); + points.cutRight = points.tipRight.shiftTowards(points.midRight, options.tipWidth * 2.5) + points.cutLeft = points.cutRight.flipX() // Overwrite path paths.seam = new Path() @@ -38,25 +30,25 @@ export default part => { .line(points.tipRight) .line(points.tip) .close() - .attr("class", "lining"); + .attr('class', 'lining') // Complete pattern? if (complete) { - macro("title", { + macro('title', { at: points.title, nr: 5, - title: "liningTip", + title: 'liningTip', rotation: -90 - }); - snippets.notch = new Snippet("notch", points.tip); + }) + snippets.notch = new Snippet('notch', points.tip) - if (sa) seamAllowance(part, "lining"); + if (sa) seamAllowance(part, 'lining') } // Paperless? if (paperless) { - tieShapeDimensions(part, true); + tieShapeDimensions(part, true) } - return part; -}; + return part +} diff --git a/packages/trayvon/src/loop.js b/packages/trayvon/src/loop.js index 6ee4c8e3184..1e978cad838 100644 --- a/packages/trayvon/src/loop.js +++ b/packages/trayvon/src/loop.js @@ -1,22 +1,10 @@ export default part => { - let { - points, - Point, - paths, - Path, - complete, - paperless, - store, - macro - } = part.shorthand(); + let { points, Point, paths, Path, complete, paperless, store, macro } = part.shorthand() - points.topLeft = new Point(0, 0); - points.bottomRight = new Point( - store.get("backTip") * 3.5, - store.get("backTip") - ); - points.topRight = new Point(points.bottomRight.x, points.topLeft.y); - points.bottomLeft = new Point(points.topLeft.x, points.bottomRight.y); + points.topLeft = new Point(0, 0) + points.bottomRight = new Point(store.get('backTip') * 3.5, store.get('backTip')) + points.topRight = new Point(points.bottomRight.x, points.topLeft.y) + points.bottomLeft = new Point(points.topLeft.x, points.bottomRight.y) paths.seam = new Path() .move(points.topLeft) @@ -25,30 +13,30 @@ export default part => { .line(points.topRight) .line(points.topLeft) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') if (complete) { - points.title = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5); + points.title = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5) - macro("title", { + macro('title', { nr: 7, - title: "loop", + title: 'loop', at: points.title - }); + }) } if (paperless) { - macro("hd", { + macro('hd', { from: points.bottomLeft, to: points.bottomRight, y: points.bottomRight.y + 15 - }); - macro("vd", { + }) + macro('vd', { from: points.topRight, to: points.bottomRight, x: points.topRight.x + 15 - }); + }) } - return part; -}; + return part +} diff --git a/packages/trayvon/src/shared.js b/packages/trayvon/src/shared.js index 5c2b0fdecc5..afd197d5b45 100644 --- a/packages/trayvon/src/shared.js +++ b/packages/trayvon/src/shared.js @@ -1,64 +1,45 @@ export const calculateHelpers = part => { - let { store, measurements, options } = part.shorthand(); + let { store, measurements, options } = part.shorthand() let halfLength = (measurements.centerBackNeckToWaist + measurements.naturalWaistToHip + measurements.neckCircumference / 2) * - (1 + options.lengthBonus); - let backTip = options.tipWidth * 0.7; - if (backTip < options.knotWidth) backTip = options.knotWidth; + (1 + options.lengthBonus) + let backTip = options.tipWidth * 0.7 + if (backTip < options.knotWidth) backTip = options.knotWidth - store.set("halfLength", halfLength); - store.set("backTip", backTip); -}; + store.set('halfLength', halfLength) + store.set('backTip', backTip) +} export const draftTieShape = (part, tipWidth, knotWidth, notch = false) => { - let { - points, - Point, - store, - utils, - options, - paths, - Path, - macro - } = part.shorthand(); + let { points, Point, store, utils, options, paths, Path, macro } = part.shorthand() - let hl = store.get("halfLength"); - let ht = tipWidth / 2; - let hk = knotWidth / 2; + let hl = store.get('halfLength') + let ht = tipWidth / 2 + let hk = knotWidth / 2 - points.tip = new Point(0, 0); - points.mid = new Point(0, hl); - points.tipRight = new Point(ht, ht); - points.tipLeft = points.tipRight.flipX(); - points._tmp1 = points.mid.shift(0, hk); - points._tmp2 = points._tmp1.rotate(45, points.mid); - points.midRight = utils.beamsIntersect( - points.mid, - points._tmp2, - points.tipRight, - points._tmp1 - ); - points._tmp3 = points.mid.shift(180, hk); - points._tmp4 = points._tmp3.rotate(45, points.mid); - points.midLeft = utils.beamsIntersect( - points.mid, - points._tmp4, - points.tipLeft, - points._tmp3 - ); - points.gridAnchor = new Point(0, points.tipRight.y); - points.title = new Point(0, hl / 5); + points.tip = new Point(0, 0) + points.mid = new Point(0, hl) + points.tipRight = new Point(ht, ht) + points.tipLeft = points.tipRight.flipX() + points._tmp1 = points.mid.shift(0, hk) + points._tmp2 = points._tmp1.rotate(45, points.mid) + points.midRight = utils.beamsIntersect(points.mid, points._tmp2, points.tipRight, points._tmp1) + points._tmp3 = points.mid.shift(180, hk) + points._tmp4 = points._tmp3.rotate(45, points.mid) + points.midLeft = utils.beamsIntersect(points.mid, points._tmp4, points.tipLeft, points._tmp3) + points.gridAnchor = new Point(0, points.tipRight.y) + points.title = new Point(0, hl / 5) if (notch) { - points.notch1 = points.tip.shift(-45, options.tipWidth / 5); - points.notch2 = points.tip.shift(-135, options.tipWidth / 5); - macro("sprinkle", { - snippet: "notch", - on: ["notch1", "notch2", "mid"] - }); + points.notch1 = points.tip.shift(-45, options.tipWidth / 5) + points.notch2 = points.tip.shift(-135, options.tipWidth / 5) + macro('sprinkle', { + snippet: 'notch', + on: ['notch1', 'notch2', 'mid'] + }) } paths.seam = new Path() .move(points.tip) @@ -67,58 +48,58 @@ export const draftTieShape = (part, tipWidth, knotWidth, notch = false) => { .line(points.midRight) .line(points.tipRight) .line(points.tip) - .close(); -}; + .close() +} export const tieShapeDimensions = (part, lining = false) => { - let { points, macro, paths, Path } = part.shorthand(); + let { points, macro, paths, Path } = part.shorthand() - macro("hd", { + macro('hd', { from: points.tipLeft, to: points.tipRight, y: points.tip.y - 15 - }); - macro("vd", { + }) + macro('vd', { from: points.tipRight, to: points.tip, x: points.tipRight.x + 15 - }); + }) if (lining) { - macro("vd", { + macro('vd', { from: points.cutRight, to: points.tip, x: points.cutRight.x + 30 - }); + }) } else { - macro("hd", { + macro('hd', { from: points._tmp3, to: points._tmp1, y: points.midLeft.y + 15 - }); - macro("vd", { + }) + macro('vd', { from: points.mid, to: points.tip, x: points.tipRight.x + 30 - }); + }) paths.hint = new Path() .move(points._tmp3) .line(points._tmp1) .line(points.midRight) - .attr("class", "dotted"); + .attr('class', 'dotted') } -}; +} export const seamAllowance = (part, className) => { - let { paths, Path, points, sa } = part.shorthand(); + let { paths, Path, points, sa } = part.shorthand() paths.sa = new Path() .move(points.tipLeft) .line(points.tip) .line(points.tipRight) .offset(sa * -1) - .attr("class", "sa " + className); + .attr('class', 'sa ' + className) paths.sa .move(paths.sa.end()) .line(points.tipRight) .move(paths.sa.start()) - .line(points.tipLeft); -}; + .line(points.tipLeft) +} diff --git a/packages/tutorial/example/src/App.js b/packages/tutorial/example/src/App.js index e7936330e5d..115cdf683af 100644 --- a/packages/tutorial/example/src/App.js +++ b/packages/tutorial/example/src/App.js @@ -1,22 +1,15 @@ -import React from "react"; -import freesewing from "@freesewing/core"; -import Workbench from "@freesewing/components/Workbench"; -import "typeface-roboto-condensed"; -import "@freesewing/css-theme"; +import React from 'react' +import freesewing from '@freesewing/core' +import Workbench from '@freesewing/components/Workbench' +import 'typeface-roboto-condensed' +import '@freesewing/css-theme' -import Pattern from "pattern"; +import Pattern from 'pattern' const App = props => { - let instance = new Pattern(); - let config = instance.config; - return ( - - ); -}; + let instance = new Pattern() + let config = instance.config + return +} -export default App; +export default App diff --git a/packages/tutorial/example/src/index.js b/packages/tutorial/example/src/index.js index 7900787a4d2..9dd7ba788d4 100644 --- a/packages/tutorial/example/src/index.js +++ b/packages/tutorial/example/src/index.js @@ -1,11 +1,11 @@ -import React from "react"; -import ReactDOM from "react-dom"; -import App from "./App"; -import * as serviceWorker from "./serviceWorker"; +import React from 'react' +import ReactDOM from 'react-dom' +import App from './App' +import * as serviceWorker from './serviceWorker' -ReactDOM.render(, document.getElementById("root")); +ReactDOM.render(, document.getElementById('root')) // If you want your app to work offline and load faster, you can change // unregister() to register() below. Note this comes with some pitfalls. // Learn more about service workers: http://bit.ly/CRA-PWA -serviceWorker.unregister(); +serviceWorker.unregister() diff --git a/packages/tutorial/example/src/serviceWorker.js b/packages/tutorial/example/src/serviceWorker.js index 68fda5a0eb6..44e1b1b2f8c 100644 --- a/packages/tutorial/example/src/serviceWorker.js +++ b/packages/tutorial/example/src/serviceWorker.js @@ -9,46 +9,44 @@ // This link also includes instructions on opting out of this behavior. const isLocalhost = Boolean( - window.location.hostname === "localhost" || + window.location.hostname === 'localhost' || // [::1] is the IPv6 localhost address. - window.location.hostname === "[::1]" || + window.location.hostname === '[::1]' || // 127.0.0.1/8 is considered localhost for IPv4. - window.location.hostname.match( - /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ - ) -); + window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/) +) export function register(config) { - if (process.env.NODE_ENV === "production" && "serviceWorker" in navigator) { + if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) { // The URL constructor is available in all browsers that support SW. - const publicUrl = new URL(process.env.PUBLIC_URL, window.location); + const publicUrl = new URL(process.env.PUBLIC_URL, window.location) if (publicUrl.origin !== window.location.origin) { // Our service worker won't work if PUBLIC_URL is on a different origin // from what our page is served on. This might happen if a CDN is used to // serve assets; see https://github.com/facebook/create-react-app/issues/2374 - return; + return } - window.addEventListener("load", () => { - const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; + window.addEventListener('load', () => { + const swUrl = `${process.env.PUBLIC_URL}/service-worker.js` if (isLocalhost) { // This is running on localhost. Let's check if a service worker still exists or not. - checkValidServiceWorker(swUrl, config); + checkValidServiceWorker(swUrl, config) // Add some additional logging to localhost, pointing developers to the // service worker/PWA documentation. navigator.serviceWorker.ready.then(() => { console.log( - "This web app is being served cache-first by a service " + - "worker. To learn more, visit https://goo.gl/SC7cgQ" - ); - }); + 'This web app is being served cache-first by a service ' + + 'worker. To learn more, visit https://goo.gl/SC7cgQ' + ) + }) } else { // Is not local host. Just register service worker - registerValidSW(swUrl, config); + registerValidSW(swUrl, config) } - }); + }) } } @@ -57,38 +55,38 @@ function registerValidSW(swUrl, config) { .register(swUrl) .then(registration => { registration.onupdatefound = () => { - const installingWorker = registration.installing; + const installingWorker = registration.installing installingWorker.onstatechange = () => { - if (installingWorker.state === "installed") { + if (installingWorker.state === 'installed') { if (navigator.serviceWorker.controller) { // At this point, the old content will have been purged and // the fresh content will have been added to the cache. // It's the perfect time to display a "New content is // available; please refresh." message in your web app. - console.log("New content is available; please refresh."); + console.log('New content is available; please refresh.') // Execute callback if (config.onUpdate) { - config.onUpdate(registration); + config.onUpdate(registration) } } else { // At this point, everything has been precached. // It's the perfect time to display a // "Content is cached for offline use." message. - console.log("Content is cached for offline use."); + console.log('Content is cached for offline use.') // Execute callback if (config.onSuccess) { - config.onSuccess(registration); + config.onSuccess(registration) } } } - }; - }; + } + } }) .catch(error => { - console.error("Error during service worker registration:", error); - }); + console.error('Error during service worker registration:', error) + }) } function checkValidServiceWorker(swUrl, config) { @@ -98,30 +96,28 @@ function checkValidServiceWorker(swUrl, config) { // Ensure service worker exists, and that we really are getting a JS file. if ( response.status === 404 || - response.headers.get("content-type").indexOf("javascript") === -1 + response.headers.get('content-type').indexOf('javascript') === -1 ) { // No service worker found. Probably a different app. Reload the page. navigator.serviceWorker.ready.then(registration => { registration.unregister().then(() => { - window.location.reload(); - }); - }); + window.location.reload() + }) + }) } else { // Service worker found. Proceed as normal. - registerValidSW(swUrl, config); + registerValidSW(swUrl, config) } }) .catch(() => { - console.log( - "No internet connection found. App is running in offline mode." - ); - }); + console.log('No internet connection found. App is running in offline mode.') + }) } export function unregister() { - if ("serviceWorker" in navigator) { + if ('serviceWorker' in navigator) { navigator.serviceWorker.ready.then(registration => { - registration.unregister(); - }); + registration.unregister() + }) } } diff --git a/packages/tutorial/src/bib.js b/packages/tutorial/src/bib.js index 7eb3c61d1cb..d069a546a3e 100644 --- a/packages/tutorial/src/bib.js +++ b/packages/tutorial/src/bib.js @@ -11,144 +11,132 @@ export default function(part) { snippets, Snippet, paperless - } = part.shorthand(); + } = part.shorthand() // Construct the neck opening - let tweak = 1; - let target = (measurements.headCircumference * options.neckRatio) / 4; - let delta; + let tweak = 1 + let target = (measurements.headCircumference * options.neckRatio) / 4 + let delta do { - points.right = new Point((tweak * measurements.headCircumference) / 10, 0); - points.bottom = new Point(0, (tweak * measurements.headCircumference) / 12); + points.right = new Point((tweak * measurements.headCircumference) / 10, 0) + points.bottom = new Point(0, (tweak * measurements.headCircumference) / 12) - points.rightCp1 = points.right.shift( - 90, - points.bottom.dy(points.right) / 2 - ); - points.bottomCp2 = points.bottom.shift( - 0, - points.bottom.dx(points.right) / 2 - ); + points.rightCp1 = points.right.shift(90, points.bottom.dy(points.right) / 2) + points.bottomCp2 = points.bottom.shift(0, points.bottom.dx(points.right) / 2) paths.neck = new Path() .move(points.right) - .curve(points.rightCp1, points.bottomCp2, points.bottom); + .curve(points.rightCp1, points.bottomCp2, points.bottom) - delta = paths.neck.length() - target; - if (delta > 0) tweak = tweak * 0.99; - else tweak = tweak * 1.02; - } while (Math.abs(delta) > 1); + delta = paths.neck.length() - target + if (delta > 0) tweak = tweak * 0.99 + else tweak = tweak * 1.02 + } while (Math.abs(delta) > 1) - points.rightCp2 = points.rightCp1.flipY(); - points.bottomCp1 = points.bottomCp2.flipX(); + points.rightCp2 = points.rightCp1.flipY() + points.bottomCp1 = points.bottomCp2.flipX() - points.left = points.right.flipX(); - points.leftCp1 = points.rightCp2.flipX(); - points.leftCp2 = points.rightCp1.flipX(); + points.left = points.right.flipX() + points.leftCp1 = points.rightCp2.flipX() + points.leftCp2 = points.rightCp1.flipX() - points.top = points.bottom.flipY(); - points.topCp1 = points.bottomCp2.flipY(); - points.topCp2 = points.bottomCp1.flipY(); + points.top = points.bottom.flipY() + points.topCp1 = points.bottomCp2.flipY() + points.topCp2 = points.bottomCp1.flipY() // Construct the outline - let width = measurements.headCircumference * options.widthRatio; - let length = measurements.headCircumference * options.lengthRatio; + let width = measurements.headCircumference * options.widthRatio + let length = measurements.headCircumference * options.lengthRatio - points.topLeft = new Point( - width / -2, - points.top.y - (width / 2 - points.right.x) - ); - points.topRight = points.topLeft.shift(0, width); - points.bottomLeft = points.topLeft.shift(-90, length); - points.bottomRight = points.topRight.shift(-90, length); + points.topLeft = new Point(width / -2, points.top.y - (width / 2 - points.right.x)) + points.topRight = points.topLeft.shift(0, width) + points.bottomLeft = points.topLeft.shift(-90, length) + points.bottomRight = points.topRight.shift(-90, length) - points.edgeLeft = new Point(points.topLeft.x, points.left.y); - points.edgeRight = new Point(points.topRight.x, points.right.y); - points.edgeTop = new Point(0, points.topLeft.y); + points.edgeLeft = new Point(points.topLeft.x, points.left.y) + points.edgeRight = new Point(points.topRight.x, points.right.y) + points.edgeTop = new Point(0, points.topLeft.y) - points.edgeLeftCp = points.edgeLeft.shiftFractionTowards(points.topLeft, 0.5); - points.edgeRightCp = points.edgeLeftCp.flipX(); - points.edgeTopLeftCp = points.edgeTop.shiftFractionTowards( - points.topLeft, - 0.5 - ); - points.edgeTopRightCp = points.edgeTopLeftCp.flipX(); + points.edgeLeftCp = points.edgeLeft.shiftFractionTowards(points.topLeft, 0.5) + points.edgeRightCp = points.edgeLeftCp.flipX() + points.edgeTopLeftCp = points.edgeTop.shiftFractionTowards(points.topLeft, 0.5) + points.edgeTopRightCp = points.edgeTopLeftCp.flipX() // Round the end of the straps - let strap = points.edgeTop.dy(points.top); + let strap = points.edgeTop.dy(points.top) - points.tipRight = points.edgeTop.translate(strap / 2, strap / 2); - points.tipRightTop = new Point(points.tipRight.x, points.edgeTop.y); - points.tipRightBottom = new Point(points.tipRight.x, points.top.y); + points.tipRight = points.edgeTop.translate(strap / 2, strap / 2) + points.tipRightTop = new Point(points.tipRight.x, points.edgeTop.y) + points.tipRightBottom = new Point(points.tipRight.x, points.top.y) - macro("round", { + macro('round', { from: points.edgeTop, to: points.tipRight, via: points.tipRightTop, - prefix: "tipRightTop" - }); - macro("round", { + prefix: 'tipRightTop' + }) + macro('round', { from: points.tipRight, to: points.top, via: points.tipRightBottom, - prefix: "tipRightBottom" - }); + prefix: 'tipRightBottom' + }) // Rotate straps so they don't overlap let rotateThese = [ - "edgeTopLeftCp", - "edgeTop", - "tipRight", - "tipRightTop", - "tipRightTopStart", - "tipRightTopCp1", - "tipRightTopCp2", - "tipRightTopEnd", - "tipRightBottomStart", - "tipRightBottomCp1", - "tipRightBottomCp2", - "tipRightBottomEnd", - "tipRightBottom", - "top", - "topCp2" - ]; + 'edgeTopLeftCp', + 'edgeTop', + 'tipRight', + 'tipRightTop', + 'tipRightTopStart', + 'tipRightTopCp1', + 'tipRightTopCp2', + 'tipRightTopEnd', + 'tipRightBottomStart', + 'tipRightBottomCp1', + 'tipRightBottomCp2', + 'tipRightBottomEnd', + 'tipRightBottom', + 'top', + 'topCp2' + ] while (points.tipRightBottomStart.x > -1) { - for (let p of rotateThese) points[p] = points[p].rotate(1, points.edgeLeft); + for (let p of rotateThese) points[p] = points[p].rotate(1, points.edgeLeft) } // Add points to anchor snaps on - points.snapLeft = points.top.shiftFractionTowards(points.edgeTop, 0.5); + points.snapLeft = points.top.shiftFractionTowards(points.edgeTop, 0.5) // Mirror points to the other side - points.edgeTopRightCp = points.edgeTopLeftCp.flipX(); - points.topCp1 = points.topCp2.flipX(); - points.tipLeftTopStart = points.tipRightTopStart.flipX(); - points.tipLeftTopCp1 = points.tipRightTopCp1.flipX(); - points.tipLeftTopCp2 = points.tipRightTopCp2.flipX(); - points.tipLeftTopEnd = points.tipRightTopEnd.flipX(); - points.tipLeftBottomStart = points.tipRightBottomStart.flipX(); - points.tipLeftBottomCp1 = points.tipRightBottomCp1.flipX(); - points.tipLeftBottomCp2 = points.tipRightBottomCp2.flipX(); - points.tipLeftBottomEnd = points.tipRightBottomEnd.flipX(); - points.snapRight = points.snapLeft.flipX(); + points.edgeTopRightCp = points.edgeTopLeftCp.flipX() + points.topCp1 = points.topCp2.flipX() + points.tipLeftTopStart = points.tipRightTopStart.flipX() + points.tipLeftTopCp1 = points.tipRightTopCp1.flipX() + points.tipLeftTopCp2 = points.tipRightTopCp2.flipX() + points.tipLeftTopEnd = points.tipRightTopEnd.flipX() + points.tipLeftBottomStart = points.tipRightBottomStart.flipX() + points.tipLeftBottomCp1 = points.tipRightBottomCp1.flipX() + points.tipLeftBottomCp2 = points.tipRightBottomCp2.flipX() + points.tipLeftBottomEnd = points.tipRightBottomEnd.flipX() + points.snapRight = points.snapLeft.flipX() // Round the bottom of the bib // Radius is fixed, but you could use an option for it) - macro("round", { + macro('round', { from: points.topLeft, to: points.bottomRight, via: points.bottomLeft, radius: points.bottomRight.x / 4, - prefix: "bottomLeft" - }); - macro("round", { + prefix: 'bottomLeft' + }) + macro('round', { from: points.bottomLeft, to: points.topRight, via: points.bottomRight, radius: points.bottomRight.x / 4, - prefix: "bottomRight" - }); + prefix: 'bottomRight' + }) // Construct the path paths.seam = new Path() @@ -160,96 +148,81 @@ export default function(part) { .line(points.edgeRight) .curve(points.edgeRightCp, points.edgeTopRightCp, points.tipLeftTopStart) .curve(points.tipLeftTopCp1, points.tipLeftTopCp2, points.tipLeftTopEnd) - .curve( - points.tipLeftBottomCp1, - points.tipLeftBottomCp2, - points.tipLeftBottomEnd - ) + .curve(points.tipLeftBottomCp1, points.tipLeftBottomCp2, points.tipLeftBottomEnd) .curve(points.topCp1, points.rightCp2, points.right) .curve(points.rightCp1, points.bottomCp2, points.bottom) .curve(points.bottomCp1, points.leftCp2, points.left) .curve(points.leftCp1, points.topCp2, points.tipRightBottomEnd) - .curve( - points.tipRightBottomCp2, - points.tipRightBottomCp1, - points.tipRightBottomStart - ) - .curve( - points.tipRightTopCp2, - points.tipRightTopCp1, - points.tipRightTopStart - ) + .curve(points.tipRightBottomCp2, points.tipRightBottomCp1, points.tipRightBottomStart) + .curve(points.tipRightTopCp2, points.tipRightTopCp1, points.tipRightTopStart) .curve(points.edgeTopLeftCp, points.edgeLeftCp, points.edgeLeft) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') // Complete? if (complete) { // Add the snaps - snippets.snapMale = new Snippet("snap-male", points.snapLeft); - snippets.snapFemale = new Snippet("snap-female", points.snapRight).attr( - "opacity", - 0.5 - ); + snippets.snapMale = new Snippet('snap-male', points.snapLeft) + snippets.snapFemale = new Snippet('snap-female', points.snapRight).attr('opacity', 0.5) // Add the bias tape paths.bias = paths.seam .offset(-5) - .attr("class", "various dashed") - .attr("data-text", "finishWithBiasTape") - .attr("data-text-class", "center fill-various"); + .attr('class', 'various dashed') + .attr('data-text', 'finishWithBiasTape') + .attr('data-text-class', 'center fill-various') // Add the title - points.title = points.bottom.shift(-90, 45); - macro("title", { + points.title = points.bottom.shift(-90, 45) + macro('title', { at: points.title, nr: 1, - title: "bib" - }); + title: 'bib' + }) // Add the scalebox - points.scalebox = points.title.shift(-90, 55); - macro("scalebox", { at: points.scalebox }); + points.scalebox = points.title.shift(-90, 55) + macro('scalebox', { at: points.scalebox }) // Add the logo - points.logo = new Point(0, 0); - snippets.logo = new Snippet("logo", points.logo); + points.logo = new Point(0, 0) + snippets.logo = new Snippet('logo', points.logo) // Paperless? if (paperless) { // Add dimensions - macro("hd", { + macro('hd', { from: points.bottomLeftStart, to: points.bottomRightEnd, y: points.bottomLeft.y + 15 - }); - macro("vd", { + }) + macro('vd', { from: points.bottomRightStart, to: points.bottom, x: points.bottomRight.x + 15 - }); - macro("vd", { + }) + macro('vd', { from: points.bottomRightStart, to: points.right, x: points.bottomRight.x + 30 - }); - macro("vd", { + }) + macro('vd', { from: points.bottomRightStart, to: points.tipLeftTopStart, x: points.bottomRight.x + 45 - }); - macro("hd", { + }) + macro('hd', { from: points.left, to: points.right, y: points.left.y + 25 - }); - macro("ld", { + }) + macro('ld', { from: points.tipLeftBottomEnd, to: points.tipLeftTopStart, d: -15 - }); + }) } } - return part; + return part } diff --git a/packages/tutorial/src/index.js b/packages/tutorial/src/index.js index 1a3aa2ce83c..d317dfe7dae 100644 --- a/packages/tutorial/src/index.js +++ b/packages/tutorial/src/index.js @@ -1,35 +1,35 @@ -import freesewing from "@freesewing/core"; -import plugins from "@freesewing/plugin-bundle"; -import config from "../config"; -import draftBib from "./bib"; +import freesewing from '@freesewing/core' +import plugins from '@freesewing/plugin-bundle' +import config from '../config' +import draftBib from './bib' // Intermediate steps for tutorial -import draftStep1 from "./step1"; -import draftStep2 from "./step2"; -import draftStep3 from "./step3"; -import draftStep4 from "./step4"; -import draftStep5 from "./step5"; -import draftStep6 from "./step6"; -import draftStep7 from "./step7"; -import draftStep8 from "./step8"; -import draftStep9 from "./step9"; -import draftStep10 from "./step10"; -import draftStep11 from "./step11"; +import draftStep1 from './step1' +import draftStep2 from './step2' +import draftStep3 from './step3' +import draftStep4 from './step4' +import draftStep5 from './step5' +import draftStep6 from './step6' +import draftStep7 from './step7' +import draftStep8 from './step8' +import draftStep9 from './step9' +import draftStep10 from './step10' +import draftStep11 from './step11' // Create new design -const Pattern = new freesewing.Design(config, plugins); +const Pattern = new freesewing.Design(config, plugins) // Attach the draft methods to the prototype -Pattern.prototype.draftBib = draftBib; -Pattern.prototype.draftStep1 = draftStep1; -Pattern.prototype.draftStep2 = draftStep2; -Pattern.prototype.draftStep3 = draftStep3; -Pattern.prototype.draftStep4 = draftStep4; -Pattern.prototype.draftStep5 = draftStep5; -Pattern.prototype.draftStep6 = draftStep6; -Pattern.prototype.draftStep7 = draftStep7; -Pattern.prototype.draftStep8 = draftStep8; -Pattern.prototype.draftStep9 = draftStep9; -Pattern.prototype.draftStep10 = draftStep10; -Pattern.prototype.draftStep11 = draftStep11; +Pattern.prototype.draftBib = draftBib +Pattern.prototype.draftStep1 = draftStep1 +Pattern.prototype.draftStep2 = draftStep2 +Pattern.prototype.draftStep3 = draftStep3 +Pattern.prototype.draftStep4 = draftStep4 +Pattern.prototype.draftStep5 = draftStep5 +Pattern.prototype.draftStep6 = draftStep6 +Pattern.prototype.draftStep7 = draftStep7 +Pattern.prototype.draftStep8 = draftStep8 +Pattern.prototype.draftStep9 = draftStep9 +Pattern.prototype.draftStep10 = draftStep10 +Pattern.prototype.draftStep11 = draftStep11 -export default Pattern; +export default Pattern diff --git a/packages/tutorial/src/step1.js b/packages/tutorial/src/step1.js index c94c7fc6633..b22cbb1053f 100644 --- a/packages/tutorial/src/step1.js +++ b/packages/tutorial/src/step1.js @@ -11,13 +11,13 @@ export default function(part) { sa, paperless, macro - } = part.shorthand(); + } = part.shorthand() - let w = 500 * options.size; - points.topLeft = new Point(0, 0); - points.topRight = new Point(w, 0); - points.bottomLeft = new Point(0, w / 2); - points.bottomRight = new Point(w, w / 2); + let w = 500 * options.size + points.topLeft = new Point(0, 0) + points.topRight = new Point(w, 0) + points.bottomLeft = new Point(0, w / 2) + points.bottomRight = new Point(w, w / 2) paths.seam = new Path() .move(points.topLeft) @@ -26,35 +26,35 @@ export default function(part) { .line(points.topRight) .line(points.topLeft) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') // Complete? if (complete) { - points.logo = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5); - snippets.logo = new Snippet("logo", points.logo); + points.logo = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5) + snippets.logo = new Snippet('logo', points.logo) points.text = points.logo .shift(-90, w / 8) - .attr("data-text", "hello") - .attr("data-text-class", "center"); + .attr('data-text', 'hello') + .attr('data-text-class', 'center') if (sa) { - paths.sa = paths.seam.offset(sa).attr("class", "fabric sa"); + paths.sa = paths.seam.offset(sa).attr('class', 'fabric sa') } } // Paperless? if (paperless) { - macro("hd", { + macro('hd', { from: points.bottomLeft, to: points.bottomRight, y: points.bottomLeft.y + sa + 15 - }); - macro("vd", { + }) + macro('vd', { from: points.bottomRight, to: points.topRight, x: points.topRight.x + sa + 15 - }); + }) } - return part; + return part } diff --git a/packages/tutorial/src/step10.js b/packages/tutorial/src/step10.js index 64c2ccbf21b..9baae925f57 100644 --- a/packages/tutorial/src/step10.js +++ b/packages/tutorial/src/step10.js @@ -1,22 +1,22 @@ export default function(part) { - let { points, Path, paths, macro } = part.shorthand(); + let { points, Path, paths, macro } = part.shorthand() - macro("round", { + macro('round', { from: points.topLeft, to: points.bottomRight, via: points.bottomLeft, radius: points.bottomRight.x / 4, render: true, - prefix: "bottomLeft" - }); - macro("round", { + prefix: 'bottomLeft' + }) + macro('round', { from: points.bottomLeft, to: points.topRight, via: points.bottomRight, radius: points.bottomRight.x / 4, render: true, - prefix: "bottomRight" - }); + prefix: 'bottomRight' + }) paths.seam = new Path() .move(points.edgeLeft) @@ -27,27 +27,15 @@ export default function(part) { .line(points.edgeRight) .curve(points.edgeRightCp, points.edgeTopRightCp, points.tipLeftTopStart) .curve(points.tipLeftTopCp1, points.tipLeftTopCp2, points.tipLeftTopEnd) - .curve( - points.tipLeftBottomCp1, - points.tipLeftBottomCp2, - points.tipLeftBottomEnd - ) + .curve(points.tipLeftBottomCp1, points.tipLeftBottomCp2, points.tipLeftBottomEnd) .curve(points.topCp1, points.rightCp2, points.right) .curve(points.rightCp1, points.bottomCp2, points.bottom) .curve(points.bottomCp1, points.leftCp2, points.left) .curve(points.leftCp1, points.topCp2, points.tipRightBottomEnd) - .curve( - points.tipRightBottomCp2, - points.tipRightBottomCp1, - points.tipRightBottomStart - ) - .curve( - points.tipRightTopCp2, - points.tipRightTopCp1, - points.tipRightTopStart - ) + .curve(points.tipRightBottomCp2, points.tipRightBottomCp1, points.tipRightBottomStart) + .curve(points.tipRightTopCp2, points.tipRightTopCp1, points.tipRightTopStart) .curve(points.edgeTopLeftCp, points.edgeLeftCp, points.edgeLeft) - .close(); + .close() - return part; + return part } diff --git a/packages/tutorial/src/step11.js b/packages/tutorial/src/step11.js index 897b29ff5c2..c7d9a2f3447 100644 --- a/packages/tutorial/src/step11.js +++ b/packages/tutorial/src/step11.js @@ -1,41 +1,30 @@ export default function(part) { - let { - Point, - points, - paths, - macro, - complete, - snippets, - Snippet - } = part.shorthand(); + let { Point, points, paths, macro, complete, snippets, Snippet } = part.shorthand() // Complete? if (complete) { - snippets.snapMale = new Snippet("snap-male", points.snapLeft); - snippets.snapFemale = new Snippet("snap-female", points.snapRight).attr( - "opacity", - 0.5 - ); + snippets.snapMale = new Snippet('snap-male', points.snapLeft) + snippets.snapFemale = new Snippet('snap-female', points.snapRight).attr('opacity', 0.5) paths.bias = paths.seam .offset(-5) - .attr("class", "various dashed") - .attr("data-text", "finishWithBiasTape") - .attr("data-text-class", "center fill-various"); + .attr('class', 'various dashed') + .attr('data-text', 'finishWithBiasTape') + .attr('data-text-class', 'center fill-various') - points.title = points.bottom.shift(-90, 45); - macro("title", { + points.title = points.bottom.shift(-90, 45) + macro('title', { at: points.title, nr: 1, - title: "bib" - }); + title: 'bib' + }) - points.scalebox = points.title.shift(-90, 55); - macro("scalebox", { at: points.scalebox }); + points.scalebox = points.title.shift(-90, 55) + macro('scalebox', { at: points.scalebox }) - points.logo = new Point(0, 0); - snippets.logo = new Snippet("logo", points.logo); + points.logo = new Point(0, 0) + snippets.logo = new Snippet('logo', points.logo) } - return part; + return part } diff --git a/packages/tutorial/src/step2.js b/packages/tutorial/src/step2.js index 123d7de8b22..d8062b35696 100644 --- a/packages/tutorial/src/step2.js +++ b/packages/tutorial/src/step2.js @@ -1,15 +1,13 @@ export default function(part) { - let { Point, points, Path, paths, measurements } = part.shorthand(); + let { Point, points, Path, paths, measurements } = part.shorthand() - points.right = new Point(measurements.headCircumference / 10, 0); - points.bottom = new Point(0, measurements.headCircumference / 12); + points.right = new Point(measurements.headCircumference / 10, 0) + points.bottom = new Point(0, measurements.headCircumference / 12) - points.rightCp1 = points.right.shift(90, points.bottom.dy(points.right) / 2); - points.bottomCp2 = points.bottom.shift(0, points.bottom.dx(points.right) / 2); + points.rightCp1 = points.right.shift(90, points.bottom.dy(points.right) / 2) + points.bottomCp2 = points.bottom.shift(0, points.bottom.dx(points.right) / 2) - paths.neck = new Path() - .move(points.right) - .curve(points.rightCp1, points.bottomCp2, points.bottom); + paths.neck = new Path().move(points.right).curve(points.rightCp1, points.bottomCp2, points.bottom) - return part; + return part } diff --git a/packages/tutorial/src/step3.js b/packages/tutorial/src/step3.js index de55cac14d3..5b16627f432 100644 --- a/packages/tutorial/src/step3.js +++ b/packages/tutorial/src/step3.js @@ -1,30 +1,24 @@ export default function(part) { - let { Point, points, Path, paths, measurements, options } = part.shorthand(); + let { Point, points, Path, paths, measurements, options } = part.shorthand() - let tweak = 1; - let target = (measurements.headCircumference * options.neckRatio) / 4; - let delta; + let tweak = 1 + let target = (measurements.headCircumference * options.neckRatio) / 4 + let delta do { - points.right = new Point((tweak * measurements.headCircumference) / 10, 0); - points.bottom = new Point(0, (tweak * measurements.headCircumference) / 12); + points.right = new Point((tweak * measurements.headCircumference) / 10, 0) + points.bottom = new Point(0, (tweak * measurements.headCircumference) / 12) - points.rightCp1 = points.right.shift( - 90, - points.bottom.dy(points.right) / 2 - ); - points.bottomCp2 = points.bottom.shift( - 0, - points.bottom.dx(points.right) / 2 - ); + points.rightCp1 = points.right.shift(90, points.bottom.dy(points.right) / 2) + points.bottomCp2 = points.bottom.shift(0, points.bottom.dx(points.right) / 2) paths.neck = new Path() .move(points.right) - .curve(points.rightCp1, points.bottomCp2, points.bottom); + .curve(points.rightCp1, points.bottomCp2, points.bottom) - delta = paths.neck.length() - target; - if (delta > 0) tweak = tweak * 0.99; - else tweak = tweak * 1.02; - } while (Math.abs(delta) > 1); + delta = paths.neck.length() - target + if (delta > 0) tweak = tweak * 0.99 + else tweak = tweak * 1.02 + } while (Math.abs(delta) > 1) - return part; + return part } diff --git a/packages/tutorial/src/step4.js b/packages/tutorial/src/step4.js index ddec41a8f8a..b978c6b866f 100644 --- a/packages/tutorial/src/step4.js +++ b/packages/tutorial/src/step4.js @@ -1,16 +1,16 @@ export default function(part) { - let { points, Path, paths } = part.shorthand(); + let { points, Path, paths } = part.shorthand() - points.rightCp2 = points.rightCp1.flipY(); - points.bottomCp1 = points.bottomCp2.flipX(); + points.rightCp2 = points.rightCp1.flipY() + points.bottomCp1 = points.bottomCp2.flipX() - points.left = points.right.flipX(); - points.leftCp1 = points.rightCp2.flipX(); - points.leftCp2 = points.rightCp1.flipX(); + points.left = points.right.flipX() + points.leftCp1 = points.rightCp2.flipX() + points.leftCp2 = points.rightCp1.flipX() - points.top = points.bottom.flipY(); - points.topCp1 = points.bottomCp2.flipY(); - points.topCp2 = points.bottomCp1.flipY(); + points.top = points.bottom.flipY() + points.topCp1 = points.bottomCp2.flipY() + points.topCp2 = points.bottomCp1.flipY() paths.neck = new Path() .move(points.top) @@ -18,7 +18,7 @@ export default function(part) { .curve(points.leftCp2, points.bottomCp1, points.bottom) .curve(points.bottomCp2, points.rightCp1, points.right) .curve(points.rightCp2, points.topCp1, points.top) - .close(); + .close() - return part; + return part } diff --git a/packages/tutorial/src/step5.js b/packages/tutorial/src/step5.js index 629311f8b8b..b19c4efb884 100644 --- a/packages/tutorial/src/step5.js +++ b/packages/tutorial/src/step5.js @@ -1,16 +1,13 @@ export default function(part) { - let { Point, points, Path, paths, measurements, options } = part.shorthand(); + let { Point, points, Path, paths, measurements, options } = part.shorthand() - let width = measurements.headCircumference * options.widthRatio; - let length = measurements.headCircumference * options.lengthRatio; + let width = measurements.headCircumference * options.widthRatio + let length = measurements.headCircumference * options.lengthRatio - points.topLeft = new Point( - width / -2, - points.top.y - (width / 2 - points.right.x) - ); - points.topRight = points.topLeft.shift(0, width); - points.bottomLeft = points.topLeft.shift(-90, length); - points.bottomRight = points.topRight.shift(-90, length); + points.topLeft = new Point(width / -2, points.top.y - (width / 2 - points.right.x)) + points.topRight = points.topLeft.shift(0, width) + points.bottomLeft = points.topLeft.shift(-90, length) + points.bottomRight = points.topRight.shift(-90, length) paths.rect = new Path() .move(points.topLeft) @@ -18,7 +15,7 @@ export default function(part) { .line(points.bottomRight) .line(points.topRight) .line(points.topLeft) - .close(); + .close() - return part; + return part } diff --git a/packages/tutorial/src/step6.js b/packages/tutorial/src/step6.js index daa73234598..f0ba47421f1 100644 --- a/packages/tutorial/src/step6.js +++ b/packages/tutorial/src/step6.js @@ -1,17 +1,14 @@ export default function(part) { - let { Point, points, Path, paths } = part.shorthand(); + let { Point, points, Path, paths } = part.shorthand() - points.edgeLeft = new Point(points.topLeft.x, points.left.y); - points.edgeRight = new Point(points.topRight.x, points.right.y); - points.edgeTop = new Point(0, points.topLeft.y); + points.edgeLeft = new Point(points.topLeft.x, points.left.y) + points.edgeRight = new Point(points.topRight.x, points.right.y) + points.edgeTop = new Point(0, points.topLeft.y) - points.edgeLeftCp = points.edgeLeft.shiftFractionTowards(points.topLeft, 0.5); - points.edgeRightCp = points.edgeLeftCp.flipX(); - points.edgeTopLeftCp = points.edgeTop.shiftFractionTowards( - points.topLeft, - 0.5 - ); - points.edgeTopRightCp = points.edgeTopLeftCp.flipX(); + points.edgeLeftCp = points.edgeLeft.shiftFractionTowards(points.topLeft, 0.5) + points.edgeRightCp = points.edgeLeftCp.flipX() + points.edgeTopLeftCp = points.edgeTop.shiftFractionTowards(points.topLeft, 0.5) + points.edgeTopRightCp = points.edgeTopLeftCp.flipX() paths.rect = new Path() .move(points.edgeTop) @@ -20,7 +17,7 @@ export default function(part) { .line(points.bottomRight) .line(points.edgeRight) .curve(points.edgeRightCp, points.edgeTopRightCp, points.edgeTop) - .close(); + .close() - return part; + return part } diff --git a/packages/tutorial/src/step7.js b/packages/tutorial/src/step7.js index 1b662841925..b3ac3e9eb85 100644 --- a/packages/tutorial/src/step7.js +++ b/packages/tutorial/src/step7.js @@ -1,26 +1,26 @@ export default function(part) { - let { Point, points, macro } = part.shorthand(); + let { Point, points, macro } = part.shorthand() - let strap = points.edgeTop.dy(points.top); + let strap = points.edgeTop.dy(points.top) - points.tipRight = points.edgeTop.translate(strap / 2, strap / 2); - points.tipRightTop = new Point(points.tipRight.x, points.edgeTop.y); - points.tipRightBottom = new Point(points.tipRight.x, points.top.y); + points.tipRight = points.edgeTop.translate(strap / 2, strap / 2) + points.tipRightTop = new Point(points.tipRight.x, points.edgeTop.y) + points.tipRightBottom = new Point(points.tipRight.x, points.top.y) - macro("round", { + macro('round', { from: points.edgeTop, to: points.tipRight, via: points.tipRightTop, - prefix: "tipRightTop", + prefix: 'tipRightTop', render: true - }); - macro("round", { + }) + macro('round', { from: points.tipRight, to: points.top, via: points.tipRightBottom, - prefix: "tipRightBottom", + prefix: 'tipRightBottom', render: true - }); + }) - return part; + return part } diff --git a/packages/tutorial/src/step8.js b/packages/tutorial/src/step8.js index cd823c3ade9..af7b618cffb 100644 --- a/packages/tutorial/src/step8.js +++ b/packages/tutorial/src/step8.js @@ -1,44 +1,44 @@ export default function(part) { - let { points, Path, paths, macro } = part.shorthand(); + let { points, Path, paths, macro } = part.shorthand() let rotateThese = [ - "edgeTopLeftCp", - "edgeTop", - "tipRight", - "tipRightTop", - "tipRightTopStart", - "tipRightTopCp1", - "tipRightTopCp2", - "tipRightTopEnd", - "tipRightBottomStart", - "tipRightBottomCp1", - "tipRightBottomCp2", - "tipRightBottomEnd", - "tipRightBottom", - "top", - "topCp2" - ]; + 'edgeTopLeftCp', + 'edgeTop', + 'tipRight', + 'tipRightTop', + 'tipRightTopStart', + 'tipRightTopCp1', + 'tipRightTopCp2', + 'tipRightTopEnd', + 'tipRightBottomStart', + 'tipRightBottomCp1', + 'tipRightBottomCp2', + 'tipRightBottomEnd', + 'tipRightBottom', + 'top', + 'topCp2' + ] while (points.tipRightBottomStart.x > -1) { - for (let p of rotateThese) points[p] = points[p].rotate(1, points.edgeLeft); + for (let p of rotateThese) points[p] = points[p].rotate(1, points.edgeLeft) } - points.snapLeft = points.top.shiftFractionTowards(points.edgeTop, 0.5); + points.snapLeft = points.top.shiftFractionTowards(points.edgeTop, 0.5) - macro("round", { + macro('round', { from: points.edgeTop, to: points.tipRight, via: points.tipRightTop, - prefix: "tipRightTop", + prefix: 'tipRightTop', render: true - }); - macro("round", { + }) + macro('round', { from: points.tipRight, to: points.top, via: points.tipRightBottom, - prefix: "tipRightBottom", + prefix: 'tipRightBottom', render: true - }); + }) paths.rect = new Path() .move(points.edgeTop) @@ -47,7 +47,7 @@ export default function(part) { .line(points.bottomRight) .line(points.edgeRight) .curve(points.edgeRightCp, points.edgeTopRightCp, points.edgeTop) - .close(); + .close() - return part; + return part } diff --git a/packages/tutorial/src/step9.js b/packages/tutorial/src/step9.js index cf88fb1a025..3135b297371 100644 --- a/packages/tutorial/src/step9.js +++ b/packages/tutorial/src/step9.js @@ -1,17 +1,17 @@ export default function(part) { - let { points, Path, paths } = part.shorthand(); + let { points, Path, paths } = part.shorthand() - points.edgeTopRightCp = points.edgeTopLeftCp.flipX(); - points.topCp1 = points.topCp2.flipX(); - points.tipLeftTopStart = points.tipRightTopStart.flipX(); - points.tipLeftTopCp1 = points.tipRightTopCp1.flipX(); - points.tipLeftTopCp2 = points.tipRightTopCp2.flipX(); - points.tipLeftTopEnd = points.tipRightTopEnd.flipX(); - points.tipLeftBottomStart = points.tipRightBottomStart.flipX(); - points.tipLeftBottomCp1 = points.tipRightBottomCp1.flipX(); - points.tipLeftBottomCp2 = points.tipRightBottomCp2.flipX(); - points.tipLeftBottomEnd = points.tipRightBottomEnd.flipX(); - points.snapRight = points.snapLeft.flipX(); + points.edgeTopRightCp = points.edgeTopLeftCp.flipX() + points.topCp1 = points.topCp2.flipX() + points.tipLeftTopStart = points.tipRightTopStart.flipX() + points.tipLeftTopCp1 = points.tipRightTopCp1.flipX() + points.tipLeftTopCp2 = points.tipRightTopCp2.flipX() + points.tipLeftTopEnd = points.tipRightTopEnd.flipX() + points.tipLeftBottomStart = points.tipRightBottomStart.flipX() + points.tipLeftBottomCp1 = points.tipRightBottomCp1.flipX() + points.tipLeftBottomCp2 = points.tipRightBottomCp2.flipX() + points.tipLeftBottomEnd = points.tipRightBottomEnd.flipX() + points.snapRight = points.snapLeft.flipX() paths.seam = new Path() .move(points.edgeLeft) @@ -20,31 +20,19 @@ export default function(part) { .line(points.edgeRight) .curve(points.edgeRightCp, points.edgeTopRightCp, points.tipLeftTopStart) .curve(points.tipLeftTopCp1, points.tipLeftTopCp2, points.tipLeftTopEnd) - .curve( - points.tipLeftBottomCp1, - points.tipLeftBottomCp2, - points.tipLeftBottomEnd - ) + .curve(points.tipLeftBottomCp1, points.tipLeftBottomCp2, points.tipLeftBottomEnd) .curve(points.topCp1, points.rightCp2, points.right) .curve(points.rightCp1, points.bottomCp2, points.bottom) .curve(points.bottomCp1, points.leftCp2, points.left) .curve(points.leftCp1, points.topCp2, points.tipRightBottomEnd) - .curve( - points.tipRightBottomCp2, - points.tipRightBottomCp1, - points.tipRightBottomStart - ) - .curve( - points.tipRightTopCp2, - points.tipRightTopCp1, - points.tipRightTopStart - ) + .curve(points.tipRightBottomCp2, points.tipRightBottomCp1, points.tipRightBottomStart) + .curve(points.tipRightTopCp2, points.tipRightTopCp1, points.tipRightTopStart) .curve(points.edgeTopLeftCp, points.edgeLeftCp, points.edgeLeft) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') - delete paths.neck; - delete paths.rect; + delete paths.neck + delete paths.rect - return part; + return part } diff --git a/packages/utils/src/index.js b/packages/utils/src/index.js index 1264d342ec3..f8cdffa32c3 100644 --- a/packages/utils/src/index.js +++ b/packages/utils/src/index.js @@ -1,22 +1,22 @@ export default [ - "backend", - "camelCase", - "capitalize", - "cloneObject", - "defaultGist", - "defaultSa", - "formatImperial", - "formatMm", - "optionDefault", - "optionType", - "roundMm", - "roundMmDown", - "roundMmUp", - "sliderStep", - "smallestImperialStep", - "storage", - "tiler", - "measurementAsMm", - "validateEmail", - "validateTld" -]; + 'backend', + 'camelCase', + 'capitalize', + 'cloneObject', + 'defaultGist', + 'defaultSa', + 'formatImperial', + 'formatMm', + 'optionDefault', + 'optionType', + 'roundMm', + 'roundMmDown', + 'roundMmUp', + 'sliderStep', + 'smallestImperialStep', + 'storage', + 'tiler', + 'measurementAsMm', + 'validateEmail', + 'validateTld' +] diff --git a/packages/wahid/example/src/App.js b/packages/wahid/example/src/App.js index e7936330e5d..115cdf683af 100644 --- a/packages/wahid/example/src/App.js +++ b/packages/wahid/example/src/App.js @@ -1,22 +1,15 @@ -import React from "react"; -import freesewing from "@freesewing/core"; -import Workbench from "@freesewing/components/Workbench"; -import "typeface-roboto-condensed"; -import "@freesewing/css-theme"; +import React from 'react' +import freesewing from '@freesewing/core' +import Workbench from '@freesewing/components/Workbench' +import 'typeface-roboto-condensed' +import '@freesewing/css-theme' -import Pattern from "pattern"; +import Pattern from 'pattern' const App = props => { - let instance = new Pattern(); - let config = instance.config; - return ( - - ); -}; + let instance = new Pattern() + let config = instance.config + return +} -export default App; +export default App diff --git a/packages/wahid/example/src/index.js b/packages/wahid/example/src/index.js index 7900787a4d2..9dd7ba788d4 100644 --- a/packages/wahid/example/src/index.js +++ b/packages/wahid/example/src/index.js @@ -1,11 +1,11 @@ -import React from "react"; -import ReactDOM from "react-dom"; -import App from "./App"; -import * as serviceWorker from "./serviceWorker"; +import React from 'react' +import ReactDOM from 'react-dom' +import App from './App' +import * as serviceWorker from './serviceWorker' -ReactDOM.render(, document.getElementById("root")); +ReactDOM.render(, document.getElementById('root')) // If you want your app to work offline and load faster, you can change // unregister() to register() below. Note this comes with some pitfalls. // Learn more about service workers: http://bit.ly/CRA-PWA -serviceWorker.unregister(); +serviceWorker.unregister() diff --git a/packages/wahid/example/src/serviceWorker.js b/packages/wahid/example/src/serviceWorker.js index 68fda5a0eb6..44e1b1b2f8c 100644 --- a/packages/wahid/example/src/serviceWorker.js +++ b/packages/wahid/example/src/serviceWorker.js @@ -9,46 +9,44 @@ // This link also includes instructions on opting out of this behavior. const isLocalhost = Boolean( - window.location.hostname === "localhost" || + window.location.hostname === 'localhost' || // [::1] is the IPv6 localhost address. - window.location.hostname === "[::1]" || + window.location.hostname === '[::1]' || // 127.0.0.1/8 is considered localhost for IPv4. - window.location.hostname.match( - /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ - ) -); + window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/) +) export function register(config) { - if (process.env.NODE_ENV === "production" && "serviceWorker" in navigator) { + if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) { // The URL constructor is available in all browsers that support SW. - const publicUrl = new URL(process.env.PUBLIC_URL, window.location); + const publicUrl = new URL(process.env.PUBLIC_URL, window.location) if (publicUrl.origin !== window.location.origin) { // Our service worker won't work if PUBLIC_URL is on a different origin // from what our page is served on. This might happen if a CDN is used to // serve assets; see https://github.com/facebook/create-react-app/issues/2374 - return; + return } - window.addEventListener("load", () => { - const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; + window.addEventListener('load', () => { + const swUrl = `${process.env.PUBLIC_URL}/service-worker.js` if (isLocalhost) { // This is running on localhost. Let's check if a service worker still exists or not. - checkValidServiceWorker(swUrl, config); + checkValidServiceWorker(swUrl, config) // Add some additional logging to localhost, pointing developers to the // service worker/PWA documentation. navigator.serviceWorker.ready.then(() => { console.log( - "This web app is being served cache-first by a service " + - "worker. To learn more, visit https://goo.gl/SC7cgQ" - ); - }); + 'This web app is being served cache-first by a service ' + + 'worker. To learn more, visit https://goo.gl/SC7cgQ' + ) + }) } else { // Is not local host. Just register service worker - registerValidSW(swUrl, config); + registerValidSW(swUrl, config) } - }); + }) } } @@ -57,38 +55,38 @@ function registerValidSW(swUrl, config) { .register(swUrl) .then(registration => { registration.onupdatefound = () => { - const installingWorker = registration.installing; + const installingWorker = registration.installing installingWorker.onstatechange = () => { - if (installingWorker.state === "installed") { + if (installingWorker.state === 'installed') { if (navigator.serviceWorker.controller) { // At this point, the old content will have been purged and // the fresh content will have been added to the cache. // It's the perfect time to display a "New content is // available; please refresh." message in your web app. - console.log("New content is available; please refresh."); + console.log('New content is available; please refresh.') // Execute callback if (config.onUpdate) { - config.onUpdate(registration); + config.onUpdate(registration) } } else { // At this point, everything has been precached. // It's the perfect time to display a // "Content is cached for offline use." message. - console.log("Content is cached for offline use."); + console.log('Content is cached for offline use.') // Execute callback if (config.onSuccess) { - config.onSuccess(registration); + config.onSuccess(registration) } } } - }; - }; + } + } }) .catch(error => { - console.error("Error during service worker registration:", error); - }); + console.error('Error during service worker registration:', error) + }) } function checkValidServiceWorker(swUrl, config) { @@ -98,30 +96,28 @@ function checkValidServiceWorker(swUrl, config) { // Ensure service worker exists, and that we really are getting a JS file. if ( response.status === 404 || - response.headers.get("content-type").indexOf("javascript") === -1 + response.headers.get('content-type').indexOf('javascript') === -1 ) { // No service worker found. Probably a different app. Reload the page. navigator.serviceWorker.ready.then(registration => { registration.unregister().then(() => { - window.location.reload(); - }); - }); + window.location.reload() + }) + }) } else { // Service worker found. Proceed as normal. - registerValidSW(swUrl, config); + registerValidSW(swUrl, config) } }) .catch(() => { - console.log( - "No internet connection found. App is running in offline mode." - ); - }); + console.log('No internet connection found. App is running in offline mode.') + }) } export function unregister() { - if ("serviceWorker" in navigator) { + if ('serviceWorker' in navigator) { navigator.serviceWorker.ready.then(registration => { - registration.unregister(); - }); + registration.unregister() + }) } } diff --git a/packages/wahid/src/back.js b/packages/wahid/src/back.js index 6d041ef5ee6..eb83a1d3323 100644 --- a/packages/wahid/src/back.js +++ b/packages/wahid/src/back.js @@ -1,4 +1,4 @@ -import { constructMainDart, shapeSideSeam, dartPath } from "./shared"; +import { constructMainDart, shapeSideSeam, dartPath } from './shared' export default part => { let { @@ -13,82 +13,73 @@ export default part => { sa, paperless, snippets - } = part.shorthand(); + } = part.shorthand() // Cleanup from Brian - for (let i of Object.keys(paths)) delete paths[i]; - delete snippets.armholePitchNotch; + for (let i of Object.keys(paths)) delete paths[i] + delete snippets.armholePitchNotch // Back inset - let shoulderLen = points.shoulder.dist(points.neck); - let backInset = shoulderLen * options.backInset; - points.armholePitch = points.armholePitch.shift(180, backInset); - points.armholePitchCp1 = points.armholePitchCp1.shift(180, backInset); - points.armholePitchCp2 = points.armholePitchCp2.shift(180, backInset); - points.armholeHollow = points.armholeHollow.shift(180, backInset / 2); - points.armholeHollowCp2 = points.armholeHollowCp2.shift(180, backInset / 2); - points.armholeHollowCp1 = points.armholeHollowCp1.shift(180, backInset / 2); + let shoulderLen = points.shoulder.dist(points.neck) + let backInset = shoulderLen * options.backInset + points.armholePitch = points.armholePitch.shift(180, backInset) + points.armholePitchCp1 = points.armholePitchCp1.shift(180, backInset) + points.armholePitchCp2 = points.armholePitchCp2.shift(180, backInset) + points.armholeHollow = points.armholeHollow.shift(180, backInset / 2) + points.armholeHollowCp2 = points.armholeHollowCp2.shift(180, backInset / 2) + points.armholeHollowCp1 = points.armholeHollowCp1.shift(180, backInset / 2) // Shoulder inset - points.shoulder = points.shoulder.shiftTowards( - points.neck, - shoulderLen * options.shoulderInset - ); + points.shoulder = points.shoulder.shiftTowards(points.neck, shoulderLen * options.shoulderInset) points.shoulderCp1 = points.shoulderCp1.shift( points.shoulder.angle(points.neck), shoulderLen * options.shoulderInset - ); + ) paths.test = new Path() .move(points.shoulder) - .curve(points.shoulderCp1, points.armholePitchCp2, points.armholePitch); + .curve(points.shoulderCp1, points.armholePitchCp2, points.armholePitch) // Neck inset - points.neck = points.neck.shiftTowards( - points.shoulder, - shoulderLen * options.neckInset - ); - points.neckCp2 = points.neck.shift( - points.shoulder.angle(points.neck) + 90, - shoulderLen * 0.1 - ); + points.neck = points.neck.shiftTowards(points.shoulder, shoulderLen * options.neckInset) + points.neckCp2 = points.neck.shift(points.shoulder.angle(points.neck) + 90, shoulderLen * 0.1) // Center back dart points.cbNeck = new Path() .move(points.cbNeck) ._curve(points.neckCp2, points.neck) - .shiftAlong(measurements.shoulderToShoulder * options.centerBackDart); - points.cbNeckCp2 = new Point(0, points.armholePitch.y); + .shiftAlong(measurements.shoulderToShoulder * options.centerBackDart) + points.cbNeckCp2 = new Point(0, points.armholePitch.y) // Construct main dart - constructMainDart(part); + constructMainDart(part) // Add dart start and end point regardless of style or front or back - points.dartStart = points.dartHemLeft; - points.dartEnd = points.dartHemRight; + points.dartStart = points.dartHemLeft + points.dartEnd = points.dartHemRight // Shape side seam - shapeSideSeam(part); + shapeSideSeam(part) // Back scye dart points._dartWidth = points.cbNeckCp2.shiftFractionTowards( points.armholePitch.rotate(options.backScyeDart, points.cbNeckCp2), 1.2 - ); + ) points.armholePitchTop = new Path() .move(points.armholePitch) .curve(points.armholePitchCp2, points.shoulderCp1, points.shoulder) .intersects(new Path().move(points.cbNeckCp2).line(points._dartWidth)) - .pop(); + .pop() // Rotate back scye dart into center back - let toRotate = ["cbNeck", "neckCp2", "neck", "shoulder", "shoulderCp1"]; + let toRotate = ['cbNeck', 'neckCp2', 'neck', 'shoulder', 'shoulderCp1'] for (let p of toRotate) { - points[p] = points[p].rotate(options.backScyeDart, points.cbNeckCp2); + points[p] = points[p].rotate(options.backScyeDart, points.cbNeckCp2) } // Seam line - delete paths.cutonfold; - delete paths.saBase; - delete paths.sa; + delete paths.cutonfold + delete paths.saBase + delete paths.sa paths.saBase = new Path() .move(points.hem) .line(points.hips) @@ -100,124 +91,124 @@ export default part => { .line(points.neck) .curve_(points.neckCp2, points.cbNeck) ._curve(points.cbNeckCp2, points.cbArmhole) - .line(points.cbHem); - paths.hemBase = new Path().move(points.cbHem).line(points.hem); - paths.dart = dartPath(part); + .line(points.cbHem) + paths.hemBase = new Path().move(points.cbHem).line(points.hem) + paths.dart = dartPath(part) paths.seam = paths.saBase .clone() .line(points.dartHemLeft) .join(paths.dart) .line(points.hem) - .attr("class", "fabric"); - paths.saBase.render = false; - paths.hemBase.render = false; - paths.hemBase.render = false; - paths.dart.render = false; + .attr('class', 'fabric') + paths.saBase.render = false + paths.hemBase.render = false + paths.hemBase.render = false + paths.dart.render = false if (complete) { if (sa) { paths.sa = paths.saBase .offset(sa) .join(paths.hemBase.offset(sa * 3)) - .close(); + .close() } if (paperless) { - macro("ld", { + macro('ld', { from: points.neck, to: points.shoulder, d: 15 + sa - }); - macro("hd", { + }) + macro('hd', { from: points.cbArmhole, to: points.cbNeck, y: points.cbNeck.y - 15 - sa - }); - macro("hd", { + }) + macro('hd', { from: points.cbArmhole, to: points.neck, y: points.cbNeck.y - 30 - sa - }); - macro("hd", { + }) + macro('hd', { from: points.cbArmhole, to: points.shoulder, y: points.cbNeck.y - 45 - sa - }); - macro("hd", { + }) + macro('hd', { from: points.cbArmhole, to: points.armholePitch, y: points.armholePitch.y - }); - macro("hd", { + }) + macro('hd', { from: points.cbArmhole, to: points.dartTop, y: points.dartTop.y - 15 - }); - macro("vd", { + }) + macro('vd', { from: points.armhole, to: points.armholePitch, x: points.armhole.x + 15 + sa - }); - macro("vd", { + }) + macro('vd', { from: points.armhole, to: points.shoulder, x: points.armhole.x + 30 + sa - }); - macro("vd", { + }) + macro('vd', { from: points.armhole, to: points.neck, x: points.armhole.x + 45 + sa - }); - macro("vd", { + }) + macro('vd', { from: points.hem, to: points.waist, x: points.armhole.x + 15 + sa - }); - macro("vd", { + }) + macro('vd', { from: points.hem, to: points.armhole, x: points.armhole.x + 30 + sa - }); - macro("hd", { + }) + macro('hd', { from: points.dartHemRight, to: points.hem, y: points.hem.y + 3 * sa + 15 - }); - macro("hd", { + }) + macro('hd', { from: points.cbHem, to: points.dartHemLeft, y: points.hem.y + 3 * sa + 15 - }); - macro("hd", { + }) + macro('hd', { from: points.cbHem, to: points.hem, y: points.hem.y + 3 * sa + 30 - }); - macro("ld", { + }) + macro('ld', { from: points.dartWaistLeft, to: points.dartWaistRight - }); - macro("ld", { + }) + macro('ld', { from: points.dartHipLeft, to: points.dartHipRight - }); - macro("vd", { + }) + macro('vd', { from: points.cbHem, to: points.cbArmhole, x: points.cbHem.x - 15 - sa - }); - macro("vd", { + }) + macro('vd', { from: points.cbHem, to: points.cbNeck, x: points.cbHem.x - 30 - sa - }); - macro("vd", { + }) + macro('vd', { from: points.cbHem, to: points.neck, x: points.cbHem.x - 45 - sa - }); + }) } } - return part; -}; + return part +} diff --git a/packages/wahid/src/front.js b/packages/wahid/src/front.js index 494294e01af..eb9bba51015 100644 --- a/packages/wahid/src/front.js +++ b/packages/wahid/src/front.js @@ -1,4 +1,4 @@ -import { constructMainDart, shapeSideSeam, dartPath } from "./shared"; +import { constructMainDart, shapeSideSeam, dartPath } from './shared' export default part => { let { @@ -16,76 +16,58 @@ export default part => { sa, paperless, store - } = part.shorthand(); + } = part.shorthand() // Cleanup from Brian - for (let i of Object.keys(paths)) delete paths[i]; - delete snippets.armholePitchNotch; + for (let i of Object.keys(paths)) delete paths[i] + delete snippets.armholePitchNotch // Neck cutout points.closureTop = new Point( measurements.chestCircumference * options.frontOverlap * -1, points.waist.y * options.necklineDrop - ); - if (options.frontStyle === "classic") - points.closureTopCp1 = new Point( - points.neck.x, - (points.waist.y * options.necklineDrop) / 2 - ); + ) + if (options.frontStyle === 'classic') + points.closureTopCp1 = new Point(points.neck.x, (points.waist.y * options.necklineDrop) / 2) else { - points.closureTopCp1 = new Point(points.neck.x, points.closureTop.y); + points.closureTopCp1 = new Point(points.neck.x, points.closureTop.y) } // Front inset - let shoulderLen = points.shoulder.dist(points.neck); - let frontInset = shoulderLen * options.frontInset; - points.armholePitch = points.armholePitch.shift(180, frontInset); - points.armholePitchCp1 = points.armholePitchCp1.shift(180, frontInset); - points.armholePitchCp2 = points.armholePitchCp2.shift(180, frontInset); - points.armholeHollow = points.armholeHollow.shift(180, frontInset / 2); - points.armholeHollowCp2 = points.armholeHollowCp2.shift(180, frontInset / 2); - points.armholeHollowCp1 = points.armholeHollowCp1.shift(180, frontInset / 2); + let shoulderLen = points.shoulder.dist(points.neck) + let frontInset = shoulderLen * options.frontInset + points.armholePitch = points.armholePitch.shift(180, frontInset) + points.armholePitchCp1 = points.armholePitchCp1.shift(180, frontInset) + points.armholePitchCp2 = points.armholePitchCp2.shift(180, frontInset) + points.armholeHollow = points.armholeHollow.shift(180, frontInset / 2) + points.armholeHollowCp2 = points.armholeHollowCp2.shift(180, frontInset / 2) + points.armholeHollowCp1 = points.armholeHollowCp1.shift(180, frontInset / 2) // Shoulder inset - points.shoulder = points.shoulder.shiftTowards( - points.neck, - shoulderLen * options.shoulderInset - ); + points.shoulder = points.shoulder.shiftTowards(points.neck, shoulderLen * options.shoulderInset) points.shoulderCp1 = points.shoulderCp1.shift( points.shoulder.angle(points.neck), shoulderLen * options.shoulderInset - ); + ) // Neck inset - points.neck = points.neck.shiftTowards( - points.shoulder, - shoulderLen * options.neckInset - ); - points.neckCp2 = points.neck.shift( - points.shoulder.angle(points.neck) + 90, - shoulderLen * 0.2 - ); + points.neck = points.neck.shiftTowards(points.shoulder, shoulderLen * options.neckInset) + points.neckCp2 = points.neck.shift(points.shoulder.angle(points.neck) + 90, shoulderLen * 0.2) // Construct main dart - constructMainDart(part); + constructMainDart(part) // Shape side seam - shapeSideSeam(part); + shapeSideSeam(part) // Hem - if (options.hemStyle === "classic") { + if (options.hemStyle === 'classic') { // Construct cutaway - let cutaway = points.closureTop.dx(points.hem) / 4; - points.closureBottom = new Point( - points.closureTop.x, - points.hem.y - cutaway / 2 - ); - points.hemTip = new Point( - points.closureBottom.x + cutaway, - points.closureBottom.y + cutaway - ); + let cutaway = points.closureTop.dx(points.hem) / 4 + points.closureBottom = new Point(points.closureTop.x, points.hem.y - cutaway / 2) + points.hemTip = new Point(points.closureBottom.x + cutaway, points.closureBottom.y + cutaway) // Shifting hem point to have a continious hem curve to work from - let shift = points.dartHemLeft.dx(points.dartHemRight); - points.splitHem = points.hem.shift(180, shift); + let shift = points.dartHemLeft.dx(points.dartHemRight) + points.splitHem = points.hem.shift(180, shift) // Split hem curve on left side of dart points.hemSplit = utils.curveIntersectsX( points.hemTip, @@ -93,7 +75,7 @@ export default part => { points.dartHemLeft, points.splitHem, points.dartHemLeft.x - ); + ) // Split the hem curve let [c1, c2] = utils.splitCurve( points.hemTip, @@ -101,146 +83,123 @@ export default part => { points.dartHemLeft, points.splitHem, points.hemSplit - ); - points.splitDartHemLeftCp1 = c1.cp2; - points.splitDartHemRightCp2 = c2.cp1.shift(0, shift); - points.splitHemCp1 = c2.cp2.shift(0, shift); + ) + points.splitDartHemLeftCp1 = c1.cp2 + points.splitDartHemRightCp2 = c2.cp1.shift(0, shift) + points.splitHemCp1 = c2.cp2.shift(0, shift) points.splitDartHemLeft = utils.curveIntersectsX( points.hemTip, points.hemTip, points.dartHemLeft, points.splitHem, points.dartHemLeft.x - ); - points.splitDartHemRight = points.splitDartHemLeft.shift(0, shift); - points.lastButton = new Point(0, points.closureBottom.y); + ) + points.splitDartHemRight = points.splitDartHemLeft.shift(0, shift) + points.lastButton = new Point(0, points.closureBottom.y) } else { - points.closureBottom = new Point(points.closureTop.x, points.hem.y); + points.closureBottom = new Point(points.closureTop.x, points.hem.y) // Draw rounded hem - let radius = measurements.hipsCircumference * options.hemRadius; + let radius = measurements.hipsCircumference * options.hemRadius // Avoid radius extending beyond the dart if (radius > points.closureTop.dx(points.dartHemLeft)) - radius = points.closureTop.dx(points.dartHemLeft); - macro("round", { + radius = points.closureTop.dx(points.dartHemLeft) + macro('round', { from: points.closureTop, to: points.hem, via: points.closureBottom, radius, - prefix: "round" - }); - points.lastButton = new Point(0, points.roundStart.y); + prefix: 'round' + }) + points.lastButton = new Point(0, points.roundStart.y) } // Add dart start and end point regardless of style or front or back - points.dartStart = - options.hemStyle === "classic" - ? points.splitDartHemLeft - : points.dartHemLeft; - points.dartEnd = - options.hemStyle === "classic" - ? points.splitDartHemRight - : points.dartHemRight; + points.dartStart = options.hemStyle === 'classic' ? points.splitDartHemLeft : points.dartHemLeft + points.dartEnd = options.hemStyle === 'classic' ? points.splitDartHemRight : points.dartHemRight // Pockets - let pw = measurements.hipsCircumference * options.pocketWidth; // Pocket width - let pwh = pw * options.weltHeight; // Pocket welt height - let pwvh = pwh / Math.cos(utils.deg2rad(options.pocketAngle)); // Pocket welt vertical height + let pw = measurements.hipsCircumference * options.pocketWidth // Pocket width + let pwh = pw * options.weltHeight // Pocket welt height + let pwvh = pwh / Math.cos(utils.deg2rad(options.pocketAngle)) // Pocket welt vertical height points.pocketTopMid = points.dartWaistCenter.shiftFractionTowards( points.dartHipCenter, options.pocketLocation - ); + ) points.pocketTopMidLeft = utils.curveIntersectsY( points.dartWaistLeft, points.dartWaistLeftCpBottom, points.dartHipLeftCpTop, points.dartHipLeft, points.pocketTopMid.y - ); + ) points.pocketBottomMidLeft = utils.curveIntersectsY( points.dartWaistLeft, points.dartWaistLeftCpBottom, points.dartHipLeftCpTop, points.dartHipLeft, points.pocketTopMid.y + pwvh - ); - points.pocketTopLeft = points.pocketTopMidLeft.shift( - 180 + options.pocketAngle, - pw / 2 - ); - points.pocketBottomLeft = points.pocketTopLeft.shift( - options.pocketAngle - 90, - pwh - ); - points.pocketTopMidRight = points.pocketTopMidLeft.flipX(points.pocketTopMid); - points.pocketBottomMidRight = points.pocketBottomMidLeft.flipX( - points.pocketTopMid - ); - points.pocketTopRight = points.pocketTopMidRight.shift( - options.pocketAngle, - pw / 2 - ); - points.pocketBottomRight = points.pocketTopRight.shift( - options.pocketAngle - 90, - pwh - ); + ) + points.pocketTopLeft = points.pocketTopMidLeft.shift(180 + options.pocketAngle, pw / 2) + points.pocketBottomLeft = points.pocketTopLeft.shift(options.pocketAngle - 90, pwh) + points.pocketTopMidRight = points.pocketTopMidLeft.flipX(points.pocketTopMid) + points.pocketBottomMidRight = points.pocketBottomMidLeft.flipX(points.pocketTopMid) + points.pocketTopRight = points.pocketTopMidRight.shift(options.pocketAngle, pw / 2) + points.pocketBottomRight = points.pocketTopRight.shift(options.pocketAngle - 90, pwh) // Store pocket bag length - store.set("pocketBagLength", points.pocketTopMid.dy(points.cfHem) * 0.75); + store.set('pocketBagLength', points.pocketTopMid.dy(points.cfHem) * 0.75) // Front scye dart points._dartWidth = points.dartTop.shiftFractionTowards( points.armholeHollow.rotate(options.frontScyeDart, points.dartTop), 1.5 - ); + ) points.armholeHollowTop = new Path() .move(points.armholeHollow) .curve(points.armholeHollowCp2, points.armholePitchCp1, points.armholePitch) .intersects(new Path().move(points.dartTop).line(points._dartWidth)) - .pop(); + .pop() // Adjust control point points.armholeHollowCp2 = points.armholeHollowCp2.shift( points.armholeHollow.angle(points.armholeHollowTop), points.armholeHollow.dist(points.armholeHollowTop) - ); + ) // Rotate front scye dart into front dart let toRotate = [ - "dartWaistRightCpTop", - "dartWaistRight", - "dartWaistRightCpBottom", - "dartHipRightCpTop", - "dartHipRight", - "dartHemRight", - "splitDartHemRight", - "splitDartHemRightCp2", - "splitHemCp1", - "hem", - "hips", - "hipsCp2", - "waistCp1", - "waist", - "waistCp2", - "armhole", - "armholeCp2", - "armholeHollow", - "pocketTopMidRight", - "pocketBottomMidRight", - "pocketTopRight", - "pocketBottomRight", - "dartEnd" - ]; + 'dartWaistRightCpTop', + 'dartWaistRight', + 'dartWaistRightCpBottom', + 'dartHipRightCpTop', + 'dartHipRight', + 'dartHemRight', + 'splitDartHemRight', + 'splitDartHemRightCp2', + 'splitHemCp1', + 'hem', + 'hips', + 'hipsCp2', + 'waistCp1', + 'waist', + 'waistCp2', + 'armhole', + 'armholeCp2', + 'armholeHollow', + 'pocketTopMidRight', + 'pocketBottomMidRight', + 'pocketTopRight', + 'pocketBottomRight', + 'dartEnd' + ] for (let p of toRotate) { - if (typeof points[p] !== "undefined") - points[p] = points[p].rotate(options.frontScyeDart, points.dartTop); + if (typeof points[p] !== 'undefined') + points[p] = points[p].rotate(options.frontScyeDart, points.dartTop) } - points.armholeHollowCp1 = points.armholeHollowCp2.rotate( - 180, - points.armholeHollow - ); + points.armholeHollowCp1 = points.armholeHollowCp2.rotate(180, points.armholeHollow) // Seam line - delete paths.cutonfold; - delete paths.saBase; - delete paths.sa; + delete paths.cutonfold + delete paths.saBase + delete paths.sa paths.saBase = new Path() .move(points.hem) .line(points.hips) @@ -250,30 +209,30 @@ export default part => { .curve(points.armholeHollowCp2, points.armholePitchCp1, points.armholePitch) .curve(points.armholePitchCp2, points.shoulderCp1, points.shoulder) .line(points.neck) - .curve(points.neckCp2, points.closureTopCp1, points.closureTop); - if (options.hemStyle === "classic") { + .curve(points.neckCp2, points.closureTopCp1, points.closureTop) + if (options.hemStyle === 'classic') { paths.saBase .line(points.closureBottom) .line(points.hemTip) - ._curve(points.splitDartHemLeftCp1, points.splitDartHemLeft); + ._curve(points.splitDartHemLeftCp1, points.splitDartHemLeft) paths.hemBase = new Path() .move(points.dartEnd) - .curve(points.splitDartHemRightCp2, points.splitHemCp1, points.hem); + .curve(points.splitDartHemRightCp2, points.splitHemCp1, points.hem) } else { paths.saBase .line(points.roundStart) .curve(points.roundCp1, points.roundCp2, points.roundEnd) - .line(points.dartHemLeft); - paths.hemBase = new Path().move(points.dartEnd).line(points.hem); + .line(points.dartHemLeft) + paths.hemBase = new Path().move(points.dartEnd).line(points.hem) } - paths.dart = dartPath(part); + paths.dart = dartPath(part) paths.seam = paths.saBase .join(paths.dart) .join(paths.hemBase) - .attr("class", "fabric"); - paths.saBase.render = false; - paths.hemBase.render = false; - paths.dart.render = false; + .attr('class', 'fabric') + paths.saBase.render = false + paths.hemBase.render = false + paths.dart.render = false // Pocket path paths.pocket = new Path() @@ -285,239 +244,221 @@ export default part => { .line(points.pocketBottomRight) .line(points.pocketTopRight) .line(points.pocketTopMidRight) - .attr("class", "fabric dashed"); + .attr('class', 'fabric dashed') if (complete) { // Buttons - points.button1 = new Point(0, points.closureTop.y + 10); - let delta = points.button1.dist(points.lastButton) / (options.buttons - 1); + points.button1 = new Point(0, points.closureTop.y + 10) + let delta = points.button1.dist(points.lastButton) / (options.buttons - 1) for (let i = 1; i <= options.buttons; i++) { - points["button" + i] = points.button1.shift(-90, delta * (i - 1)); - snippets["button" + i] = new Snippet("button", points["button" + i]); - snippets["buttonhole" + i] = new Snippet( - "buttonhole", - points["button" + i] - ).attr("data-rotate", 90); + points['button' + i] = points.button1.shift(-90, delta * (i - 1)) + snippets['button' + i] = new Snippet('button', points['button' + i]) + snippets['buttonhole' + i] = new Snippet('buttonhole', points['button' + i]).attr( + 'data-rotate', + 90 + ) } // Facing/Lining boundary (flb) - points.flbTop = points.neck.shiftFractionTowards(points.shoulder, 0.5); - points.flbCp = points.dartTop.shift( - 90, - points.dartTop.dist(points.flbTop) / 2 - ); + points.flbTop = points.neck.shiftFractionTowards(points.shoulder, 0.5) + points.flbCp = points.dartTop.shift(90, points.dartTop.dist(points.flbTop) / 2) paths.flbFacing = new Path() .move(points.dartTop) .curve_(points.flbCp, points.flbTop) - .attr("class", "fabric"); - paths.flbLining = paths.flbFacing.clone().attr("class", "lining dashed"); + .attr('class', 'fabric') + paths.flbLining = paths.flbFacing.clone().attr('class', 'lining dashed') if (sa) { paths.sa = paths.saBase .offset(sa) .join(paths.hemBase.offset(sa * 3)) - .close(); + .close() } if (paperless) { - macro("hd", { + macro('hd', { from: points.closureTop, to: points.neck, y: points.neck.y - 15 - sa - }); - macro("hd", { + }) + macro('hd', { from: points.closureTop, to: points.shoulder, y: points.neck.y - 30 - sa - }); - macro("hd", { + }) + macro('hd', { from: points.closureTop, to: points.armhole, y: points.neck.y - 45 - sa - }); - macro("ld", { + }) + macro('ld', { from: points.neck, to: points.shoulder, d: 15 + sa - }); - macro("ld", { + }) + macro('ld', { from: points.neck, to: points.flbTop, d: -15 - }); - macro("vd", { + }) + macro('vd', { from: points.armhole, to: points.shoulder, x: points.armhole.x + 15 + sa - }); - macro("vd", { + }) + macro('vd', { from: points.armhole, to: points.neck, x: points.armhole.x + 30 + sa - }); - macro("vd", { + }) + macro('vd', { from: points.hem, to: points.armhole, - x: - (points.armhole.x > points.hem.x ? points.armhole.x : points.hem.x) + - 15 + - sa - }); - macro("vd", { - from: - options.hemStyle === "classic" - ? points.splitDartHemRight - : points.dartHemRight, + x: (points.armhole.x > points.hem.x ? points.armhole.x : points.hem.x) + 15 + sa + }) + macro('vd', { + from: options.hemStyle === 'classic' ? points.splitDartHemRight : points.dartHemRight, to: points.armhole, - x: - (points.armhole.x > points.hem.x ? points.armhole.x : points.hem.x) + - 30 + - sa - }); - macro("vd", { - from: - options.hemStyle === "classic" - ? points.splitDartHemLeft - : points.dartHemLeft, + x: (points.armhole.x > points.hem.x ? points.armhole.x : points.hem.x) + 30 + sa + }) + macro('vd', { + from: options.hemStyle === 'classic' ? points.splitDartHemLeft : points.dartHemLeft, to: points.armhole, - x: - (points.armhole.x > points.hem.x ? points.armhole.x : points.hem.x) + - 45 + - sa - }); - macro("ld", { + x: (points.armhole.x > points.hem.x ? points.armhole.x : points.hem.x) + 45 + sa + }) + macro('ld', { from: points.dartHemRight, to: points.hem, d: 15 - }); - if (options.hemStyle === "classic") { - macro("hd", { + }) + if (options.hemStyle === 'classic') { + macro('hd', { from: points.closureBottom, to: points.hemTip, y: points.hemTip.y + 15 + sa - }); - macro("hd", { + }) + macro('hd', { from: points.closureBottom, to: points.splitDartHemLeft, y: points.hemTip.y + 30 + sa - }); - macro("hd", { + }) + macro('hd', { from: points.closureBottom, to: points.splitDartHemRight, y: points.hemTip.y + 45 + sa - }); - macro("hd", { + }) + macro('hd', { from: points.closureBottom, to: points.hem, y: points.hemTip.y + 60 + sa - }); - macro("vd", { + }) + macro('vd', { from: points.hemTip, to: points.closureBottom, x: points.closureBottom.x - 15 - sa - }); - macro("vd", { + }) + macro('vd', { from: points.hemTip, to: points.pocketTopMidLeft, x: points.closureBottom.x - 30 - sa - }); - macro("vd", { + }) + macro('vd', { from: points.hemTip, to: points.dartWaistLeft, x: points.closureBottom.x - 45 - sa - }); - macro("vd", { + }) + macro('vd', { from: points.hemTip, to: points.closureTop, x: points.closureBottom.x - 60 - sa - }); + }) } else { - macro("hd", { + macro('hd', { from: points.roundStart, to: points.roundEnd, y: points.roundEnd.y + 15 + sa - }); - macro("hd", { + }) + macro('hd', { from: points.roundStart, to: points.dartHemLeft, y: points.roundEnd.y + 30 + sa - }); - macro("hd", { + }) + macro('hd', { from: points.roundStart, to: points.dartHemRight, y: points.roundEnd.y + 45 + sa - }); - macro("hd", { + }) + macro('hd', { from: points.roundStart, to: points.hem, y: points.roundEnd.y + 60 + sa - }); - macro("vd", { + }) + macro('vd', { from: points.roundEnd, to: points.roundStart, x: points.roundStart.x - 15 - sa - }); - macro("vd", { + }) + macro('vd', { from: points.roundEnd, to: points.pocketTopMidLeft, x: points.roundStart.x - 30 - sa - }); - macro("vd", { + }) + macro('vd', { from: points.roundEnd, to: points.dartWaistLeft, x: points.roundStart.x - 45 - sa - }); - macro("vd", { + }) + macro('vd', { from: points.roundEnd, to: points.closureTop, x: points.roundStart.x - 60 - sa - }); + }) } - macro("vd", { + macro('vd', { from: points.closureTop, to: points.neck, x: points.closureTop.x - 15 - sa - }); - macro("vd", { + }) + macro('vd', { from: points.button2, to: points.button1, x: points.button1.x + 15 - }); - macro("hd", { + }) + macro('hd', { from: points.closureTop, to: points.button2, y: points.button2.y + 15 - }); - macro("ld", { + }) + macro('ld', { from: points.dartWaistLeft, to: points.dartWaistRight - }); - macro("ld", { + }) + macro('ld', { from: points.dartHipLeft, to: points.dartHipRight - }); - macro("ld", { + }) + macro('ld', { from: points.pocketTopLeft, to: points.pocketTopMidLeft, d: 15 - }); - macro("ld", { + }) + macro('ld', { from: points.pocketTopMidRight, to: points.pocketTopRight, d: 15 - }); - macro("ld", { + }) + macro('ld', { from: points.pocketBottomRight, to: points.pocketTopRight, d: -15 - }); - macro("vd", { + }) + macro('vd', { from: points.pocketTopMidLeft, to: points.dartTop, x: points.closureTop.x - 30 - sa - }); + }) } } - return part; -}; + return part +} diff --git a/packages/wahid/src/frontfacing.js b/packages/wahid/src/frontfacing.js index 7fbfb2e107b..a4d5a22cfcd 100644 --- a/packages/wahid/src/frontfacing.js +++ b/packages/wahid/src/frontfacing.js @@ -10,53 +10,46 @@ export default part => { Snippet, complete, sa - } = part.shorthand(); + } = part.shorthand() // Cleanup from front part - for (let i of Object.keys(paths)) delete paths[i]; - for (let i of Object.keys(snippets)) delete snippets[i]; + for (let i of Object.keys(paths)) delete paths[i] + for (let i of Object.keys(snippets)) delete snippets[i] // Seam line paths.seam = new Path() .move(points.dartStart) .line(points.dartHipLeft) - .curve( - points.dartHipLeftCpTop, - points.dartWaistLeftCpBottom, - points.dartWaistLeft - ) + .curve(points.dartHipLeftCpTop, points.dartWaistLeftCpBottom, points.dartWaistLeft) .curve_(points.dartWaistLeftCpTop, points.dartTop) .curve_(points.flbCp, points.flbTop) .line(points.neck) - .curve(points.neckCp2, points.closureTopCp1, points.closureTop); - if (options.hemStyle === "classic") { + .curve(points.neckCp2, points.closureTopCp1, points.closureTop) + if (options.hemStyle === 'classic') { paths.seam .line(points.closureBottom) .line(points.hemTip) - ._curve(points.splitDartHemLeftCp1, points.splitDartHemLeft); + ._curve(points.splitDartHemLeftCp1, points.splitDartHemLeft) } else { paths.seam .line(points.roundStart) .curve(points.roundCp1, points.roundCp2, points.roundEnd) - .line(points.dartHemLeft); + .line(points.dartHemLeft) } - paths.seam.close().attr("class", "fabric"); + paths.seam.close().attr('class', 'fabric') if (complete) { - if (sa) paths.sa = paths.seam.offset(sa).attr("class", "fabric sa"); + if (sa) paths.sa = paths.seam.offset(sa).attr('class', 'fabric sa') - points.title = new Point(points.dartWaistLeft.x / 2, points.waist.y); - macro("title", { + points.title = new Point(points.dartWaistLeft.x / 2, points.waist.y) + macro('title', { nr: 3, at: points.title, - title: "frontFacing" - }); - points.logo = points.closureTop.shiftFractionTowards( - points.dartWaistLeft, - 0.5 - ); - snippets.logo = new Snippet("logo", points.logo); + title: 'frontFacing' + }) + points.logo = points.closureTop.shiftFractionTowards(points.dartWaistLeft, 0.5) + snippets.logo = new Snippet('logo', points.logo) } - return part; -}; + return part +} diff --git a/packages/wahid/src/frontlining.js b/packages/wahid/src/frontlining.js index db1774987cf..1d2d5cad12a 100644 --- a/packages/wahid/src/frontlining.js +++ b/packages/wahid/src/frontlining.js @@ -1,19 +1,9 @@ export default part => { - let { - points, - paths, - Path, - options, - macro, - snippets, - Snippet, - complete, - sa - } = part.shorthand(); + let { points, paths, Path, options, macro, snippets, Snippet, complete, sa } = part.shorthand() // Cleanup from Brian - for (let i of Object.keys(paths)) delete paths[i]; - for (let i of Object.keys(snippets)) delete snippets[i]; + for (let i of Object.keys(paths)) delete paths[i] + for (let i of Object.keys(snippets)) delete snippets[i] // Seam line paths.seam = new Path() @@ -27,31 +17,23 @@ export default part => { .line(points.flbTop) ._curve(points.flbCp, points.dartTop) ._curve(points.dartWaistRightCpTop, points.dartWaistRight) - .curve( - points.dartWaistRightCpBottom, - points.dartHipRightCpTop, - points.dartHipRight - ) - .line(points.dartEnd); - if (options.hemStyle === "classic") { - paths.seam.curve( - points.splitDartHemRightCp2, - points.splitHemCp1, - points.hem - ); - } else paths.seam.line(points.hem); + .curve(points.dartWaistRightCpBottom, points.dartHipRightCpTop, points.dartHipRight) + .line(points.dartEnd) + if (options.hemStyle === 'classic') { + paths.seam.curve(points.splitDartHemRightCp2, points.splitHemCp1, points.hem) + } else paths.seam.line(points.hem) if (complete) { - if (sa) paths.sa = paths.seam.offset(sa).attr("class", "fabric sa"); - points.title = points.armhole.shiftFractionTowards(points.dartTop, 0.5); - macro("title", { + if (sa) paths.sa = paths.seam.offset(sa).attr('class', 'fabric sa') + points.title = points.armhole.shiftFractionTowards(points.dartTop, 0.5) + macro('title', { nr: 4, at: points.title, - title: "frontLining" - }); - points.logo = points.dartWaistRight.shiftFractionTowards(points.waist, 0.5); - snippets.logo = new Snippet("logo", points.logo); + title: 'frontLining' + }) + points.logo = points.dartWaistRight.shiftFractionTowards(points.waist, 0.5) + snippets.logo = new Snippet('logo', points.logo) } - return part; -}; + return part +} diff --git a/packages/wahid/src/index.js b/packages/wahid/src/index.js index 55f14a1c257..65f9eca458a 100644 --- a/packages/wahid/src/index.js +++ b/packages/wahid/src/index.js @@ -1,41 +1,41 @@ -import freesewing from "@freesewing/core"; -import Brian from "@freesewing/brian"; -import plugins from "@freesewing/plugin-bundle"; -import round from "@freesewing/plugin-round"; -import buttons from "@freesewing/plugin-buttons"; -import config from "../config"; +import freesewing from '@freesewing/core' +import Brian from '@freesewing/brian' +import plugins from '@freesewing/plugin-bundle' +import round from '@freesewing/plugin-round' +import buttons from '@freesewing/plugin-buttons' +import config from '../config' // Parts -import draftFront from "./front"; -import draftBack from "./back"; -import draftFrontFacing from "./frontfacing"; -import draftFrontLining from "./frontlining"; -import draftPocketWelt from "./pocketwelt"; -import draftPocketBag from "./pocketbag"; -import draftPocketFacing from "./pocketfacing"; -import draftPocketInterfacing from "./pocketinterfacing"; +import draftFront from './front' +import draftBack from './back' +import draftFrontFacing from './frontfacing' +import draftFrontLining from './frontlining' +import draftPocketWelt from './pocketwelt' +import draftPocketBag from './pocketbag' +import draftPocketFacing from './pocketfacing' +import draftPocketInterfacing from './pocketinterfacing' // Create pattern -const Pattern = new freesewing.Design(config, [plugins, round, buttons]); +const Pattern = new freesewing.Design(config, [plugins, round, buttons]) // Parts we're getting from Brian Pattern.prototype.draftBase = function(part) { - return new Brian(this.settings).draftBase(part); -}; + return new Brian(this.settings).draftBase(part) +} Pattern.prototype.draftBackBlock = function(part) { - return new Brian(this.settings).draftBack(part); -}; + return new Brian(this.settings).draftBack(part) +} Pattern.prototype.draftFrontBlock = function(part) { - return new Brian(this.settings).draftFront(part); -}; + return new Brian(this.settings).draftFront(part) +} // Attach draft methods to prototype -Pattern.prototype.draftFront = part => draftFront(part); -Pattern.prototype.draftBack = part => draftBack(part); -Pattern.prototype.draftFrontFacing = part => draftFrontFacing(part); -Pattern.prototype.draftFrontLining = part => draftFrontLining(part); -Pattern.prototype.draftPocketWelt = part => draftPocketWelt(part); -Pattern.prototype.draftPocketBag = part => draftPocketBag(part); -Pattern.prototype.draftPocketFacing = part => draftPocketFacing(part); -Pattern.prototype.draftPocketInterfacing = part => draftPocketInterfacing(part); +Pattern.prototype.draftFront = part => draftFront(part) +Pattern.prototype.draftBack = part => draftBack(part) +Pattern.prototype.draftFrontFacing = part => draftFrontFacing(part) +Pattern.prototype.draftFrontLining = part => draftFrontLining(part) +Pattern.prototype.draftPocketWelt = part => draftPocketWelt(part) +Pattern.prototype.draftPocketBag = part => draftPocketBag(part) +Pattern.prototype.draftPocketFacing = part => draftPocketFacing(part) +Pattern.prototype.draftPocketInterfacing = part => draftPocketInterfacing(part) -export default Pattern; +export default Pattern diff --git a/packages/wahid/src/pocketbag.js b/packages/wahid/src/pocketbag.js index 3145119953e..d921367323e 100644 --- a/packages/wahid/src/pocketbag.js +++ b/packages/wahid/src/pocketbag.js @@ -10,31 +10,31 @@ export default part => { complete, paperless, store - } = part.shorthand(); + } = part.shorthand() - let pw = measurements.hipsCircumference * options.pocketWidth; // Pocket width - let ph = store.get("pocketBagLength"); // Pocket height + let pw = measurements.hipsCircumference * options.pocketWidth // Pocket width + let ph = store.get('pocketBagLength') // Pocket height - points.topLeft = new Point(0, 0); - points.topRight = new Point(pw + 30, 0); - points.bottomLeft = new Point(0, ph + 10); - points.bottomRight = new Point(points.topRight.x, points.bottomLeft.y); - macro("round", { + points.topLeft = new Point(0, 0) + points.topRight = new Point(pw + 30, 0) + points.bottomLeft = new Point(0, ph + 10) + points.bottomRight = new Point(points.topRight.x, points.bottomLeft.y) + macro('round', { from: points.topLeft, to: points.bottomRight, via: points.bottomLeft, radius: pw / 8, render: true, - prefix: "roundLeft" - }); - macro("round", { + prefix: 'roundLeft' + }) + macro('round', { from: points.bottomLeft, to: points.topRight, via: points.bottomRight, radius: pw / 8, render: true, - prefix: "roundRight" - }); + prefix: 'roundRight' + }) paths.seam = new Path() .move(points.topLeft) @@ -45,29 +45,29 @@ export default part => { .line(points.topRight) .line(points.topLeft) .close() - .attr("class", "lining"); + .attr('class', 'lining') if (complete) { - points.title = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5); - macro("title", { + points.title = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5) + macro('title', { nr: 7, - title: "pocketBag", + title: 'pocketBag', at: points.title - }); + }) } if (paperless) { - macro("hd", { + macro('hd', { from: points.bottomLeft, to: points.bottomRight, y: points.bottomLeft.y + 15 - }); - macro("vd", { + }) + macro('vd', { from: points.bottomRight, to: points.topRight, x: points.topRight.x + 15 - }); + }) } - return part; -}; + return part +} diff --git a/packages/wahid/src/pocketfacing.js b/packages/wahid/src/pocketfacing.js index 3c28ea2703b..16221a25266 100644 --- a/packages/wahid/src/pocketfacing.js +++ b/packages/wahid/src/pocketfacing.js @@ -10,34 +10,34 @@ export default part => { complete, paperless, store - } = part.shorthand(); + } = part.shorthand() - let pw = measurements.hipsCircumference * options.pocketWidth; // Pocket width - let pwh = pw * options.weltHeight; // Pocket welt height - let ph = store.get("pocketBagLength") + pwh; // Pocket height + let pw = measurements.hipsCircumference * options.pocketWidth // Pocket width + let pwh = pw * options.weltHeight // Pocket welt height + let ph = store.get('pocketBagLength') + pwh // Pocket height - points.topLeft = new Point(0, 0); - points.topRight = new Point(pw + 30, 0); - points.bottomLeft = new Point(0, ph + 10); - points.bottomRight = new Point(points.topRight.x, points.bottomLeft.y); - points.notchLeft = new Point(15, 10); - points.notchRight = new Point(pw + 15, 10); - macro("round", { + points.topLeft = new Point(0, 0) + points.topRight = new Point(pw + 30, 0) + points.bottomLeft = new Point(0, ph + 10) + points.bottomRight = new Point(points.topRight.x, points.bottomLeft.y) + points.notchLeft = new Point(15, 10) + points.notchRight = new Point(pw + 15, 10) + macro('round', { from: points.topLeft, to: points.bottomRight, via: points.bottomLeft, radius: pw / 8, render: true, - prefix: "roundLeft" - }); - macro("round", { + prefix: 'roundLeft' + }) + macro('round', { from: points.bottomLeft, to: points.topRight, via: points.bottomRight, radius: pw / 8, render: true, - prefix: "roundRight" - }); + prefix: 'roundRight' + }) paths.seam = new Path() .move(points.topLeft) @@ -48,37 +48,37 @@ export default part => { .line(points.topRight) .line(points.topLeft) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') if (complete) { - points.title = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5); - macro("title", { + points.title = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5) + macro('title', { nr: 6, - title: "pocketFacing", + title: 'pocketFacing', at: points.title - }); - macro("sprinkle", { - snippet: "notch", - on: ["notchLeft", "notchRight"] - }); + }) + macro('sprinkle', { + snippet: 'notch', + on: ['notchLeft', 'notchRight'] + }) paths.cutline = new Path() .move(points.notchLeft) .line(points.notchRight) - .attr("class", "fabric stroke-sm dashed"); + .attr('class', 'fabric stroke-sm dashed') } if (paperless) { - macro("hd", { + macro('hd', { from: points.bottomLeft, to: points.bottomRight, y: points.bottomLeft.y + 15 - }); - macro("vd", { + }) + macro('vd', { from: points.bottomRight, to: points.topRight, x: points.topRight.x + 15 - }); + }) } - return part; -}; + return part +} diff --git a/packages/wahid/src/pocketinterfacing.js b/packages/wahid/src/pocketinterfacing.js index 7a1a8838223..63d19a1a3a0 100644 --- a/packages/wahid/src/pocketinterfacing.js +++ b/packages/wahid/src/pocketinterfacing.js @@ -9,17 +9,17 @@ export default part => { macro, complete, paperless - } = part.shorthand(); + } = part.shorthand() - let pw = measurements.hipsCircumference * options.pocketWidth; // Pocket width - let pwh = pw * options.weltHeight; // Pocket welt height + let pw = measurements.hipsCircumference * options.pocketWidth // Pocket width + let pwh = pw * options.weltHeight // Pocket welt height - points.topLeft = new Point(0, 0); - points.topRight = new Point(pw + 30, 0); - points.bottomLeft = new Point(0, pwh + 20); - points.bottomRight = new Point(points.topRight.x, points.bottomLeft.y); - points.notchLeft = new Point(15, 10); - points.notchRight = new Point(pw + 15, 10); + points.topLeft = new Point(0, 0) + points.topRight = new Point(pw + 30, 0) + points.bottomLeft = new Point(0, pwh + 20) + points.bottomRight = new Point(points.topRight.x, points.bottomLeft.y) + points.notchLeft = new Point(15, 10) + points.notchRight = new Point(pw + 15, 10) paths.seam = new Path() .move(points.topLeft) @@ -28,37 +28,37 @@ export default part => { .line(points.topRight) .line(points.topLeft) .close() - .attr("class", "interfacing"); + .attr('class', 'interfacing') if (complete) { - points.title = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5); - macro("title", { + points.title = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5) + macro('title', { nr: 8, - title: "pocketInterfacing", + title: 'pocketInterfacing', at: points.title - }); - macro("sprinkle", { - snippet: "notch", - on: ["notchLeft", "notchRight"] - }); + }) + macro('sprinkle', { + snippet: 'notch', + on: ['notchLeft', 'notchRight'] + }) paths.cutline = new Path() .move(points.notchLeft) .line(points.notchRight) - .attr("class", "interfacing stroke-sm dashed"); + .attr('class', 'interfacing stroke-sm dashed') } if (paperless) { - macro("hd", { + macro('hd', { from: points.bottomLeft, to: points.bottomRight, y: points.bottomLeft.y + 15 - }); - macro("vd", { + }) + macro('vd', { from: points.bottomRight, to: points.topRight, x: points.topRight.x + 15 - }); + }) } - return part; -}; + return part +} diff --git a/packages/wahid/src/pocketwelt.js b/packages/wahid/src/pocketwelt.js index c1397bb4da9..1f6dab034d2 100644 --- a/packages/wahid/src/pocketwelt.js +++ b/packages/wahid/src/pocketwelt.js @@ -9,19 +9,19 @@ export default part => { macro, complete, paperless - } = part.shorthand(); + } = part.shorthand() - let pw = measurements.hipsCircumference * options.pocketWidth; // Pocket width - let pwh = pw * options.weltHeight; // Pocket welt height + let pw = measurements.hipsCircumference * options.pocketWidth // Pocket width + let pwh = pw * options.weltHeight // Pocket welt height - points.topLeft = new Point(0, 0); - points.topRight = new Point(pw + 30, 0); - points.bottomLeft = new Point(0, pwh * 2 + 20); - points.bottomRight = new Point(points.topRight.x, points.bottomLeft.y); - points.notchLeft = new Point(15, 10); - points.notchRight = new Point(pw + 15, 10); - points.midLeft = new Point(0, pwh + 10); - points.midRight = new Point(pw + 30, pwh + 10); + points.topLeft = new Point(0, 0) + points.topRight = new Point(pw + 30, 0) + points.bottomLeft = new Point(0, pwh * 2 + 20) + points.bottomRight = new Point(points.topRight.x, points.bottomLeft.y) + points.notchLeft = new Point(15, 10) + points.notchRight = new Point(pw + 15, 10) + points.midLeft = new Point(0, pwh + 10) + points.midRight = new Point(pw + 30, pwh + 10) paths.seam = new Path() .move(points.topLeft) @@ -30,56 +30,56 @@ export default part => { .line(points.topRight) .line(points.topLeft) .close() - .attr("class", "fabric"); + .attr('class', 'fabric') if (complete) { - points.title = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5); - macro("title", { + points.title = points.topLeft.shiftFractionTowards(points.bottomRight, 0.5) + macro('title', { nr: 5, - title: "pocketWelt", + title: 'pocketWelt', at: points.title - }); - macro("sprinkle", { - snippet: "notch", - on: ["notchLeft", "notchRight"] - }); + }) + macro('sprinkle', { + snippet: 'notch', + on: ['notchLeft', 'notchRight'] + }) paths.cutline = new Path() .move(points.notchLeft) .line(points.notchRight) - .attr("class", "fabric stroke-sm dashed"); + .attr('class', 'fabric stroke-sm dashed') paths.foldline = new Path() .move(points.midLeft) .line(points.midRight) - .attr("class", "hint dotted"); + .attr('class', 'hint dotted') } if (paperless) { - macro("hd", { + macro('hd', { from: points.notchLeft, to: points.notchRight, y: points.bottomLeft.y + 15 - }); - macro("hd", { + }) + macro('hd', { from: points.bottomLeft, to: points.bottomRight, y: points.bottomLeft.y + 30 - }); - macro("vd", { + }) + macro('vd', { from: points.midRight, to: points.notchRight, x: points.midRight.x + 15 - }); - macro("vd", { + }) + macro('vd', { from: points.midRight, to: points.topRight, x: points.midRight.x + 30 - }); - macro("vd", { + }) + macro('vd', { from: points.bottomRight, to: points.topRight, x: points.midRight.x + 45 - }); + }) } - return part; -}; + return part +} diff --git a/packages/wahid/src/shared.js b/packages/wahid/src/shared.js index 40bf0511850..a22fe8f44d9 100644 --- a/packages/wahid/src/shared.js +++ b/packages/wahid/src/shared.js @@ -1,88 +1,68 @@ export const constructMainDart = part => { - let { measurements, options, points, Point, store } = part.shorthand(); + let { measurements, options, points, Point, store } = part.shorthand() - let reduce = {}; - let chest = measurements.chestCircumference * (1 + options.chestEase); - let waist = measurements.naturalWaist * (1 + options.waistEase); - let hips = measurements.hipsCircumference * (1 + options.hipsEase); + let reduce = {} + let chest = measurements.chestCircumference * (1 + options.chestEase) + let waist = measurements.naturalWaist * (1 + options.waistEase) + let hips = measurements.hipsCircumference * (1 + options.hipsEase) - reduce.waist = chest - waist; - reduce.hips = chest - hips; - if (reduce.hips < 0) reduce.hips = 0; - if (reduce.waist < 0) reduce.waist = 0; + reduce.waist = chest - waist + reduce.hips = chest - hips + if (reduce.hips < 0) reduce.hips = 0 + if (reduce.waist < 0) reduce.waist = 0 - let wr12 = reduce.waist / 12; - let hr12 = reduce.hips / 12; - store.set("wr12", wr12); - store.set("hr12", hr12); + let wr12 = reduce.waist / 12 + let hr12 = reduce.hips / 12 + store.set('wr12', wr12) + store.set('hr12', hr12) - points.dartWaistCenter = new Point(points.armhole.x / 2, points.waist.y); - points.dartWaistRight = points.dartWaistCenter.shift(0, wr12); - points.dartWaistLeft = points.dartWaistCenter.shift(180, wr12); - points.dartTop = points.dartWaistCenter.shift( - 90, - points.neck.dy(points.waist) * 0.35 - ); + points.dartWaistCenter = new Point(points.armhole.x / 2, points.waist.y) + points.dartWaistRight = points.dartWaistCenter.shift(0, wr12) + points.dartWaistLeft = points.dartWaistCenter.shift(180, wr12) + points.dartTop = points.dartWaistCenter.shift(90, points.neck.dy(points.waist) * 0.35) points.dartWaistRightCpTop = points.dartWaistRight.shift( 90, points.dartTop.dy(points.waist) * 0.35 - ); - points.dartWaistLeftCpTop = points.dartWaistLeft.shift( - 90, - points.dartTop.dy(points.waist) * 0.35 - ); - points.dartHipCenter = new Point(points.dartWaistCenter.x, points.hips.y); - points.dartHipRight = points.dartHipCenter.shift(0, hr12); - points.dartHipLeft = points.dartHipCenter.shift(180, hr12); - points.dartHemRight = new Point(points.dartHipRight.x, points.hem.y); - points.dartHemLeft = new Point(points.dartHipLeft.x, points.hem.y); - points.dartHipRightCpTop = points.dartHipRight.shift( - 90, - points.waist.dy(points.hips) * 0.25 - ); - points.dartHipLeftCpTop = points.dartHipLeft.shift( - 90, - points.waist.dy(points.hips) * 0.25 - ); + ) + points.dartWaistLeftCpTop = points.dartWaistLeft.shift(90, points.dartTop.dy(points.waist) * 0.35) + points.dartHipCenter = new Point(points.dartWaistCenter.x, points.hips.y) + points.dartHipRight = points.dartHipCenter.shift(0, hr12) + points.dartHipLeft = points.dartHipCenter.shift(180, hr12) + points.dartHemRight = new Point(points.dartHipRight.x, points.hem.y) + points.dartHemLeft = new Point(points.dartHipLeft.x, points.hem.y) + points.dartHipRightCpTop = points.dartHipRight.shift(90, points.waist.dy(points.hips) * 0.25) + points.dartHipLeftCpTop = points.dartHipLeft.shift(90, points.waist.dy(points.hips) * 0.25) points.dartWaistRightCpBottom = points.dartWaistRight.shift( -90, points.waist.dy(points.hips) * 0.25 - ); + ) points.dartWaistLeftCpBottom = points.dartWaistLeft.shift( -90, points.waist.dy(points.hips) * 0.25 - ); -}; + ) +} export const shapeSideSeam = part => { - let { points, Point, store } = part.shorthand(); - let wr12 = store.get("wr12"); - let hr12 = store.get("hr12"); + let { points, Point, store } = part.shorthand() + let wr12 = store.get('wr12') + let hr12 = store.get('hr12') - points.waist = points.waist.shift(180, wr12); - points.waistCp2 = new Point(points.waist.x, points.dartWaistRightCpTop.y); - points.waistCp1 = new Point(points.waist.x, points.dartWaistRightCpBottom.y); - points.hips = points.hips.shift(180, hr12); - points.hipsCp2 = new Point(points.hips.x, points.dartHipRightCpTop.y); - points.hem = points.hem.shift(180, hr12); -}; + points.waist = points.waist.shift(180, wr12) + points.waistCp2 = new Point(points.waist.x, points.dartWaistRightCpTop.y) + points.waistCp1 = new Point(points.waist.x, points.dartWaistRightCpBottom.y) + points.hips = points.hips.shift(180, hr12) + points.hipsCp2 = new Point(points.hips.x, points.dartHipRightCpTop.y) + points.hem = points.hem.shift(180, hr12) +} export const dartPath = part => { - let { Path, points } = part.shorthand(); + let { Path, points } = part.shorthand() return new Path() .move(points.dartStart) .line(points.dartHipLeft) - .curve( - points.dartHipLeftCpTop, - points.dartWaistLeftCpBottom, - points.dartWaistLeft - ) + .curve(points.dartHipLeftCpTop, points.dartWaistLeftCpBottom, points.dartWaistLeft) .curve_(points.dartWaistLeftCpTop, points.dartTop) ._curve(points.dartWaistRightCpTop, points.dartWaistRight) - .curve( - points.dartWaistRightCpBottom, - points.dartHipRightCpTop, - points.dartHipRight - ) - .line(points.dartEnd); -}; + .curve(points.dartWaistRightCpBottom, points.dartHipRightCpTop, points.dartHipRight) + .line(points.dartEnd) +}