1
0
Fork 0

construction: Moved to JS with babel transpiler

This commit is contained in:
Joost De Cock 2018-07-15 17:13:52 +02:00
parent b8eb8d5ab8
commit 945d3fd34c
13 changed files with 153 additions and 205 deletions

View file

@ -1,45 +1,44 @@
/** Pattern parts */ /** Pattern parts */
export const parts = [ module.exports = {
"backBlock", parts: [
"frontBlock", "backBlock",
"_sleeveBlock" "frontBlock",
]; "_sleeveBlock"
],
measurements: [
"bicepsCircumference",
"centerBackNeckToWaist",
"chestCircumference",
"naturalWaistToHip",
"neckCircumference",
"shoulderSlope",
"shoulderToShoulder",
"hipsCircumference",
"shoulderToWrist",
"wristCircumference"
],
options: [
// Constants
{ "id": "backNeckCutout", "val": 20, "type": "constant"},
{ "id": "bicepsEase", "val": 50, "type": "constant"},
{ "id": "collarEase", "val": 15, "type": "constant"},
{ "id": "frontArmholeExtra", "val": 5, "type": "constant"},
{ "id": "shoulderSlopeReduction", "val": 0, "type": "constant"},
{ "id": "sleevecapEase", "val": 5, "type": "constant"},
{ "id": "collarFactor", "val":4.8, "type": "constant"},
/** Requires measurements */ // Measures
export const measurements = [ { "id": "bicepsEase", "val": 50, "min": 30, "max": 80 },
"bicepsCircumference", { "id": "chestEase", "val": 30, "min": -40, "max": 160 },
"centerBackNeckToWaist", { "id": "shoulderEase", "val": 0, "min": -20, "max": 60 },
"chestCircumference", { "id": "cuffEase", "val": 45, "min": 0, "max": 100 },
"naturalWaistToHip", { "id": "lengthBonus", "val": 0, "min": -40, "max": 120 },
"neckCircumference", { "id": "sleeveLengthBonus", "val": 0, "min": -40, "max": 80 },
"shoulderSlope",
"shoulderToShoulder",
"hipsCircumference",
"shoulderToWrist",
"wristCircumference"
];
export const options = [ // Percentages
{ "id": "acrossBackFactor", "val": 96, "type": "percentage", "min": 93, "max": 99 },
{ "id": "armholeDepthFactor", "val": 50, "type": "percentage", "min": 50, "max": 65 },
{ "id": "sleevecapHeightFactor", "val": 55, "type": "percentage", "min": 35, "max": 75 }
]
};
// Constants
{ "id": "backNeckCutout", "val": 20, "type": "constant"},
{ "id": "bicepsEase", "val": 50, "type": "constant"},
{ "id": "collarEase", "val": 15, "type": "constant"},
{ "id": "frontArmholeExtra", "val": 5, "type": "constant"},
{ "id": "shoulderSlopeReduction", "val": 0, "type": "constant"},
{ "id": "sleevecapEase", "val": 5, "type": "constant"},
{ "id": "collarFactor", "val":4.8, "type": "constant"},
// Measures
{ "id": "bicepsEase", "val": 50, "min": 30, "max": 80 },
{ "id": "chestEase", "val": 30, "min": -40, "max": 160 },
{ "id": "shoulderEase", "val": 0, "min": -20, "max": 60 },
{ "id": "cuffEase", "val": 45, "min": 0, "max": 100 },
{ "id": "lengthBonus", "val": 0, "min": -40, "max": 120 },
{ "id": "sleeveLengthBonus", "val": 0, "min": -40, "max": 80 },
// Percentages
{ "id": "acrossBackFactor", "val": 96, "type": "percentage", "min": 93, "max": 99 },
{ "id": "armholeDepthFactor", "val": 50, "type": "percentage", "min": 50, "max": 65 },
{ "id": "sleevecapHeightFactor", "val": 55, "type": "percentage", "min": 35, "max": 75 }
];

View file

@ -1,23 +0,0 @@
/** Pattern parts */
export declare const parts: string[];
/** Requires measurements */
export declare const measurements: string[];
export declare const options: ({
"id": string;
"val": number;
"type": string;
"min"?: undefined;
"max"?: undefined;
} | {
"id": string;
"val": number;
"min": number;
"max": number;
"type"?: undefined;
} | {
"id": string;
"val": number;
"type": string;
"min": number;
"max": number;
})[];

View file

@ -1,42 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/** Pattern parts */
exports.parts = [
"backBlock",
"frontBlock",
"_sleeveBlock"
];
/** Requires measurements */
exports.measurements = [
"bicepsCircumference",
"centerBackNeckToWaist",
"chestCircumference",
"naturalWaistToHip",
"neckCircumference",
"shoulderSlope",
"shoulderToShoulder",
"hipsCircumference",
"shoulderToWrist",
"wristCircumference"
];
exports.options = [
// Constants
{ "id": "backNeckCutout", "val": 20, "type": "constant" },
{ "id": "bicepsEase", "val": 50, "type": "constant" },
{ "id": "collarEase", "val": 15, "type": "constant" },
{ "id": "frontArmholeExtra", "val": 5, "type": "constant" },
{ "id": "shoulderSlopeReduction", "val": 0, "type": "constant" },
{ "id": "sleevecapEase", "val": 5, "type": "constant" },
{ "id": "collarFactor", "val": 4.8, "type": "constant" },
// Measures
{ "id": "bicepsEase", "val": 50, "min": 30, "max": 80 },
{ "id": "chestEase", "val": 30, "min": -40, "max": 160 },
{ "id": "shoulderEase", "val": 0, "min": -20, "max": 60 },
{ "id": "cuffEase", "val": 45, "min": 0, "max": 100 },
{ "id": "lengthBonus", "val": 0, "min": -40, "max": 120 },
{ "id": "sleeveLengthBonus", "val": 0, "min": -40, "max": 80 },
// Percentages
{ "id": "acrossBackFactor", "val": 96, "type": "percentage", "min": 93, "max": 99 },
{ "id": "armholeDepthFactor", "val": 50, "type": "percentage", "min": 50, "max": 65 },
{ "id": "sleevecapHeightFactor", "val": 55, "type": "percentage", "min": 35, "max": 75 }
];

View file

@ -1,3 +0,0 @@
import { Pattern } from 'freesewing/dist/lib/pattern';
declare var brian: Pattern;
export default brian;

View file

@ -1,28 +1,45 @@
"use strict"; 'use strict';
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod }; Object.defineProperty(exports, "__esModule", {
}; value: true
var __importStar = (this && this.__importStar) || function (mod) { });
if (mod && mod.__esModule) return mod;
var result = {}; var _freesewing = require('freesewing');
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod; var _freesewing2 = _interopRequireDefault(_freesewing);
return result;
}; var _config = require('../config/config');
Object.defineProperty(exports, "__esModule", { value: true });
var freesewing_1 = __importDefault(require("freesewing")); var patternConfig = _interopRequireWildcard(_config);
var patternConfig = __importStar(require("./config/config"));
var back_1 = __importDefault(require("./lib/back")); var _pattern = require('freesewing/dist/lib/pattern');
var models_1 = require("@freesewing/models");
var brian = new freesewing_1.default.pattern(patternConfig); var _back = require('./lib/back');
brian.draft = function (final) {
if (final === void 0) { final = true; } var _back2 = _interopRequireDefault(_back);
back_1.default.draft(brian, final);
return brian; var _models = require('@freesewing/models');
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var brian = new _freesewing2.default.pattern(patternConfig);
brian.draft = function () {
var final = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
_back2.default.draft(brian, final);
return brian;
}; };
exports.default = brian; exports.default = brian;
// This is not for inclusion in production // This is not for inclusion in production
console.log(models_1.manSize38);
brian.settings.measurements = models_1.manSize38; console.log(_models.manSize38);
brian.settings.measurements = _models.manSize38;
brian.draft(); brian.draft();
console.log(brian.parts.backBlock.points); console.log(brian.parts.backBlock.points);

View file

@ -1,5 +0,0 @@
import { Pattern } from 'freesewing/dist/lib/pattern';
declare var backBlock: {
draft: (pattern: Pattern, final?: boolean) => void;
};
export default backBlock;

View file

@ -1,44 +1,56 @@
"use strict"; 'use strict';
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod }; Object.defineProperty(exports, "__esModule", {
}; value: true
Object.defineProperty(exports, "__esModule", { value: true }); });
var freesewing_1 = __importDefault(require("freesewing"));
var _freesewing = require('freesewing');
var _freesewing2 = _interopRequireDefault(_freesewing);
var _pattern = require('freesewing/dist/lib/pattern');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var backBlock = { var backBlock = {
draft: function (pattern, final) { draft: function draft(pattern) {
if (final === void 0) { final = true; } var final = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
// Save some typing
var measurements = pattern.settings.measurements || {};
var options = pattern.options; // Save some typing
var values = pattern.values; var measurements = pattern.settings.measurements || {};
var points = pattern.parts.backBlock.points; var options = pattern.options;
var paths = pattern.parts.backBlock.paths; var values = pattern.values;
// Center back (cb) vertical axis var points = pattern.parts.backBlock.points;
points.cbNeck = new freesewing_1.default.point(0, options.backNeckCutout); var paths = pattern.parts.backBlock.paths;
points.cbShoulder = new freesewing_1.default.point(0, points.cbNeck.y + (measurements.shoulderSlope - options.shoulderSlopeReduction) / 2);
points.cbArmhole = new freesewing_1.default.point(0, points.cbShoulder.y + (measurements.bicepsCircumference + options.bicepsEase) * options.armholeDepthFactor); // Center back (cb) vertical axis
points.cbWaist = new freesewing_1.default.point(0, measurements.centerBackNeckToWaist + options.backNeckCutout); points.cbNeck = new _freesewing2.default.point(0, options.backNeckCutout);
points.cbHips = new freesewing_1.default.point(0, points.cbWaist.y + measurements.naturalWaistToHip); points.cbShoulder = new _freesewing2.default.point(0, points.cbNeck.y + (measurements.shoulderSlope - options.shoulderSlopeReduction) / 2);
// Side back (cb) vertical axis points.cbArmhole = new _freesewing2.default.point(0, points.cbShoulder.y + (measurements.bicepsCircumference + options.bicepsEase) * options.armholeDepthFactor);
points.armhole = new freesewing_1.default.point(measurements.chestCircumference / 4 + options.chestEase / 4, points.cbArmhole.y); points.cbWaist = new _freesewing2.default.point(0, measurements.centerBackNeckToWaist + options.backNeckCutout);
points.waist = new freesewing_1.default.point(points.armhole.x, points.cbWaist.y); points.cbHips = new _freesewing2.default.point(0, points.cbWaist.y + measurements.naturalWaistToHip);
points.hips = new freesewing_1.default.point(points.armhole.x, points.cbHips.y);
// Shoulder line // Side back (cb) vertical axis
points.neck = new freesewing_1.default.point(measurements.neckCircumference / options.collarFactor, 0); points.armhole = new _freesewing2.default.point(measurements.chestCircumference / 4 + options.chestEase / 4, points.cbArmhole.y);
points.shoulder = new freesewing_1.default.point(measurements.shoulderToShoulder / 2 + options.shoulderEase / 2, points.cbShoulder.y); points.waist = new _freesewing2.default.point(points.armhole.x, points.cbWaist.y);
// Armhhole points.hips = new _freesewing2.default.point(points.armhole.x, points.cbHips.y);
points.armholePitch = new freesewing_1.default.point(measurements.shoulderToShoulder * options.acrossBackFactor / 2, points.armhole.y / 2 - points.shoulder.y / 2);
points._tmp1 = new freesewing_1.default.point(points.armholePitch.x, points.armhole.y); // Shoulder line
points._tmp2 = points._tmp1.shift(45, 10); points.neck = new _freesewing2.default.point(measurements.neckCircumference / options.collarFactor, 0);
points._tmp3 = freesewing_1.default.utils.beamsCross(points._tmp1, points._tmp2, points.armhole, points.armholePitch); points.shoulder = new _freesewing2.default.point(measurements.shoulderToShoulder / 2 + options.shoulderEase / 2, points.cbShoulder.y);
points.armholeHollow = points._tmp1.shiftFractionTowards(points._tmp3, 0.5);
paths.test = new freesewing_1.default.path() // Armhhole
.move(points.cbNeck) points.armholePitch = new _freesewing2.default.point(measurements.shoulderToShoulder * options.acrossBackFactor / 2, points.armhole.y / 2 - points.shoulder.y / 2);
.line(points.armhole) points._tmp1 = new _freesewing2.default.point(points.armholePitch.x, points.armhole.y);
.line(points.cbHips) points._tmp2 = points._tmp1.shift(45, 10);
.line(points.hips) points._tmp3 = _freesewing2.default.utils.beamsCross(points._tmp1, points._tmp2, points.armhole, points.armholePitch);
.curve(points.neck, points.shoulder, points.armholePitch); points.armholeHollow = points._tmp1.shiftFractionTowards(points._tmp3, 0.5);
points.gridAnchor = points.cbHips;
} paths.test = new _freesewing2.default.path().move(points.cbNeck).line(points.armhole).line(points.cbHips).line(points.hips).curve(points.neck, points.shoulder, points.armholePitch);
points.gridAnchor = points.cbHips;
}
}; };
exports.default = backBlock;
exports.default = backBlock;

View file

@ -1,16 +0,0 @@
export declare type DraftMode = "sample" | "compare" | "draft";
export declare type CompareGroup = "men" | "women";
export declare type Units = "metric" | "imperial";
export interface DraftConfig {
mode: DraftMode;
units?: Units;
options: {
[index: string]: number;
};
measurements?: {
[index: string]: number;
};
sa?: number;
scope?: string[];
theme?: string;
}

View file

@ -1,2 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

View file

@ -759,6 +759,17 @@
"to-fast-properties": "1.0.3" "to-fast-properties": "1.0.3"
} }
}, },
"babel-watch": {
"version": "2.0.7",
"resolved": "https://registry.npmjs.org/babel-watch/-/babel-watch-2.0.7.tgz",
"integrity": "sha512-pBVjnK1A3xJZHOrgVCbfd727tIPQrvzxFqGL1hgUClNd7LdQpTlO73SM1RJ9I4ibgiljbUE/3IcIHXHBJSL5+w==",
"dev": true,
"requires": {
"chokidar": "1.7.0",
"commander": "2.16.0",
"source-map-support": "0.4.18"
}
},
"babylon": { "babylon": {
"version": "6.18.0", "version": "6.18.0",
"resolved": "https://registry.npmjs.org/babylon/-/babylon-6.18.0.tgz", "resolved": "https://registry.npmjs.org/babylon/-/babylon-6.18.0.tgz",

View file

@ -2,13 +2,12 @@
"name": "@freesewing/brian", "name": "@freesewing/brian",
"version": "0.2.4", "version": "0.2.4",
"description": "A basic body block for menswear", "description": "A basic body block for menswear",
"main": "dist/index.js", "main": "dist/main.js",
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1", "test": "echo \"Error: no test specified\" && exit 1",
"build": "babel-node -- ./index.js", "build": "babel src -d dist",
"build-watch": "nodemon --exec npm run build", "watch": "babel-watch src/main.js",
"run": "nodemon node dist/index.js", "run": "nodemon node dist/main.js"
"run-watch": "nodemon node dist/index.js"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
@ -26,6 +25,7 @@
"devDependencies": { "devDependencies": {
"@freesewing/models": "0.1.1", "@freesewing/models": "0.1.1",
"babel-cli": "6.26.0", "babel-cli": "6.26.0",
"babel-preset-env": "1.7.0" "babel-preset-env": "1.7.0",
"babel-watch": "2.0.7"
} }
} }

View file

@ -1,5 +1,5 @@
import F from 'freesewing' import F from 'freesewing'
import * as patternConfig from './config/config' import * as patternConfig from '../config/config'
import { Pattern } from 'freesewing/dist/lib/pattern' import { Pattern } from 'freesewing/dist/lib/pattern'
import backBlock from './lib/back' import backBlock from './lib/back'
import { manSize38 } from '@freesewing/models' import { manSize38 } from '@freesewing/models'