From 155debc1d4fde0c3c12be24cecbaa8a7a6abe19d Mon Sep 17 00:00:00 2001 From: Joost De Cock Date: Sat, 25 May 2019 19:12:31 +0200 Subject: [PATCH] :construction: Added more examples --- packages/examples/config/index.js | 3 ++ packages/examples/package.json | 1 + packages/examples/src/index.js | 6 ++++ packages/examples/src/plugin_buttons.js | 10 +++++++ packages/examples/src/plugin_logo.js | 21 ++++---------- packages/examples/src/plugin_round.js | 35 ++++++++++++++++++++++++ packages/examples/src/plugin_sprinkle.js | 22 +++++++++++++++ packages/examples/src/plugin_title.js | 24 ++++++---------- 8 files changed, 90 insertions(+), 32 deletions(-) create mode 100644 packages/examples/src/plugin_buttons.js create mode 100644 packages/examples/src/plugin_round.js create mode 100644 packages/examples/src/plugin_sprinkle.js diff --git a/packages/examples/config/index.js b/packages/examples/config/index.js index 667137eea72..da1f3f9d4de 100644 --- a/packages/examples/config/index.js +++ b/packages/examples/config/index.js @@ -39,11 +39,14 @@ export default { "path_start", "path_translate", "path_trim", + "plugin_buttons", "plugin_cutonfold", "plugin_dimension", "plugin_grainline", "plugin_logo", + "plugin_round", "plugin_scalebox", + "plugin_sprinkle", "plugin_title", "point_angle", "point_attr", diff --git a/packages/examples/package.json b/packages/examples/package.json index 176a51ada64..fff6e98bd24 100644 --- a/packages/examples/package.json +++ b/packages/examples/package.json @@ -24,6 +24,7 @@ "build": "npm run clean && npm run nodebuild && npm run modulebuild", "test": "echo \"examples: No tests configured. Perhaps you'd like to do this?\" && exit 0", "pubtest": "npm publish --registry http://localhost:6662", + "start": "rollup -c -w", "pubforce": "npm publish", "symlink": "mkdir -p ./node_modules/@freesewing && cd ./node_modules/@freesewing && ln -s -f ../../../* . && cd -" }, diff --git a/packages/examples/src/index.js b/packages/examples/src/index.js index 62fa3d44012..1a9b87e176d 100644 --- a/packages/examples/src/index.js +++ b/packages/examples/src/index.js @@ -29,9 +29,12 @@ 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"; // Point API @@ -108,11 +111,14 @@ let methods = { draftPath_start, draftPath_translate, draftPath_trim, + draftPlugin_buttons, draftPlugin_cutonfold, draftPlugin_dimension, draftPlugin_grainline, draftPlugin_logo, + draftPlugin_round, draftPlugin_scalebox, + draftPlugin_sprinkle, draftPlugin_title, draftPoint_angle, draftPoint_attr, diff --git a/packages/examples/src/plugin_buttons.js b/packages/examples/src/plugin_buttons.js new file mode 100644 index 00000000000..db100080ead --- /dev/null +++ b/packages/examples/src/plugin_buttons.js @@ -0,0 +1,10 @@ +import { box } from "./shared"; + +export default part => { + let { Point, snippets, Snippet } = part.shorthand(); + + snippets.button = new Snippet("button", new Point(30, 10)); + snippets.buttonhole = new Snippet("buttonhole", new Point(70, 10)); + + return box(part, 100, 20); +}; diff --git a/packages/examples/src/plugin_logo.js b/packages/examples/src/plugin_logo.js index 97010a70718..d6aa3e83e5f 100644 --- a/packages/examples/src/plugin_logo.js +++ b/packages/examples/src/plugin_logo.js @@ -1,20 +1,9 @@ +import { box } from "./shared"; + export default part => { - let { Point, points, Path, paths, snippets, Snippet } = part.shorthand(); + let { Point, snippets, Snippet } = part.shorthand(); - points.topLeft = new Point(0, 0); - points.topRight = new Point(120, 0); - points.bottomRight = new Point(120, 70); - points.bottomLeft = new Point(0, 70); - points.logoAnchor = new Point(60, 47); + snippets.logo = new Snippet("logo", new Point(50, 30)); - paths.box = new Path() - .move(points.topLeft) - .line(points.topRight) - .line(points.bottomRight) - .line(points.bottomLeft) - .close(); - - snippets.logo = new Snippet("logo", points.logoAnchor); - - return part; + return box(part, 100, 40); }; diff --git a/packages/examples/src/plugin_round.js b/packages/examples/src/plugin_round.js new file mode 100644 index 00000000000..b27a2ec6477 --- /dev/null +++ b/packages/examples/src/plugin_round.js @@ -0,0 +1,35 @@ +export default part => { + 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); + + paths.demo = new Path() + .move(points.topLeft) + .line(points.bottomLeft) + .line(points.bottomRight) + .line(points.topRight) + .close() + .attr("class", "note dashed"); + + macro("round", { + from: points.topLeft, + to: points.bottomRight, + via: points.bottomLeft, + radius: 10, + prefix: "bl", + render: true + }); + macro("round", { + from: points.bottomRight, + to: points.topLeft, + via: points.topRight, + radius: 20, + prefix: "tr", + render: true + }); + + return part; +}; diff --git a/packages/examples/src/plugin_sprinkle.js b/packages/examples/src/plugin_sprinkle.js new file mode 100644 index 00000000000..4e086f8b481 --- /dev/null +++ b/packages/examples/src/plugin_sprinkle.js @@ -0,0 +1,22 @@ +import { box } from "./shared"; + +export default part => { + 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); + + macro("sprinkle", { + snippet: "button", + on: ["a", "b", "c", "d", "e", "f", "g", "h", "i"] + }); + + return box(part, 100, 25); +}; diff --git a/packages/examples/src/plugin_title.js b/packages/examples/src/plugin_title.js index 90f6b28befb..be853ee3177 100644 --- a/packages/examples/src/plugin_title.js +++ b/packages/examples/src/plugin_title.js @@ -1,24 +1,16 @@ +import { box } from "./shared"; + export default part => { - let { Point, points, Path, paths, macro } = part.shorthand(); + let { Point, points, macro } = part.shorthand(); - points.topLeft = new Point(0, 0); - points.topRight = new Point(120, 0); - points.bottomRight = new Point(120, 70); - points.bottomLeft = new Point(0, 70); - points.titleAnchor = new Point(60, 35); - - paths.box = new Path() - .move(points.topLeft) - .line(points.topRight) - .line(points.bottomRight) - .line(points.bottomLeft) - .close(); + points.title = new Point(90, 45); macro("title", { - at: points.titleAnchor, + at: points.title, nr: 4, - title: "sleeve" + title: "sleeve", + prefix: "test" }); - return part; + return box(part, 200, 70); };