1
0
Fork 0

construction: Rollup based pattern showing in browser

This commit is contained in:
Joost De Cock 2018-07-26 23:30:43 +02:00
parent fceb73f4ea
commit 29a3e8987d
8 changed files with 2165 additions and 1454 deletions

View file

@ -7,11 +7,12 @@
<body>
<div id="svg"></div>
<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/designer.js"></script>
<script>
var pattern = brian
console.log(this);
var pattern = freesewing.patterns.brian
.with(freesewing.plugins.theme)
.with(freesewing.plugins.designer);

File diff suppressed because it is too large Load diff

View file

@ -4,10 +4,10 @@
"description": "Freesewing pattern for a basic body block for menswear",
"author": "Joost De Cock <joost@decock.org> (https://github.com/joostdecock)",
"license": "MIT",
"homepage": "https://github.com/freesewing-patterns/brian#readme",
"repository": "github:freesewing-patterns/brian",
"homepage": "https://github.com/freesewing/pattern-brian#readme",
"repository": "github:freesewing/pattern-brian",
"bugs": {
"url": "https://github.com/freesewing-patterns/brian/issues"
"url": "https://github.com/freesewing/pattern-brian/issues"
},
"keywords": [
"freesewing",
@ -16,18 +16,23 @@
"menswear",
"block"
],
"main": "dist/node/index.js",
"unpkg": "dist/browser/bundle.js",
"main": "dist/index.js",
"module": "dist/index.mjs",
"unpkg": "dist/browser.js",
"scripts": {
"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",
"clean": "rimraf dist",
"pretty": "npx prettier --write \"src/*.js\"",
"lint": "eslint --fix \"src/*.js\"",
"watch": "npx webpack --watch",
"browserbuild": "rollup -c rollup.browser.js",
"nodebuild": "rollup -c rollup.node.js",
"build": "npx webpack"
"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.js -o dist/index.js -f cjs",
"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": {
"hooks": {
@ -61,8 +66,12 @@
"lint-staged": "^7.2.0",
"prettier": "^1.13.7",
"rimraf": "^2.6.2",
"webpack": "^4.16.2",
"webpack-cli": "^3.1.0"
"rollup-plugin-babel": "^3.0.7",
"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": [
"dist/*",

View file

@ -11,10 +11,7 @@ export default {
output: {
file: "dist/browser.js",
format: "iife",
name: "freesewing.patterns.brian",
globals: {
freesewing: "freesewing"
}
name: "freesewing.patterns.brian"
},
plugins: [
resolve({
@ -25,18 +22,18 @@ export default {
babel({
exclude: "node_modules/**"
})
// terser({
// output: {
// preamble: `/**\n * ${meta.name} | v${meta.version}\n * ${
// meta.description
// }\n * (c) ${new Date().getFullYear()} ${meta.author}\n * @license ${
// meta.license
// }\n */`
// }
// })
//terser({
// output: {
// preamble: `/**\n * ${meta.name} | v${meta.version}\n * ${
// meta.description
// }\n * (c) ${new Date().getFullYear()} ${meta.author}\n * @license ${
// meta.license
// }\n */`
// }
//})
],
external: [
"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
View 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")
]
};

View file

@ -1,4 +1,4 @@
import * as F from "freesewing";
import freesewing from "freesewing";
import base from "./base";
var back = {
@ -9,13 +9,16 @@ var back = {
points,
paths,
snippets,
macro,
path,
point,
snippet,
final,
paperless
} = F.utils.shorthand(part);
paperless,
macro
} = freesewing.utils.shorthand(part);
base.draft(part);
paths.seam = new F.path()
paths.seam = new path()
.move(points.cbNeck)
.line(points.cbHips)
.line(points.hips)
@ -40,21 +43,21 @@ var back = {
grainline: true
});
points.title = new F.point(
points.title = new point(
points.armholePitch.x / 2,
points.armholePitch.y
);
macro("title", { at: points.title, nr: 2 });
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");
points.t1 = new F.point(100, 400);
points.t2 = new F.point(200, 400);
points.t3 = new F.point(200, 500);
points.t4 = new F.point(100, 500);
paths.test = new F.path()
points.t1 = new point(100, 400);
points.t2 = new point(200, 400);
points.t3 = new point(200, 500);
points.t4 = new point(100, 500);
paths.test = new path()
.move(points.t1)
.line(points.t2)
.line(points.t3)

View file

@ -1,58 +1,66 @@
import * as F from "freesewing";
import freesewing from "freesewing";
var base = {
draft: function(part) {
let { measurements, options, points, paths, snippets } = F.utils.shorthand(
part
);
let {
measurements,
options,
points,
paths,
snippets,
path,
point,
snippet,
utils
} = freesewing.utils.shorthand(part);
// Center back (cb) vertical axis
points.cbNeck = new F.point(0, options.backNeckCutout);
points.cbShoulder = new F.point(
points.cbNeck = new point(0, options.backNeckCutout);
points.cbShoulder = new point(
0,
(measurements.shoulderSlope - options.shoulderSlopeReduction) / 2
);
points.cbArmhole = new F.point(
points.cbArmhole = new point(
0,
points.cbShoulder.y +
(measurements.bicepsCircumference + options.bicepsEase) *
options.armholeDepthFactor
);
points.cbWaist = new F.point(
points.cbWaist = new point(
0,
measurements.centerBackNeckToWaist + options.backNeckCutout
);
points.cbHips = new F.point(
points.cbHips = new point(
0,
points.cbWaist.y + measurements.naturalWaistToHip
);
// Side back (cb) vertical axis
points.armhole = new F.point(
points.armhole = new point(
measurements.chestCircumference / 4 + options.chestEase / 4,
points.cbArmhole.y
);
points.waist = new F.point(points.armhole.x, points.cbWaist.y);
points.hips = new F.point(points.armhole.x, points.cbHips.y);
points.waist = new point(points.armhole.x, points.cbWaist.y);
points.hips = new point(points.armhole.x, points.cbHips.y);
// Shoulder line
points.neck = new F.point(
points.neck = new point(
measurements.neckCircumference / options.collarFactor,
0
);
points.shoulder = new F.point(
points.shoulder = new point(
measurements.shoulderToShoulder / 2 + options.shoulderEase / 2,
points.cbShoulder.y
);
// Armhhole
points.armholePitch = new F.point(
points.armholePitch = new point(
(measurements.shoulderToShoulder * options.acrossBackFactor) / 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._tmp3 = F.utils.beamsCross(
points._tmp3 = freesewing.utils.beamsCross(
points._tmp1,
points._tmp2,
points.armhole,
@ -87,7 +95,7 @@ var base = {
points._tmp4 = points.neck
.shiftTowards(points.shoulder, 10)
.rotate(-90, points.neck);
points.neckCp1 = F.utils.beamCrossesY(
points.neckCp1 = freesewing.utils.beamCrossesY(
points.neck,
points._tmp4,
points.cbNeck.y

View file

@ -17,4 +17,4 @@ pattern.draft = function() {
return pattern;
};
module.exports = pattern;
export default pattern;