From 5ad7a7ede95b36e82edf54630fd5a3675da989e9 Mon Sep 17 00:00:00 2001 From: Joost De Cock Date: Mon, 28 Jan 2019 14:34:55 +0100 Subject: [PATCH] sparkles: Added _curve and curve_ to path.ops example --- packages/examples/config/index.js | 4 +- packages/examples/index.html | 4 +- packages/examples/rollup.js | 10 ++-- packages/examples/src/index.js | 11 ++++- packages/examples/src/path_ops.js | 72 +++++++++++++---------------- packages/examples/src/point_attr.js | 2 - 6 files changed, 50 insertions(+), 53 deletions(-) diff --git a/packages/examples/config/index.js b/packages/examples/config/index.js index e01b864ea38..5031dfebc76 100644 --- a/packages/examples/config/index.js +++ b/packages/examples/config/index.js @@ -6,10 +6,12 @@ export default { // This is not needed, but is here to sidestep an issue in freesewing // that needs to be fixed but hasn't yet dependencies: { - path_attr: "path_clone" + path_attr: "path_ops" }, parts: [ "point_attr", + "path__curve", + "path_curve_", "path_attr", "path_clone", "path_divide", diff --git a/packages/examples/index.html b/packages/examples/index.html index 31b272cff8d..a7912617903 100644 --- a/packages/examples/index.html +++ b/packages/examples/index.html @@ -3,7 +3,7 @@ Examples - + @@ -23,7 +23,7 @@ .use(freesewing.plugins.validate) ; - //pattern.settings.only = ['pathAttr']; + pattern.settings.only = ['path_ops']; pattern.draft(); document.getElementById("svg").innerHTML = pattern.render(); diff --git a/packages/examples/rollup.js b/packages/examples/rollup.js index efea00c2214..a0a23877911 100644 --- a/packages/examples/rollup.js +++ b/packages/examples/rollup.js @@ -16,12 +16,12 @@ export default { commonjs(), babel({ exclude: "node_modules/**" + }), + terser({ + output: { + preamble: `/**\n * ${name} | v${version}\n * ${description}\n * (c) ${new Date().getFullYear()} ${author}\n * @license ${license}\n */` + } }) - //terser({ - // output: { - // preamble: `/**\n * ${name} | v${version}\n * ${description}\n * (c) ${new Date().getFullYear()} ${author}\n * @license ${license}\n */` - // } - //}) ], external: ["freesewing", "@freesewing/plugin-bundle"], output: { diff --git a/packages/examples/src/index.js b/packages/examples/src/index.js index c63cab57c7d..265ea192412 100644 --- a/packages/examples/src/index.js +++ b/packages/examples/src/index.js @@ -4,6 +4,7 @@ import plugins from "@freesewing/plugin-bundle"; import config from "../config/"; import { version } from "../package.json"; +import draftPath_ops from "./path_ops"; import draftPath_attr from "./path_attr"; import draftPath_clone from "./path_clone"; import draftPath_divide from "./path_divide"; @@ -15,7 +16,6 @@ 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_ops from "./path_ops"; import draftPath_reverse from "./path_reverse"; import draftPath_shiftalong from "./path_shiftalong"; import draftPath_shiftfractionalong from "./path_shiftfractionalong"; @@ -76,7 +76,13 @@ Examples.prototype = Object.create(freesewing.Pattern.prototype); Examples.prototype.constructor = Examples; // Attach per-part draft methods to prototype -Examples.prototype.draftPoint_attr = draftPoint_attr; + +Examples.prototype.draftPath_move = draftPath_ops; +Examples.prototype.draftPath_line = draftPath_ops; +Examples.prototype.draftPath_curve = draftPath_ops; +Examples.prototype.draftPath__curve = draftPath_ops; +Examples.prototype.draftPath_curve_ = draftPath_ops; +Examples.prototype.draftPath_close = draftPath_ops; Examples.prototype.draftPath_attr = draftPath_attr; Examples.prototype.draftPath_clone = draftPath_clone; @@ -105,6 +111,7 @@ Examples.prototype.draftPlugin_logo = draftPlugin_logo; Examples.prototype.draftPlugin_scalebox = draftPlugin_scalebox; Examples.prototype.draftPlugin_title = draftPlugin_title; +Examples.prototype.draftPoint_attr = draftPoint_attr; Examples.prototype.draftPoint_angle = draftPoint_angle; Examples.prototype.draftPoint_attr = draftPoint_attr; Examples.prototype.draftPoint_clone = draftPoint_clone; diff --git a/packages/examples/src/path_ops.js b/packages/examples/src/path_ops.js index 945b0785a95..1f3bbdcabc9 100644 --- a/packages/examples/src/path_ops.js +++ b/packages/examples/src/path_ops.js @@ -1,63 +1,53 @@ export default part => { - let { - Point, - points, - Path, - paths, - Snippet, - snippets, - macro - } = part.shorthand(); + let { Point, points, Path, paths } = part.shorthand(); points.A = new Point(10, 10) - .attr("data-text", "Move to point A") + .attr("data-text", "msg_move") .attr("data-text-class", "center text-xs"); 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.example = new Path() + paths.line = new Path() .move(points.A) .line(points.B) - .curve(points.BCp2, points.CCp1, points.C) - .close(); + .attr("data-text", "msg_line") + .attr("data-text-class", "center text-xs"); - paths.handle1 = new Path() + paths.curve = new Path() .move(points.B) - .line(points.BCp2) - .attr("class", "note dashed"); - paths.handle2 = new Path() + .curve(points.BCp2, points.CCp1, points.C) + .attr("data-text", "msg_curve") + .attr("data-text-class", "center text-xs"); + + paths._curve = new Path() .move(points.C) - .line(points.CCp1) - .attr("class", "note dashed"); - - snippets.A = new Snippet("notch", points.A); - snippets.B = new Snippet("notch", points.B); - snippets.C = new Snippet("notch", points.C); - snippets.Bcp2 = new Snippet("x", points.BCp2); - snippets.Ccp1 = new Snippet("x", points.CCp1); - - paths.textLine = new Path() - .move(points.A) - .line(points.B) - .attr("data-text", "Line to point B") + ._curve(points.DCp, points.D) + .attr("data-text", "msg__curve") .attr("data-text-class", "center text-xs"); - paths.textCurve = new Path() - .move(points.B) - .curve(points.BCp2, points.CCp1, points.C) - .attr( - "data-text", - "Curve to point C, using BCp2 and CCp1 as control points" - ) + paths.curve_ = new Path() + .move(points.D) + .curve_(points.ECp, points.E) + .attr("data-text", "msg_curve_") .attr("data-text-class", "center text-xs"); - paths.textClose = new Path() - .move(points.A) - .line(points.C) - .attr("data-text", "Close path") + paths.close = new Path() + .move(points.E) + .line(points.A) + .attr("data-text", "msg_close") .attr("data-text-class", "center text-xs"); + paths.example = paths.line + .join(paths.curve) + .join(paths._curve) + .join(paths.curve_) + .close(); + return part; }; diff --git a/packages/examples/src/point_attr.js b/packages/examples/src/point_attr.js index f3d8480ebf4..33f9be58dd3 100644 --- a/packages/examples/src/point_attr.js +++ b/packages/examples/src/point_attr.js @@ -8,7 +8,5 @@ export default part => { .attr("data-text-class", "text-xl center") .attr("data-text-lineheight", 10); - snippets.notch = new Snippet("x", points.anchor); - return box(part); };