construction: Rollup based pattern showing in browser
This commit is contained in:
parent
fceb73f4ea
commit
29a3e8987d
8 changed files with 2165 additions and 1454 deletions
|
@ -7,11 +7,12 @@
|
||||||
<body>
|
<body>
|
||||||
<div id="svg"></div>
|
<div id="svg"></div>
|
||||||
<script type="text/javascript" src="freesewing.js"></script>
|
<script type="text/javascript" src="freesewing.js"></script>
|
||||||
<script type="text/javascript" src="dist/module.js"></script>
|
<script type="text/javascript" src="dist/browser.js"></script>
|
||||||
<script type="text/javascript" src="tmp/theme.js"></script>
|
<script type="text/javascript" src="tmp/theme.js"></script>
|
||||||
<script type="text/javascript" src="tmp/designer.js"></script>
|
<script type="text/javascript" src="tmp/designer.js"></script>
|
||||||
<script>
|
<script>
|
||||||
var pattern = brian
|
console.log(this);
|
||||||
|
var pattern = freesewing.patterns.brian
|
||||||
.with(freesewing.plugins.theme)
|
.with(freesewing.plugins.theme)
|
||||||
.with(freesewing.plugins.designer);
|
.with(freesewing.plugins.designer);
|
||||||
|
|
||||||
|
|
3457
packages/brian/package-lock.json
generated
3457
packages/brian/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -4,10 +4,10 @@
|
||||||
"description": "Freesewing pattern for a basic body block for menswear",
|
"description": "Freesewing pattern for a basic body block for menswear",
|
||||||
"author": "Joost De Cock <joost@decock.org> (https://github.com/joostdecock)",
|
"author": "Joost De Cock <joost@decock.org> (https://github.com/joostdecock)",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"homepage": "https://github.com/freesewing-patterns/brian#readme",
|
"homepage": "https://github.com/freesewing/pattern-brian#readme",
|
||||||
"repository": "github:freesewing-patterns/brian",
|
"repository": "github:freesewing/pattern-brian",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/freesewing-patterns/brian/issues"
|
"url": "https://github.com/freesewing/pattern-brian/issues"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"freesewing",
|
"freesewing",
|
||||||
|
@ -16,18 +16,23 @@
|
||||||
"menswear",
|
"menswear",
|
||||||
"block"
|
"block"
|
||||||
],
|
],
|
||||||
"main": "dist/node/index.js",
|
"main": "dist/index.js",
|
||||||
"unpkg": "dist/browser/bundle.js",
|
"module": "dist/index.mjs",
|
||||||
|
"unpkg": "dist/browser.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"precommit": "npm run pretty && lint-staged",
|
"precommit": "npm run pretty && lint-staged",
|
||||||
|
"patch": "npm version patch -m ':bookmark: v%s; && npm run build",
|
||||||
|
"minor": "npm version minor -m ':bookmark: v%s; && npm run build",
|
||||||
|
"major": "npm version major -m ':bookmark: v%s; && npm run build",
|
||||||
"test": "echo \"Error: no test specified\" && exit 1",
|
"test": "echo \"Error: no test specified\" && exit 1",
|
||||||
"clean": "rimraf dist",
|
"clean": "rimraf dist",
|
||||||
"pretty": "npx prettier --write \"src/*.js\"",
|
"pretty": "npx prettier --write \"src/*.js\"",
|
||||||
"lint": "eslint --fix \"src/*.js\"",
|
"lint": "eslint --fix \"src/*.js\"",
|
||||||
"watch": "npx webpack --watch",
|
"watch": "npx webpack --watch",
|
||||||
"browserbuild": "rollup -c rollup.browser.js",
|
"browserbuild": "rollup -c rollup.js -o dist/browser.js -f iife -n freesewing_patterns_brian --footer 'freesewing.patterns.brian = freesewing_patterns_brian;'",
|
||||||
"nodebuild": "rollup -c rollup.node.js",
|
"nodebuild": "rollup -c rollup.js -o dist/index.js -f cjs",
|
||||||
"build": "npx webpack"
|
"modulebuild": "rollup -c rollup.js -o dist/index.mjs -f es",
|
||||||
|
"build": "npm run clean && npm run browserbuild && npm run nodebuild && npm run modulebuild"
|
||||||
},
|
},
|
||||||
"husky": {
|
"husky": {
|
||||||
"hooks": {
|
"hooks": {
|
||||||
|
@ -61,8 +66,12 @@
|
||||||
"lint-staged": "^7.2.0",
|
"lint-staged": "^7.2.0",
|
||||||
"prettier": "^1.13.7",
|
"prettier": "^1.13.7",
|
||||||
"rimraf": "^2.6.2",
|
"rimraf": "^2.6.2",
|
||||||
"webpack": "^4.16.2",
|
"rollup-plugin-babel": "^3.0.7",
|
||||||
"webpack-cli": "^3.1.0"
|
"rollup-plugin-commonjs": "9.1.3",
|
||||||
|
"rollup-plugin-filesize": "^4.0.1",
|
||||||
|
"rollup-plugin-json": "^3.0.0",
|
||||||
|
"rollup-plugin-node-resolve": "^3.3.0",
|
||||||
|
"rollup-plugin-terser": "^1.0.1"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"dist/*",
|
"dist/*",
|
||||||
|
|
|
@ -11,10 +11,7 @@ export default {
|
||||||
output: {
|
output: {
|
||||||
file: "dist/browser.js",
|
file: "dist/browser.js",
|
||||||
format: "iife",
|
format: "iife",
|
||||||
name: "freesewing.patterns.brian",
|
name: "freesewing.patterns.brian"
|
||||||
globals: {
|
|
||||||
freesewing: "freesewing"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
resolve({
|
resolve({
|
||||||
|
@ -37,6 +34,6 @@ export default {
|
||||||
],
|
],
|
||||||
external: [
|
external: [
|
||||||
"freesewing",
|
"freesewing",
|
||||||
path.resolve("./node_modules/freesewing/dist/freesewing.min.js")
|
path.resolve("./node_modules/freesewing/dist/index.mjs")
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
30
packages/brian/rollup.js
Normal file
30
packages/brian/rollup.js
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
import { terser } from "rollup-plugin-terser";
|
||||||
|
import babel from "rollup-plugin-babel";
|
||||||
|
import resolve from "rollup-plugin-node-resolve";
|
||||||
|
import commonjs from "rollup-plugin-commonjs";
|
||||||
|
import json from "rollup-plugin-json";
|
||||||
|
import path from "path";
|
||||||
|
import { name, version, description, author, license } from "./package.json";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
input: "src/index.js",
|
||||||
|
plugins: [
|
||||||
|
resolve({
|
||||||
|
browser: true
|
||||||
|
}),
|
||||||
|
json(),
|
||||||
|
commonjs(),
|
||||||
|
babel({
|
||||||
|
exclude: "node_modules/**"
|
||||||
|
})
|
||||||
|
//terser({
|
||||||
|
// output: {
|
||||||
|
// preamble: `/**\n * ${name} | v${version}\n * ${description}\n * (c) ${new Date().getFullYear()} ${author}\n * @license ${license}\n */`
|
||||||
|
// }
|
||||||
|
//})
|
||||||
|
],
|
||||||
|
external: [
|
||||||
|
"freesewing",
|
||||||
|
path.resolve("./node_modules/freesewing/dist/index.mjs")
|
||||||
|
]
|
||||||
|
};
|
|
@ -1,4 +1,4 @@
|
||||||
import * as F from "freesewing";
|
import freesewing from "freesewing";
|
||||||
import base from "./base";
|
import base from "./base";
|
||||||
|
|
||||||
var back = {
|
var back = {
|
||||||
|
@ -9,13 +9,16 @@ var back = {
|
||||||
points,
|
points,
|
||||||
paths,
|
paths,
|
||||||
snippets,
|
snippets,
|
||||||
macro,
|
path,
|
||||||
|
point,
|
||||||
|
snippet,
|
||||||
final,
|
final,
|
||||||
paperless
|
paperless,
|
||||||
} = F.utils.shorthand(part);
|
macro
|
||||||
|
} = freesewing.utils.shorthand(part);
|
||||||
base.draft(part);
|
base.draft(part);
|
||||||
|
|
||||||
paths.seam = new F.path()
|
paths.seam = new path()
|
||||||
.move(points.cbNeck)
|
.move(points.cbNeck)
|
||||||
.line(points.cbHips)
|
.line(points.cbHips)
|
||||||
.line(points.hips)
|
.line(points.hips)
|
||||||
|
@ -40,21 +43,21 @@ var back = {
|
||||||
grainline: true
|
grainline: true
|
||||||
});
|
});
|
||||||
|
|
||||||
points.title = new F.point(
|
points.title = new point(
|
||||||
points.armholePitch.x / 2,
|
points.armholePitch.x / 2,
|
||||||
points.armholePitch.y
|
points.armholePitch.y
|
||||||
);
|
);
|
||||||
macro("title", { at: points.title, nr: 2 });
|
macro("title", { at: points.title, nr: 2 });
|
||||||
|
|
||||||
points.logo = points.title.shift(-90, 100);
|
points.logo = points.title.shift(-90, 100);
|
||||||
snippets.logo = new F.snippet("logo", points.logo);
|
snippets.logo = new snippet("logo", points.logo);
|
||||||
|
|
||||||
console.log("path offset");
|
console.log("path offset");
|
||||||
points.t1 = new F.point(100, 400);
|
points.t1 = new point(100, 400);
|
||||||
points.t2 = new F.point(200, 400);
|
points.t2 = new point(200, 400);
|
||||||
points.t3 = new F.point(200, 500);
|
points.t3 = new point(200, 500);
|
||||||
points.t4 = new F.point(100, 500);
|
points.t4 = new point(100, 500);
|
||||||
paths.test = new F.path()
|
paths.test = new path()
|
||||||
.move(points.t1)
|
.move(points.t1)
|
||||||
.line(points.t2)
|
.line(points.t2)
|
||||||
.line(points.t3)
|
.line(points.t3)
|
||||||
|
|
|
@ -1,58 +1,66 @@
|
||||||
import * as F from "freesewing";
|
import freesewing from "freesewing";
|
||||||
|
|
||||||
var base = {
|
var base = {
|
||||||
draft: function(part) {
|
draft: function(part) {
|
||||||
let { measurements, options, points, paths, snippets } = F.utils.shorthand(
|
let {
|
||||||
part
|
measurements,
|
||||||
);
|
options,
|
||||||
|
points,
|
||||||
|
paths,
|
||||||
|
snippets,
|
||||||
|
path,
|
||||||
|
point,
|
||||||
|
snippet,
|
||||||
|
utils
|
||||||
|
} = freesewing.utils.shorthand(part);
|
||||||
|
|
||||||
// Center back (cb) vertical axis
|
// Center back (cb) vertical axis
|
||||||
points.cbNeck = new F.point(0, options.backNeckCutout);
|
points.cbNeck = new point(0, options.backNeckCutout);
|
||||||
points.cbShoulder = new F.point(
|
points.cbShoulder = new point(
|
||||||
0,
|
0,
|
||||||
(measurements.shoulderSlope - options.shoulderSlopeReduction) / 2
|
(measurements.shoulderSlope - options.shoulderSlopeReduction) / 2
|
||||||
);
|
);
|
||||||
points.cbArmhole = new F.point(
|
points.cbArmhole = new point(
|
||||||
0,
|
0,
|
||||||
points.cbShoulder.y +
|
points.cbShoulder.y +
|
||||||
(measurements.bicepsCircumference + options.bicepsEase) *
|
(measurements.bicepsCircumference + options.bicepsEase) *
|
||||||
options.armholeDepthFactor
|
options.armholeDepthFactor
|
||||||
);
|
);
|
||||||
points.cbWaist = new F.point(
|
points.cbWaist = new point(
|
||||||
0,
|
0,
|
||||||
measurements.centerBackNeckToWaist + options.backNeckCutout
|
measurements.centerBackNeckToWaist + options.backNeckCutout
|
||||||
);
|
);
|
||||||
points.cbHips = new F.point(
|
points.cbHips = new point(
|
||||||
0,
|
0,
|
||||||
points.cbWaist.y + measurements.naturalWaistToHip
|
points.cbWaist.y + measurements.naturalWaistToHip
|
||||||
);
|
);
|
||||||
|
|
||||||
// Side back (cb) vertical axis
|
// Side back (cb) vertical axis
|
||||||
points.armhole = new F.point(
|
points.armhole = new point(
|
||||||
measurements.chestCircumference / 4 + options.chestEase / 4,
|
measurements.chestCircumference / 4 + options.chestEase / 4,
|
||||||
points.cbArmhole.y
|
points.cbArmhole.y
|
||||||
);
|
);
|
||||||
points.waist = new F.point(points.armhole.x, points.cbWaist.y);
|
points.waist = new point(points.armhole.x, points.cbWaist.y);
|
||||||
points.hips = new F.point(points.armhole.x, points.cbHips.y);
|
points.hips = new point(points.armhole.x, points.cbHips.y);
|
||||||
|
|
||||||
// Shoulder line
|
// Shoulder line
|
||||||
points.neck = new F.point(
|
points.neck = new point(
|
||||||
measurements.neckCircumference / options.collarFactor,
|
measurements.neckCircumference / options.collarFactor,
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
points.shoulder = new F.point(
|
points.shoulder = new point(
|
||||||
measurements.shoulderToShoulder / 2 + options.shoulderEase / 2,
|
measurements.shoulderToShoulder / 2 + options.shoulderEase / 2,
|
||||||
points.cbShoulder.y
|
points.cbShoulder.y
|
||||||
);
|
);
|
||||||
|
|
||||||
// Armhhole
|
// Armhhole
|
||||||
points.armholePitch = new F.point(
|
points.armholePitch = new point(
|
||||||
(measurements.shoulderToShoulder * options.acrossBackFactor) / 2,
|
(measurements.shoulderToShoulder * options.acrossBackFactor) / 2,
|
||||||
points.shoulder.y + points.shoulder.dy(points.armhole) / 2
|
points.shoulder.y + points.shoulder.dy(points.armhole) / 2
|
||||||
);
|
);
|
||||||
points._tmp1 = new F.point(points.armholePitch.x, points.armhole.y);
|
points._tmp1 = new point(points.armholePitch.x, points.armhole.y);
|
||||||
points._tmp2 = points._tmp1.shift(45, 10);
|
points._tmp2 = points._tmp1.shift(45, 10);
|
||||||
points._tmp3 = F.utils.beamsCross(
|
points._tmp3 = freesewing.utils.beamsCross(
|
||||||
points._tmp1,
|
points._tmp1,
|
||||||
points._tmp2,
|
points._tmp2,
|
||||||
points.armhole,
|
points.armhole,
|
||||||
|
@ -87,7 +95,7 @@ var base = {
|
||||||
points._tmp4 = points.neck
|
points._tmp4 = points.neck
|
||||||
.shiftTowards(points.shoulder, 10)
|
.shiftTowards(points.shoulder, 10)
|
||||||
.rotate(-90, points.neck);
|
.rotate(-90, points.neck);
|
||||||
points.neckCp1 = F.utils.beamCrossesY(
|
points.neckCp1 = freesewing.utils.beamCrossesY(
|
||||||
points.neck,
|
points.neck,
|
||||||
points._tmp4,
|
points._tmp4,
|
||||||
points.cbNeck.y
|
points.cbNeck.y
|
||||||
|
|
|
@ -17,4 +17,4 @@ pattern.draft = function() {
|
||||||
return pattern;
|
return pattern;
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = pattern;
|
export default pattern;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue