sparkles: Added examples for plugins
This commit is contained in:
parent
6c0b53bf25
commit
637c8b6015
7 changed files with 180 additions and 5 deletions
|
@ -51,8 +51,14 @@ import utilsCirclesIntersect from "./utils.circlesintersect";
|
||||||
import utilsBeamIntersectsCircle from "./utils.beamintersectscircle";
|
import utilsBeamIntersectsCircle from "./utils.beamintersectscircle";
|
||||||
import utilsLineIntersectsCircle from "./utils.lineintersectscircle";
|
import utilsLineIntersectsCircle from "./utils.lineintersectscircle";
|
||||||
|
|
||||||
|
import pluginGrainline from "./plugin.grainline";
|
||||||
|
import pluginCutonfold from "./plugin.cutonfold";
|
||||||
|
import pluginDimension from "./plugin.dimension";
|
||||||
|
import pluginLogo from "./plugin.logo";
|
||||||
|
import pluginTitle from "./plugin.title";
|
||||||
|
import pluginScalebox from "./plugin.scalebox";
|
||||||
|
|
||||||
import settingsSa from "./settings.sa";
|
import settingsSa from "./settings.sa";
|
||||||
import macroGrainline from "./macro.grainline";
|
|
||||||
|
|
||||||
var pattern = new freesewing.Pattern({ version: version, ...config }).with(
|
var pattern = new freesewing.Pattern({ version: version, ...config }).with(
|
||||||
pluginBundle
|
pluginBundle
|
||||||
|
@ -106,8 +112,14 @@ pattern.draft = function() {
|
||||||
if (this.needs('utilsBeamIntersectsCircle')) this.parts.utilsBeamIntersectsCircle = this.draftUtilsBeamIntersectsCircle(new pattern.Part());
|
if (this.needs('utilsBeamIntersectsCircle')) this.parts.utilsBeamIntersectsCircle = this.draftUtilsBeamIntersectsCircle(new pattern.Part());
|
||||||
if (this.needs('utilsLineIntersectsCircle')) this.parts.utilsLineIntersectsCircle = this.draftUtilsLineIntersectsCircle(new pattern.Part());
|
if (this.needs('utilsLineIntersectsCircle')) this.parts.utilsLineIntersectsCircle = this.draftUtilsLineIntersectsCircle(new pattern.Part());
|
||||||
|
|
||||||
|
if (this.needs('pluginGrainline')) this.parts.pluginGrainline = this.draftPluginGrainline(new pattern.Part());
|
||||||
|
if (this.needs('pluginCutonfold')) this.parts.pluginCutonfold = this.draftPluginCutonfold(new pattern.Part());
|
||||||
|
if (this.needs('pluginDimension')) this.parts.pluginDimension = this.draftPluginDimension(new pattern.Part());
|
||||||
|
if (this.needs('pluginLogo')) this.parts.pluginLogo = this.draftPluginLogo(new pattern.Part());
|
||||||
|
if (this.needs('pluginTitle')) this.parts.pluginTitle = this.draftPluginTitle(new pattern.Part());
|
||||||
|
if (this.needs('pluginScalebox')) this.parts.pluginScalebox = this.draftPluginScalebox(new pattern.Part());
|
||||||
|
|
||||||
if (this.needs('settingsSa')) this.parts.settingsSa = this.draftSettingsSa(new pattern.Part());
|
if (this.needs('settingsSa')) this.parts.settingsSa = this.draftSettingsSa(new pattern.Part());
|
||||||
if (this.needs('macroGrainline')) this.parts.macroGrainline = this.draftMacroGrainline(new pattern.Part());
|
|
||||||
return pattern;
|
return pattern;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -158,8 +170,14 @@ pattern.draftUtilsCirclesIntersect = part => utilsCirclesIntersect.draft(part);
|
||||||
pattern.draftUtilsBeamIntersectsCircle = part => utilsBeamIntersectsCircle.draft(part);
|
pattern.draftUtilsBeamIntersectsCircle = part => utilsBeamIntersectsCircle.draft(part);
|
||||||
pattern.draftUtilsLineIntersectsCircle = part => utilsLineIntersectsCircle.draft(part);
|
pattern.draftUtilsLineIntersectsCircle = part => utilsLineIntersectsCircle.draft(part);
|
||||||
|
|
||||||
|
pattern.draftPluginGrainline = part => pluginGrainline.draft(part);
|
||||||
|
pattern.draftPluginCutonfold = part => pluginCutonfold.draft(part);
|
||||||
|
pattern.draftPluginDimension = part => pluginDimension.draft(part);
|
||||||
|
pattern.draftPluginLogo = part => pluginLogo.draft(part);
|
||||||
|
pattern.draftPluginTitle = part => pluginTitle.draft(part);
|
||||||
|
pattern.draftPluginScalebox = part => pluginScalebox.draft(part);
|
||||||
|
|
||||||
pattern.draftSettingsSa = part => settingsSa.draft(part);
|
pattern.draftSettingsSa = part => settingsSa.draft(part);
|
||||||
pattern.draftMacroGrainline = part => macroGrainline.draft(part);
|
|
||||||
|
|
||||||
// Add custom snippet
|
// Add custom snippet
|
||||||
pattern.on('preRender', function(next) {
|
pattern.on('preRender', function(next) {
|
||||||
|
|
30
packages/examples/src/plugin.cutonfold.js
Normal file
30
packages/examples/src/plugin.cutonfold.js
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
import freesewing from "freesewing";
|
||||||
|
|
||||||
|
var pluginCutonfold = {
|
||||||
|
draft: function(part) {
|
||||||
|
// prettier-ignore
|
||||||
|
let {Point, points, Path, paths, macro} = part.shorthand();
|
||||||
|
|
||||||
|
points.topLeft = new Point(0,0);
|
||||||
|
points.topRight = new Point(150,0);
|
||||||
|
points.bottomRight = new Point(150,50);
|
||||||
|
points.bottomLeft = new Point(0,50);
|
||||||
|
|
||||||
|
paths.box = new Path()
|
||||||
|
.move(points.topLeft)
|
||||||
|
.line(points.topRight)
|
||||||
|
.line(points.bottomRight)
|
||||||
|
.line(points.bottomLeft)
|
||||||
|
.close()
|
||||||
|
|
||||||
|
macro('cutonfold', {
|
||||||
|
from: points.topRight,
|
||||||
|
to: points.topLeft,
|
||||||
|
grainline: true
|
||||||
|
});
|
||||||
|
|
||||||
|
return part;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export default pluginCutonfold;
|
56
packages/examples/src/plugin.dimension.js
Normal file
56
packages/examples/src/plugin.dimension.js
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
import freesewing from "freesewing";
|
||||||
|
|
||||||
|
var pluginDimension = {
|
||||||
|
draft: function(part) {
|
||||||
|
// prettier-ignore
|
||||||
|
let {Point, points, Path, paths, macro} = part.shorthand();
|
||||||
|
|
||||||
|
points.A = new Point(0,0);
|
||||||
|
points.B = new Point(0,100);
|
||||||
|
points.C = new Point(50,100);
|
||||||
|
points.D = new Point(100,50);
|
||||||
|
points.DCp1 = new Point(100,0);
|
||||||
|
|
||||||
|
paths.box = new Path()
|
||||||
|
.move(points.A)
|
||||||
|
.line(points.B)
|
||||||
|
.line(points.C)
|
||||||
|
.line(points.D)
|
||||||
|
.curve(points.DCp1, points.A, points.A)
|
||||||
|
.close()
|
||||||
|
|
||||||
|
macro('vd', {
|
||||||
|
from: points.A,
|
||||||
|
to: points.B,
|
||||||
|
x: points.A.x - 15
|
||||||
|
});
|
||||||
|
|
||||||
|
macro('hd', {
|
||||||
|
from: points.B,
|
||||||
|
to: points.C,
|
||||||
|
y: points.B.y + 15
|
||||||
|
});
|
||||||
|
|
||||||
|
macro('ld', {
|
||||||
|
from: points.C,
|
||||||
|
to: points.D,
|
||||||
|
d: -15
|
||||||
|
});
|
||||||
|
|
||||||
|
macro('ld', {
|
||||||
|
from: points.C,
|
||||||
|
to: points.D,
|
||||||
|
d: -30,
|
||||||
|
text: 'Custom text'
|
||||||
|
});
|
||||||
|
|
||||||
|
macro('pd', {
|
||||||
|
path: new Path().move(points.A).curve(points.A, points.DCp1, points.D),
|
||||||
|
d: -15
|
||||||
|
});
|
||||||
|
|
||||||
|
return part;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export default pluginDimension;
|
|
@ -1,6 +1,6 @@
|
||||||
import freesewing from "freesewing";
|
import freesewing from "freesewing";
|
||||||
|
|
||||||
var macroGrainline = {
|
var pluginGrainline = {
|
||||||
draft: function(part) {
|
draft: function(part) {
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
let {Point, points, macro} = part.shorthand();
|
let {Point, points, macro} = part.shorthand();
|
||||||
|
@ -12,8 +12,9 @@ var macroGrainline = {
|
||||||
from: points.grainlineFrom,
|
from: points.grainlineFrom,
|
||||||
to: points.grainlineTo
|
to: points.grainlineTo
|
||||||
});
|
});
|
||||||
|
|
||||||
return part;
|
return part;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export default macroGrainline;
|
export default pluginGrainline;
|
25
packages/examples/src/plugin.logo.js
Normal file
25
packages/examples/src/plugin.logo.js
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
var pluginLogo = {
|
||||||
|
draft: function(part) {
|
||||||
|
// prettier-ignore
|
||||||
|
let {Point, points, Path, paths, 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);
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export default pluginLogo;
|
16
packages/examples/src/plugin.scalebox.js
Normal file
16
packages/examples/src/plugin.scalebox.js
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
var pluginScalebox = {
|
||||||
|
draft: function(part) {
|
||||||
|
// prettier-ignore
|
||||||
|
let {Point, points, Path, paths, macro} = part.shorthand();
|
||||||
|
|
||||||
|
points.anchor = new Point(0,0);
|
||||||
|
|
||||||
|
macro('scalebox', {
|
||||||
|
at: points.anchor
|
||||||
|
});
|
||||||
|
|
||||||
|
return part;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export default pluginScalebox;
|
29
packages/examples/src/plugin.title.js
Normal file
29
packages/examples/src/plugin.title.js
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
var pluginTitle = {
|
||||||
|
draft: function(part) {
|
||||||
|
// prettier-ignore
|
||||||
|
let {Point, points, Path, paths, 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()
|
||||||
|
|
||||||
|
macro('title', {
|
||||||
|
at: points.titleAnchor,
|
||||||
|
nr: 4,
|
||||||
|
title: "sleeve"
|
||||||
|
});
|
||||||
|
|
||||||
|
return part;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export default pluginTitle;
|
Loading…
Add table
Add a link
Reference in a new issue