🚧 Added more examples
This commit is contained in:
parent
3e7b620585
commit
155debc1d4
8 changed files with 90 additions and 32 deletions
|
@ -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",
|
||||
|
|
|
@ -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 -"
|
||||
},
|
||||
|
|
|
@ -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,
|
||||
|
|
10
packages/examples/src/plugin_buttons.js
Normal file
10
packages/examples/src/plugin_buttons.js
Normal file
|
@ -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);
|
||||
};
|
|
@ -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);
|
||||
};
|
||||
|
|
35
packages/examples/src/plugin_round.js
Normal file
35
packages/examples/src/plugin_round.js
Normal file
|
@ -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;
|
||||
};
|
22
packages/examples/src/plugin_sprinkle.js
Normal file
22
packages/examples/src/plugin_sprinkle.js
Normal file
|
@ -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);
|
||||
};
|
|
@ -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);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue