1
0
Fork 0

construction: Ported to v0.29

This commit is contained in:
Joost De Cock 2019-01-27 12:54:18 +01:00
parent dee09139bf
commit 3f65251532
108 changed files with 1962 additions and 1940 deletions

View file

@ -1,10 +0,0 @@
import { version } from "../package.json";
export default {
name: "examples",
version,
dependencies: {
path_attr: "path_clone"
},
parts: ["path_attr", "path_clone"]
};

View file

@ -0,0 +1,68 @@
import { version } from "../package.json";
export default {
name: "examples",
version,
// 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"
},
parts: [
"point_attr",
"path_attr",
"path_clone",
"path_divide",
"path_edge",
"path_end",
"path_intersects",
"path_intersectsx",
"path_intersectsy",
"path_join",
"path_length",
"path_offset",
"path_ops",
"path_reverse",
"path_shiftalong",
"path_shiftfractionalong",
"path_split",
"path_start",
"path_translate",
"path_trim",
"plugin_cutonfold",
"plugin_dimension",
"plugin_grainline",
"plugin_logo",
"plugin_scalebox",
"plugin_title",
"point_angle",
"point_attr",
"point_clone",
"point_copy",
"point_dist",
"point_dx",
"point_dy",
"point_flipx",
"point_flipy",
"point_shift",
"point_shiftfractiontowards",
"point_shifttowards",
"point_shiftoutwards",
"point_sitson",
"point_rotate",
"point_translate",
"settings_sa",
"utils_linesintersect",
"utils_beamsintersect",
"utils_beamintersectsx",
"utils_beamintersectsy",
"utils_lineintersectscurve",
"utils_curvesintersect",
"utils_pointonbeam",
"utils_pointonline",
"utils_pointoncurve",
"utils_circlesintersect",
"utils_beamintersectscircle",
"utils_lineintersectscircle"
]
};

View file

@ -19,7 +19,7 @@
var pattern = new freesewing.patterns.examples();
pattern.use(freesewing.plugins.debug)
.use(freesewing.plugins.theme)
.use(freesewing.plugins.designer)
//.use(freesewing.plugins.designer)
.use(freesewing.plugins.validate)
;

View file

@ -1,68 +1,67 @@
import freesewing from "freesewing";
import plugins from "@freesewing/plugin-bundle";
import config from "../config/config";
import config from "../config/";
import { version } from "../package.json";
import pointAttr from "./point.attr";
import pointDist from "./point.dist";
import pointDx from "./point.dx";
import pointDy from "./point.dy";
import pointAngle from "./point.angle";
import pointRotate from "./point.rotate";
import pointCopy from "./point.copy";
import pointFlipX from "./point.flipx";
import pointFlipY from "./point.flipy";
import pointShift from "./point.shift";
import pointShiftTowards from "./point.shifttowards";
import pointShiftFractionTowards from "./point.shiftfractiontowards";
import pointShiftOutwards from "./point.shiftoutwards";
import pointTranslate from "./point.translate";
import pointSitsOn from "./point.sitson";
import pointClone from "./point.clone";
import draftPath_attr from "./path_attr";
import draftPath_clone from "./path_clone";
import draftPath_divide from "./path_divide";
import draftPath_edge from "./path_edge";
import draftPath_end from "./path_end";
import draftPath_intersects from "./path_intersects";
import draftPath_intersectsx from "./path_intersectsx";
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";
import draftPath_split from "./path_split";
import draftPath_start from "./path_start";
import draftPath_translate from "./path_translate";
import draftPath_trim from "./path_trim";
import pathOps from "./path.ops";
import pathOffset from "./path.offset";
import pathLength from "./path.length";
import pathStart from "./path.start";
import pathEnd from "./path.end";
import pathJoin from "./path.join";
import pathReverse from "./path.reverse";
import pathShiftAlong from "./path.shiftalong";
import pathShiftFractionAlong from "./path.shiftfractionalong";
import pathEdge from "./path.edge";
import pathTrim from "./path.trim";
import pathIntersectsX from "./path.intersectsx";
import pathIntersectsY from "./path.intersectsy";
import pathIntersects from "./path.intersects";
import pathDivide from "./path.divide";
import pathSplit from "./path.split";
import pathTranslate from "./path.translate";
import draftPlugin_cutonfold from "./plugin_cutonfold";
import draftPlugin_dimension from "./plugin_dimension";
import draftPlugin_grainline from "./plugin_grainline";
import draftPlugin_logo from "./plugin_logo";
import draftPlugin_scalebox from "./plugin_scalebox";
import draftPlugin_title from "./plugin_title";
import utilsLinesIntersect from "./utils.linesintersect";
import utilsBeamsIntersect from "./utils.beamsintersect";
import utilsBeamIntersectsX from "./utils.beamintersectsx";
import utilsBeamIntersectsY from "./utils.beamintersectsy";
import utilsLineIntersectsCurve from "./utils.lineintersectscurve";
import utilsCurvesIntersect from "./utils.curvesintersect";
import utilsPointOnBeam from "./utils.pointonbeam";
import utilsPointOnLine from "./utils.pointonline";
import utilsPointOnCurve from "./utils.pointoncurve";
import utilsCirclesIntersect from "./utils.circlesintersect";
import utilsBeamIntersectsCircle from "./utils.beamintersectscircle";
import utilsLineIntersectsCircle from "./utils.lineintersectscircle";
import draftPoint_angle from "./point_angle";
import draftPoint_attr from "./point_attr";
import draftPoint_clone from "./point_clone";
import draftPoint_copy from "./point_copy";
import draftPoint_dist from "./point_dist";
import draftPoint_dx from "./point_dx";
import draftPoint_dy from "./point_dy";
import draftPoint_flipx from "./point_flipx";
import draftPoint_flipy from "./point_flipy";
import draftPoint_shift from "./point_shift";
import draftPoint_shiftfractiontowards from "./point_shiftfractiontowards";
import draftPoint_shifttowards from "./point_shifttowards";
import draftPoint_shiftoutwards from "./point_shiftoutwards";
import draftPoint_sitson from "./point_sitson";
import draftPoint_rotate from "./point_rotate";
import draftPoint_translate from "./point_translate";
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 draftUtils_linesintersect from "./utils_linesintersect";
import draftUtils_beamsintersect from "./utils_beamsintersect";
import draftUtils_beamintersectsx from "./utils_beamintersectsx";
import draftUtils_beamintersectsy from "./utils_beamintersectsy";
import draftUtils_lineintersectscurve from "./utils_lineintersectscurve";
import draftUtils_curvesintersect from "./utils_curvesintersect";
import draftUtils_pointonbeam from "./utils_pointonbeam";
import draftUtils_pointonline from "./utils_pointonline";
import draftUtils_pointoncurve from "./utils_pointoncurve";
import draftUtils_circlesintersect from "./utils_circlesintersect";
import draftUtils_beamintersectscircle from "./utils_beamintersectscircle";
import draftUtils_lineintersectscircle from "./utils_lineintersectscircle";
import settingsSa from "./settings.sa";
import draftSettings_sa from "./settings_sa";
// Constructor
const Examples = function(settings) {
@ -77,8 +76,66 @@ 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_attr = draftPath_attr;
Examples.prototype.draftPath_clone = draftPath_clone;
Examples.prototype.draftPath_divide = draftPath_divide;
Examples.prototype.draftPath_edge = draftPath_edge;
Examples.prototype.draftPath_end = draftPath_end;
Examples.prototype.draftPath_intersects = draftPath_intersects;
Examples.prototype.draftPath_intersectsx = draftPath_intersectsy;
Examples.prototype.draftPath_intersectsy = draftPath_intersectsy;
Examples.prototype.draftPath_join = draftPath_join;
Examples.prototype.draftPath_length = draftPath_length;
Examples.prototype.draftPath_offset = draftPath_offset;
Examples.prototype.draftPath_ops = draftPath_ops;
Examples.prototype.draftPath_reverse = draftPath_reverse;
Examples.prototype.draftPath_shiftalong = draftPath_shiftalong;
Examples.prototype.draftPath_shiftfractionalong = draftPath_shiftfractionalong;
Examples.prototype.draftPath_split = draftPath_split;
Examples.prototype.draftPath_start = draftPath_start;
Examples.prototype.draftPath_translate = draftPath_translate;
Examples.prototype.draftPath_trim = draftPath_trim;
Examples.prototype.draftPlugin_cutonfold = draftPlugin_cutonfold;
Examples.prototype.draftPlugin_dimension = draftPlugin_dimension;
Examples.prototype.draftPlugin_grainline = draftPlugin_grainline;
Examples.prototype.draftPlugin_logo = draftPlugin_logo;
Examples.prototype.draftPlugin_scalebox = draftPlugin_scalebox;
Examples.prototype.draftPlugin_title = draftPlugin_title;
Examples.prototype.draftPoint_angle = draftPoint_angle;
Examples.prototype.draftPoint_attr = draftPoint_attr;
Examples.prototype.draftPoint_clone = draftPoint_clone;
Examples.prototype.draftPoint_copy = draftPoint_copy;
Examples.prototype.draftPoint_dist = draftPoint_dist;
Examples.prototype.draftPoint_dx = draftPoint_dx;
Examples.prototype.draftPoint_dy = draftPoint_dy;
Examples.prototype.draftPoint_flipx = draftPoint_flipx;
Examples.prototype.draftPoint_flipy = draftPoint_flipy;
Examples.prototype.draftPoint_shift = draftPoint_shift;
Examples.prototype.draftPoint_shiftfractiontowards = draftPoint_shiftfractiontowards;
Examples.prototype.draftPoint_shifttowards = draftPoint_shifttowards;
Examples.prototype.draftPoint_shiftoutwards = draftPoint_shiftoutwards;
Examples.prototype.draftPoint_sitson = draftPoint_sitson;
Examples.prototype.draftPoint_rotate = draftPoint_rotate;
Examples.prototype.draftPoint_translate = draftPoint_translate;
Examples.prototype.draftSettings_sa = draftSettings_sa;
Examples.prototype.draftUtils_linesintersect = draftUtils_linesintersect;
Examples.prototype.draftUtils_beamsintersect = draftUtils_beamsintersect;
Examples.prototype.draftUtils_beamintersectsx = draftUtils_beamintersectsx;
Examples.prototype.draftUtils_beamintersectsy = draftUtils_beamintersectsy;
Examples.prototype.draftUtils_lineintersectscurve = draftUtils_lineintersectscurve;
Examples.prototype.draftUtils_curvesintersect = draftUtils_curvesintersect;
Examples.prototype.draftUtils_pointonbeam = draftUtils_pointonbeam;
Examples.prototype.draftUtils_pointonline = draftUtils_pointonline;
Examples.prototype.draftUtils_pointoncurve = draftUtils_pointoncurve;
Examples.prototype.draftUtils_circlesintersect = draftUtils_circlesintersect;
Examples.prototype.draftUtils_beamintersectscircle = draftUtils_beamintersectscircle;
Examples.prototype.draftUtils_lineintersectscircle = draftUtils_lineintersectscircle;
// Add custom snippet
//pattern.on("preRender", function(next) {

View file

@ -1,37 +0,0 @@
import freesewing from "freesewing";
var pathDivide = {
draft: function(part) {
// prettier-ignore
let {Point, points, Path, paths, Snippet, snippets, macro} = part.shorthand();
points.A = new Point(55, 40);
points.B = new Point(10, 70);
points.BCp2 = new Point(40, 20);
points.C = new Point(90, 60);
points.CCp1 = new Point(50, -30);
points.D = new Point(50, 80);
points.DCp1 = new Point(140, 50);
paths.example = new Path()
.move(points.A)
.line(points.B)
.curve(points.BCp2, points.CCp1, points.C)
.curve(points.DCp1, points.DCp1, points.D)
.close();
let i = 1;
for (let p of paths.example.divide()) {
paths[i] = p.attr(
"style",
`stroke-width: 4; stroke-opacity: 0.5; stroke: hsl(${i *
70}, 100%, 50%)`
);
i++;
}
return part;
}
};
export default pathDivide;

View file

@ -1,36 +0,0 @@
import freesewing from "freesewing";
var pathEdge = {
draft: function(part) {
// prettier-ignore
let {Point, points, Path, paths, Snippet, snippets, macro} = part.shorthand();
points.A = new Point(45, 60);
points.B = new Point(10, 30);
points.BCp2 = new Point(40, 20);
points.C = new Point(90, 30);
points.CCp1 = new Point(50, -30);
points.D = new Point(-60, 90);
points.E = new Point(90, 190);
paths.example = new Path()
.move(points.A)
.line(points.B)
.curve(points.BCp2, points.CCp1, points.C)
.curve(points.E, points.D, points.A)
.close();
snippets.a = new Snippet("x", paths.example.edge("topLeft"));
snippets.b = new Snippet("x", paths.example.edge("topRight"));
snippets.c = new Snippet("x", paths.example.edge("bottomLeft"));
snippets.d = new Snippet("x", paths.example.edge("bottomRight"));
snippets.e = new Snippet("x", paths.example.edge("top"));
snippets.f = new Snippet("x", paths.example.edge("left"));
snippets.g = new Snippet("x", paths.example.edge("bottom"));
snippets.h = new Snippet("x", paths.example.edge("right"));
return part;
}
};
export default pathEdge;

View file

@ -1,24 +0,0 @@
import freesewing from "freesewing";
var pathEnd = {
draft: function(part) {
// prettier-ignore
let {Point, points, Path, paths, Snippet, snippets, macro} = part.shorthand();
points.A = new Point(45, 60);
points.B = new Point(10, 30);
points.BCp2 = new Point(40, 20);
points.C = new Point(90, 30);
points.CCp1 = new Point(50, -30);
paths.example = new Path()
.move(points.A)
.line(points.B)
.curve(points.BCp2, points.CCp1, points.C);
snippets.x = new Snippet("x", paths.example.end());
return part;
}
};
export default pathEnd;

View file

@ -1,42 +0,0 @@
import freesewing from "freesewing";
var pathIntersects = {
draft: function(part) {
// prettier-ignore
let {Point, points, Path, paths, Snippet, snippets, macro} = part.shorthand();
points.A = new Point(45, 60);
points.B = new Point(10, 30);
points.BCp2 = new Point(40, 20);
points.C = new Point(90, 30);
points.CCp1 = new Point(50, -30);
points.D = new Point(50, 130);
points.DCp1 = new Point(150, 30);
points._A = new Point(55, 40);
points._B = new Point(0, 55);
points._BCp2 = new Point(40, -20);
points._C = new Point(90, 40);
points._CCp1 = new Point(50, -30);
points._D = new Point(40, 120);
points._DCp1 = new Point(180, 40);
paths.example1 = new Path()
.move(points.A)
.line(points.B)
.curve(points.BCp2, points.CCp1, points.C)
.curve(points.DCp1, points.DCp1, points.D);
paths.example2 = new Path()
.move(points._A)
.line(points._B)
.curve(points._BCp2, points._CCp1, points._C)
.curve(points._DCp1, points._DCp1, points._D);
for (let p of paths.example1.intersects(paths.example2))
snippets[part.getId()] = new Snippet("x", p);
return part;
}
};
export default pathIntersects;

View file

@ -1,35 +0,0 @@
import freesewing from "freesewing";
var pathIntersectsX = {
draft: function(part) {
// prettier-ignore
let {Point, points, Path, paths, Snippet, snippets, macro} = part.shorthand();
points.A = new Point(95, 50);
points.B = new Point(10, 30);
points.BCp2 = new Point(40, 20);
points.C = new Point(90, 30);
points.CCp1 = new Point(50, -30);
points.D = new Point(50, 130);
points.DCp1 = new Point(150, 30);
points.top = new Point(60, -10);
points.bot = new Point(60, 140);
paths.line = new Path()
.move(points.top)
.line(points.bot)
.attr("class", "lining dashed");
paths.example = new Path()
.move(points.A)
.line(points.B)
.curve(points.BCp2, points.CCp1, points.C)
.curve(points.DCp1, points.DCp1, points.D);
for (let p of paths.example.intersectsX(60))
snippets[part.getId()] = new Snippet("x", p);
return part;
}
};
export default pathIntersectsX;

View file

@ -1,34 +0,0 @@
import freesewing from "freesewing";
var pathIntersectsY = {
draft: function(part) {
// prettier-ignore
let {Point, points, Path, paths, Snippet, snippets, macro} = part.shorthand();
points.A = new Point(55, 40);
points.B = new Point(10, 70);
points.BCp2 = new Point(40, 20);
points.C = new Point(90, 60);
points.CCp1 = new Point(50, -30);
points.D = new Point(50, 80);
points.DCp1 = new Point(140, 50);
points.top = new Point(10, 58);
points.bot = new Point(130, 58);
paths.line = new Path()
.move(points.top)
.line(points.bot)
.attr("class", "lining dashed");
paths.example = new Path()
.move(points.A)
.line(points.B)
.curve(points.BCp2, points.CCp1, points.C)
.curve(points.DCp1, points.DCp1, points.D);
for (let p of paths.example.intersectsY(58))
snippets[part.getId()] = new Snippet("x", p);
return part;
}
};
export default pathIntersectsY;

View file

@ -1,32 +0,0 @@
import freesewing from "freesewing";
var pathJoin = {
draft: function(part) {
// prettier-ignore
let {Point, points, Path, paths, Snippet, snippets, macro} = part.shorthand();
points.A = new Point(45, 60);
points.B = new Point(10, 30);
points.BCp2 = new Point(40, 20);
points.C = new Point(90, 30);
points.CCp1 = new Point(50, -30);
paths.path1 = new Path()
.move(points.A)
.line(points.B)
.attr("class", "various");
paths.path2 = new Path()
.move(points.B)
.curve(points.BCp2, points.CCp1, points.C)
.attr("class", "canvas");
paths.joint = paths.path1
.join(paths.path2)
.attr("class", "note lashed stroke-xl");
return part;
}
};
export default pathJoin;

View file

@ -1,38 +0,0 @@
import freesewing from "freesewing";
var pathLength = {
draft: function(part) {
// prettier-ignore
let {Point, points, Path, paths, Snippet, snippets, macro} = part.shorthand();
points.A = new Point(45, 60);
points.B = new Point(10, 30);
points.BCp2 = new Point(40, 20);
points.C = new Point(90, 30);
points.CCp1 = new Point(50, -30);
paths.example = new Path()
.move(points.A)
.line(points.B)
.curve(points.BCp2, points.CCp1, points.C);
macro("pd", {
path: paths.example,
d: -20
});
macro("pd", {
path: new Path().move(points.B).line(points.A),
d: 10
});
macro("pd", {
path: new Path().move(points.B).curve(points.BCp2, points.CCp1, points.C),
d: -10
});
return part;
}
};
export default pathLength;

View file

@ -1,40 +0,0 @@
import freesewing from "freesewing";
import { box } from "./shared";
var pathOffset = {
draft: function(part) {
// prettier-ignore
let {Point, points, Path, paths, Snippet, snippets, macro} = part.shorthand();
points.A = new Point(45, 60);
points.B = new Point(10, 30);
points.BCp2 = new Point(40, 20);
points.C = new Point(90, 30);
points.CCp1 = new Point(50, -30);
paths.example = new Path()
.move(points.A)
.line(points.B)
.curve(points.BCp2, points.CCp1, points.C)
.line(points.A)
.close();
paths.offset = paths.example.offset(-10).attr("class", "interfacing");
paths.lineOffset = new Path()
.move(points.A)
.line(points.B)
.offset(-5)
.attr("class", "various");
paths.curveOffset = new Path()
.move(points.B)
.curve(points.BCp2, points.CCp1, points.C)
.offset(-5)
.attr("class", "canvas");
return part;
}
};
export default pathOffset;

View file

@ -1,62 +0,0 @@
import freesewing from "freesewing";
var pathOps = {
draft: function(part) {
// prettier-ignore
let {Point, points, Path, paths, Snippet, snippets, macro} = part.shorthand();
points.A = new Point(10, 10)
.attr("data-text", "Move to point A")
.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);
paths.example = new Path()
.move(points.A)
.line(points.B)
.curve(points.BCp2, points.CCp1, points.C)
.close();
paths.handle1 = new Path()
.move(points.B)
.line(points.BCp2)
.attr("class", "note dashed");
paths.handle2 = 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")
.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"
)
.attr("data-text-class", "center text-xs");
paths.textClose = new Path()
.move(points.A)
.line(points.C)
.attr("data-text", "Close path")
.attr("data-text-class", "center text-xs");
return part;
}
};
export default pathOps;

View file

@ -1,27 +0,0 @@
import freesewing from "freesewing";
import { box } from "./shared";
var pathReverse = {
draft: function(part) {
// prettier-ignore
let {Point, points, Path, paths, Snippet, snippets, macro} = part.shorthand();
points.B = new Point(10, 30);
points.BCp2 = new Point(40, 20);
points.C = new Point(90, 30);
points.CCp1 = new Point(50, -30);
paths.example = new Path()
.move(points.B)
.curve(points.BCp2, points.CCp1, points.C)
.attr("data-text", "I am the original path");
paths.reverse = paths.example
.reverse()
.attr("data-text", "I am the reversed path");
return part;
}
};
export default pathReverse;

View file

@ -1,37 +0,0 @@
import freesewing from "freesewing";
var pathShiftAlong = {
draft: function(part) {
// prettier-ignore
let {Point, points, Path, paths, Snippet, snippets, macro} = part.shorthand();
points.A = new Point(45, 60);
points.B = new Point(10, 30);
points.BCp2 = new Point(40, 20);
points.C = new Point(90, 30);
points.CCp1 = new Point(50, -30);
paths.example = new Path()
.move(points.A)
.line(points.B)
.curve(points.BCp2, points.CCp1, points.C);
points.X1 = paths.example
.shiftAlong(20)
.attr("data-text", "Shifted 2cm\nalong this path")
.attr("data-text-class", "center")
.attr("data-text-lineheight", 6);
points.X2 = paths.example
.shiftAlong(90)
.attr("data-text", "Shifted 9cm\nalong this path")
.attr("data-text-class", "center")
.attr("data-text-lineheight", 6);
snippets.Xl = new Snippet("x", points.X1);
snippets.X2 = new Snippet("x", points.X2);
return part;
}
};
export default pathShiftAlong;

View file

@ -1,37 +0,0 @@
import freesewing from "freesewing";
var pathShiftFractionAlong = {
draft: function(part) {
// prettier-ignore
let {Point, points, Path, paths, Snippet, snippets, macro} = part.shorthand();
points.A = new Point(45, 60);
points.B = new Point(10, 30);
points.BCp2 = new Point(40, 20);
points.C = new Point(90, 30);
points.CCp1 = new Point(50, -30);
paths.example = new Path()
.move(points.A)
.line(points.B)
.curve(points.BCp2, points.CCp1, points.C);
points.X1 = paths.example
.shiftFractionAlong(0.2)
.attr("data-text", "Shifted 20%\nalong this path")
.attr("data-text-class", "center")
.attr("data-text-lineheight", 6);
points.X2 = paths.example
.shiftFractionAlong(0.9)
.attr("data-text", "Shifted 90%\nalong this path")
.attr("data-text-class", "center")
.attr("data-text-lineheight", 6);
snippets.Xl = new Snippet("x", points.X1);
snippets.X2 = new Snippet("x", points.X2);
return part;
}
};
export default pathShiftFractionAlong;

View file

@ -1,44 +0,0 @@
import freesewing from "freesewing";
var pathSplit = {
draft: function(part) {
// prettier-ignore
let {Point, points, Path, paths, Snippet, snippets, macro} = part.shorthand();
points.A = new Point(45, 60);
points.B = new Point(10, 30);
points.BCp2 = new Point(40, 20);
points.C = new Point(90, 30);
points.CCp1 = new Point(50, -30);
points.D = new Point(50, 130);
points.DCp1 = new Point(150, 30);
paths.example = new Path()
.move(points.A)
.line(points.B)
.curve(points.BCp2, points.CCp1, points.C)
.curve(points.DCp1, points.DCp1, points.D);
paths.example2 = new Path()
.move(points.D)
.curve(points.DCp1, points.DCp1, points.C)
.curve(points.CCp1, points.BCp2, points.B)
.line(points.A);
points.split = paths.example.shiftAlong(20);
snippets.x = new Snippet("x", points.split);
let halves = paths.example2.split(points.split);
for (let i in halves) {
paths[i] = halves[i].attr(
"style",
`stroke-width: 3; stroke-opacity: 0.5; stroke: hsl(${i *
70}, 100%, 50%)`
);
}
return part;
}
};
export default pathSplit;

View file

@ -1,24 +0,0 @@
import freesewing from "freesewing";
var pathStart = {
draft: function(part) {
// prettier-ignore
let {Point, points, Path, paths, Snippet, snippets, macro} = part.shorthand();
points.A = new Point(45, 60);
points.B = new Point(10, 30);
points.BCp2 = new Point(40, 20);
points.C = new Point(90, 30);
points.CCp1 = new Point(50, -30);
paths.example = new Path()
.move(points.A)
.line(points.B)
.curve(points.BCp2, points.CCp1, points.C);
snippets.x = new Snippet("x", paths.example.start());
return part;
}
};
export default pathStart;

View file

@ -1,41 +0,0 @@
var pathTranslate = {
draft: function(part) {
// prettier-ignore
let {Point, points, Path, paths, Snippet, snippets, macro} = part.shorthand();
points.A = new Point(45, 60);
points.B = new Point(10, 30);
points.BCp2 = new Point(40, 20);
points.C = new Point(90, 30);
points.CCp1 = new Point(50, -30);
paths.A = new Path()
.move(points.A)
.line(points.B)
.curve(points.BCp2, points.CCp1, points.C)
.attr("data-text", "Path A")
.attr("data-text-class", "center");
paths.B = paths.A.translate(60, 30).attr(
"data-text",
"with a translate(60,30) transform applied"
);
points.step1 = points.B.shift(0, 60);
points.step2 = points.step1.shift(-90, 30);
macro("ld", {
from: points.B,
to: points.step1,
noStartMarker: true
});
macro("ld", {
from: points.step1,
to: points.step2,
noStartMarker: true
});
return part;
}
};
export default pathTranslate;

View file

@ -1,50 +0,0 @@
var pathTrim = {
draft: function(part) {
// prettier-ignore
let {Point, points, Path, paths, Snippet, snippets, macro} = part.shorthand();
points.center = new Point(0, 0);
points.base = new Point(0, 10);
points.tip = new Point(0, 50);
points.tipCpRight = new Point(30, 50);
points.tipCpLeft = new Point(-30, 50);
paths.example = new Path().move(points.base);
for (let i = 0; i < 4; i++) {
points["base" + i] = points.base.rotate(60 * i, points.center);
points["tip" + i] = points.tip.rotate(60 * i, points.center);
points["tipCpRight" + i] = points.tipCpRight.rotate(
60 * i,
points.center
);
points["tipCpLeft" + i] = points.tipCpLeft.rotate(60 * i, points.center);
if (i < 2) {
paths.example
.line(points["base" + i])
.curve(points["base" + i], points["tipCpLeft" + i], points["tip" + i])
.curve(
points["tipCpRight" + i],
points["base" + i],
points["base" + i]
);
} else {
paths.example
.line(points["base" + i])
.line(points["tip" + i])
.line(points["tipCpRight" + i])
.line(points["base" + i]);
}
}
paths.offset = paths.example
.offset(10)
.attr("class", "lining dotted stroke-sm");
paths.trimmed = paths.offset
.trim()
.attr("class", "various stroke-xl")
.attr("style", "stroke-opacity: 0.5;");
return part;
}
};
export default pathTrim;

View file

@ -0,0 +1,37 @@
export default part => {
let {
Point,
points,
Path,
paths,
Snippet,
snippets,
macro
} = part.shorthand();
points.A = new Point(55, 40);
points.B = new Point(10, 70);
points.BCp2 = new Point(40, 20);
points.C = new Point(90, 60);
points.CCp1 = new Point(50, -30);
points.D = new Point(50, 80);
points.DCp1 = new Point(140, 50);
paths.example = new Path()
.move(points.A)
.line(points.B)
.curve(points.BCp2, points.CCp1, points.C)
.curve(points.DCp1, points.DCp1, points.D)
.close();
let i = 1;
for (let p of paths.example.divide()) {
paths[i] = p.attr(
"style",
`stroke-width: 4; stroke-opacity: 0.5; stroke: hsl(${i * 70}, 100%, 50%)`
);
i++;
}
return part;
};

View file

@ -0,0 +1,37 @@
export default part => {
let {
Point,
points,
Path,
paths,
Snippet,
snippets,
macro
} = part.shorthand();
points.A = new Point(45, 60);
points.B = new Point(10, 30);
points.BCp2 = new Point(40, 20);
points.C = new Point(90, 30);
points.CCp1 = new Point(50, -30);
points.D = new Point(-60, 90);
points.E = new Point(90, 190);
paths.example = new Path()
.move(points.A)
.line(points.B)
.curve(points.BCp2, points.CCp1, points.C)
.curve(points.E, points.D, points.A)
.close();
snippets.a = new Snippet("x", paths.example.edge("topLeft"));
snippets.b = new Snippet("x", paths.example.edge("topRight"));
snippets.c = new Snippet("x", paths.example.edge("bottomLeft"));
snippets.d = new Snippet("x", paths.example.edge("bottomRight"));
snippets.e = new Snippet("x", paths.example.edge("top"));
snippets.f = new Snippet("x", paths.example.edge("left"));
snippets.g = new Snippet("x", paths.example.edge("bottom"));
snippets.h = new Snippet("x", paths.example.edge("right"));
return part;
};

View file

@ -0,0 +1,25 @@
export default part => {
let {
Point,
points,
Path,
paths,
Snippet,
snippets,
macro
} = part.shorthand();
points.A = new Point(45, 60);
points.B = new Point(10, 30);
points.BCp2 = new Point(40, 20);
points.C = new Point(90, 30);
points.CCp1 = new Point(50, -30);
paths.example = new Path()
.move(points.A)
.line(points.B)
.curve(points.BCp2, points.CCp1, points.C);
snippets.x = new Snippet("x", paths.example.end());
return part;
};

View file

@ -0,0 +1,43 @@
export default part => {
let {
Point,
points,
Path,
paths,
Snippet,
snippets,
macro
} = part.shorthand();
points.A = new Point(45, 60);
points.B = new Point(10, 30);
points.BCp2 = new Point(40, 20);
points.C = new Point(90, 30);
points.CCp1 = new Point(50, -30);
points.D = new Point(50, 130);
points.DCp1 = new Point(150, 30);
points._A = new Point(55, 40);
points._B = new Point(0, 55);
points._BCp2 = new Point(40, -20);
points._C = new Point(90, 40);
points._CCp1 = new Point(50, -30);
points._D = new Point(40, 120);
points._DCp1 = new Point(180, 40);
paths.example1 = new Path()
.move(points.A)
.line(points.B)
.curve(points.BCp2, points.CCp1, points.C)
.curve(points.DCp1, points.DCp1, points.D);
paths.example2 = new Path()
.move(points._A)
.line(points._B)
.curve(points._BCp2, points._CCp1, points._C)
.curve(points._DCp1, points._DCp1, points._D);
for (let p of paths.example1.intersects(paths.example2))
snippets[part.getId()] = new Snippet("x", p);
return part;
};

View file

@ -0,0 +1,36 @@
export default part => {
let {
Point,
points,
Path,
paths,
Snippet,
snippets,
macro
} = part.shorthand();
points.A = new Point(95, 50);
points.B = new Point(10, 30);
points.BCp2 = new Point(40, 20);
points.C = new Point(90, 30);
points.CCp1 = new Point(50, -30);
points.D = new Point(50, 130);
points.DCp1 = new Point(150, 30);
points.top = new Point(60, -10);
points.bot = new Point(60, 140);
paths.line = new Path()
.move(points.top)
.line(points.bot)
.attr("class", "lining dashed");
paths.example = new Path()
.move(points.A)
.line(points.B)
.curve(points.BCp2, points.CCp1, points.C)
.curve(points.DCp1, points.DCp1, points.D);
for (let p of paths.example.intersectsX(60))
snippets[part.getId()] = new Snippet("x", p);
return part;
};

View file

@ -0,0 +1,35 @@
export default part => {
let {
Point,
points,
Path,
paths,
Snippet,
snippets,
macro
} = part.shorthand();
points.A = new Point(55, 40);
points.B = new Point(10, 70);
points.BCp2 = new Point(40, 20);
points.C = new Point(90, 60);
points.CCp1 = new Point(50, -30);
points.D = new Point(50, 80);
points.DCp1 = new Point(140, 50);
points.top = new Point(10, 58);
points.bot = new Point(130, 58);
paths.line = new Path()
.move(points.top)
.line(points.bot)
.attr("class", "lining dashed");
paths.example = new Path()
.move(points.A)
.line(points.B)
.curve(points.BCp2, points.CCp1, points.C)
.curve(points.DCp1, points.DCp1, points.D);
for (let p of paths.example.intersectsY(58))
snippets[part.getId()] = new Snippet("x", p);
return part;
};

View file

@ -0,0 +1,33 @@
export default part => {
let {
Point,
points,
Path,
paths,
Snippet,
snippets,
macro
} = part.shorthand();
points.A = new Point(45, 60);
points.B = new Point(10, 30);
points.BCp2 = new Point(40, 20);
points.C = new Point(90, 30);
points.CCp1 = new Point(50, -30);
paths.path1 = new Path()
.move(points.A)
.line(points.B)
.attr("class", "various");
paths.path2 = new Path()
.move(points.B)
.curve(points.BCp2, points.CCp1, points.C)
.attr("class", "canvas");
paths.joint = paths.path1
.join(paths.path2)
.attr("class", "note lashed stroke-xl");
return part;
};

View file

@ -0,0 +1,39 @@
export default part => {
let {
Point,
points,
Path,
paths,
Snippet,
snippets,
macro
} = part.shorthand();
points.A = new Point(45, 60);
points.B = new Point(10, 30);
points.BCp2 = new Point(40, 20);
points.C = new Point(90, 30);
points.CCp1 = new Point(50, -30);
paths.example = new Path()
.move(points.A)
.line(points.B)
.curve(points.BCp2, points.CCp1, points.C);
macro("pd", {
path: paths.example,
d: -20
});
macro("pd", {
path: new Path().move(points.B).line(points.A),
d: 10
});
macro("pd", {
path: new Path().move(points.B).curve(points.BCp2, points.CCp1, points.C),
d: -10
});
return part;
};

View file

@ -0,0 +1,42 @@
import { box } from "./shared";
export default part => {
let {
Point,
points,
Path,
paths,
Snippet,
snippets,
macro
} = part.shorthand();
points.A = new Point(45, 60);
points.B = new Point(10, 30);
points.BCp2 = new Point(40, 20);
points.C = new Point(90, 30);
points.CCp1 = new Point(50, -30);
paths.example = new Path()
.move(points.A)
.line(points.B)
.curve(points.BCp2, points.CCp1, points.C)
.line(points.A)
.close();
paths.offset = paths.example.offset(-10).attr("class", "interfacing");
paths.lineOffset = new Path()
.move(points.A)
.line(points.B)
.offset(-5)
.attr("class", "various");
paths.curveOffset = new Path()
.move(points.B)
.curve(points.BCp2, points.CCp1, points.C)
.offset(-5)
.attr("class", "canvas");
return part;
};

View file

@ -0,0 +1,63 @@
export default part => {
let {
Point,
points,
Path,
paths,
Snippet,
snippets,
macro
} = part.shorthand();
points.A = new Point(10, 10)
.attr("data-text", "Move to point A")
.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);
paths.example = new Path()
.move(points.A)
.line(points.B)
.curve(points.BCp2, points.CCp1, points.C)
.close();
paths.handle1 = new Path()
.move(points.B)
.line(points.BCp2)
.attr("class", "note dashed");
paths.handle2 = 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")
.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"
)
.attr("data-text-class", "center text-xs");
paths.textClose = new Path()
.move(points.A)
.line(points.C)
.attr("data-text", "Close path")
.attr("data-text-class", "center text-xs");
return part;
};

View file

@ -0,0 +1,29 @@
import { box } from "./shared";
export default part => {
let {
Point,
points,
Path,
paths,
Snippet,
snippets,
macro
} = part.shorthand();
points.B = new Point(10, 30);
points.BCp2 = new Point(40, 20);
points.C = new Point(90, 30);
points.CCp1 = new Point(50, -30);
paths.example = new Path()
.move(points.B)
.curve(points.BCp2, points.CCp1, points.C)
.attr("data-text", "I am the original path");
paths.reverse = paths.example
.reverse()
.attr("data-text", "I am the reversed path");
return part;
};

View file

@ -0,0 +1,38 @@
export default part => {
let {
Point,
points,
Path,
paths,
Snippet,
snippets,
macro
} = part.shorthand();
points.A = new Point(45, 60);
points.B = new Point(10, 30);
points.BCp2 = new Point(40, 20);
points.C = new Point(90, 30);
points.CCp1 = new Point(50, -30);
paths.example = new Path()
.move(points.A)
.line(points.B)
.curve(points.BCp2, points.CCp1, points.C);
points.X1 = paths.example
.shiftAlong(20)
.attr("data-text", "Shifted 2cm\nalong this path")
.attr("data-text-class", "center")
.attr("data-text-lineheight", 6);
points.X2 = paths.example
.shiftAlong(90)
.attr("data-text", "Shifted 9cm\nalong this path")
.attr("data-text-class", "center")
.attr("data-text-lineheight", 6);
snippets.Xl = new Snippet("x", points.X1);
snippets.X2 = new Snippet("x", points.X2);
return part;
};

View file

@ -0,0 +1,31 @@
export default part => {
// prettier-ignore
let {Point, points, Path, paths, Snippet, snippets, macro} = part.shorthand();
points.A = new Point(45, 60);
points.B = new Point(10, 30);
points.BCp2 = new Point(40, 20);
points.C = new Point(90, 30);
points.CCp1 = new Point(50, -30);
paths.example = new Path()
.move(points.A)
.line(points.B)
.curve(points.BCp2, points.CCp1, points.C);
points.X1 = paths.example
.shiftFractionAlong(0.2)
.attr("data-text", "Shifted 20%\nalong this path")
.attr("data-text-class", "center")
.attr("data-text-lineheight", 6);
points.X2 = paths.example
.shiftFractionAlong(0.9)
.attr("data-text", "Shifted 90%\nalong this path")
.attr("data-text-class", "center")
.attr("data-text-lineheight", 6);
snippets.Xl = new Snippet("x", points.X1);
snippets.X2 = new Snippet("x", points.X2);
return part;
};

View file

@ -0,0 +1,44 @@
export default part => {
let {
Point,
points,
Path,
paths,
Snippet,
snippets,
macro
} = part.shorthand();
points.A = new Point(45, 60);
points.B = new Point(10, 30);
points.BCp2 = new Point(40, 20);
points.C = new Point(90, 30);
points.CCp1 = new Point(50, -30);
points.D = new Point(50, 130);
points.DCp1 = new Point(150, 30);
paths.example = new Path()
.move(points.A)
.line(points.B)
.curve(points.BCp2, points.CCp1, points.C)
.curve(points.DCp1, points.DCp1, points.D);
paths.example2 = new Path()
.move(points.D)
.curve(points.DCp1, points.DCp1, points.C)
.curve(points.CCp1, points.BCp2, points.B)
.line(points.A);
points.split = paths.example.shiftAlong(20);
snippets.x = new Snippet("x", points.split);
let halves = paths.example2.split(points.split);
for (let i in halves) {
paths[i] = halves[i].attr(
"style",
`stroke-width: 3; stroke-opacity: 0.5; stroke: hsl(${i * 70}, 100%, 50%)`
);
}
return part;
};

View file

@ -0,0 +1,25 @@
export default part => {
let {
Point,
points,
Path,
paths,
Snippet,
snippets,
macro
} = part.shorthand();
points.A = new Point(45, 60);
points.B = new Point(10, 30);
points.BCp2 = new Point(40, 20);
points.C = new Point(90, 30);
points.CCp1 = new Point(50, -30);
paths.example = new Path()
.move(points.A)
.line(points.B)
.curve(points.BCp2, points.CCp1, points.C);
snippets.x = new Snippet("x", paths.example.start());
return part;
};

View file

@ -0,0 +1,44 @@
export default part => {
let {
Point,
points,
Path,
paths,
Snippet,
snippets,
macro
} = part.shorthand();
points.A = new Point(45, 60);
points.B = new Point(10, 30);
points.BCp2 = new Point(40, 20);
points.C = new Point(90, 30);
points.CCp1 = new Point(50, -30);
paths.A = new Path()
.move(points.A)
.line(points.B)
.curve(points.BCp2, points.CCp1, points.C)
.attr("data-text", "Path A")
.attr("data-text-class", "center");
paths.B = paths.A.translate(60, 30).attr(
"data-text",
"with a translate(60,30) transform applied"
);
points.step1 = points.B.shift(0, 60);
points.step2 = points.step1.shift(-90, 30);
macro("ld", {
from: points.B,
to: points.step1,
noStartMarker: true
});
macro("ld", {
from: points.step1,
to: points.step2,
noStartMarker: true
});
return part;
};

View file

@ -0,0 +1,50 @@
export default part => {
let {
Point,
points,
Path,
paths,
Snippet,
snippets,
macro
} = part.shorthand();
points.center = new Point(0, 0);
points.base = new Point(0, 10);
points.tip = new Point(0, 50);
points.tipCpRight = new Point(30, 50);
points.tipCpLeft = new Point(-30, 50);
paths.example = new Path().move(points.base);
for (let i = 0; i < 4; i++) {
points["base" + i] = points.base.rotate(60 * i, points.center);
points["tip" + i] = points.tip.rotate(60 * i, points.center);
points["tipCpRight" + i] = points.tipCpRight.rotate(60 * i, points.center);
points["tipCpLeft" + i] = points.tipCpLeft.rotate(60 * i, points.center);
if (i < 2) {
paths.example
.line(points["base" + i])
.curve(points["base" + i], points["tipCpLeft" + i], points["tip" + i])
.curve(
points["tipCpRight" + i],
points["base" + i],
points["base" + i]
);
} else {
paths.example
.line(points["base" + i])
.line(points["tip" + i])
.line(points["tipCpRight" + i])
.line(points["base" + i]);
}
}
paths.offset = paths.example
.offset(10)
.attr("class", "lining dotted stroke-sm");
paths.trimmed = paths.offset
.trim()
.attr("class", "various stroke-xl")
.attr("style", "stroke-opacity: 0.5;");
return part;
};

View file

@ -1,30 +0,0 @@
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;

View file

@ -1,56 +0,0 @@
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;

View file

@ -1,20 +0,0 @@
import freesewing from "freesewing";
var pluginGrainline = {
draft: function(part) {
// prettier-ignore
let {Point, points, macro} = part.shorthand();
points.grainlineFrom = new Point(10, 10);
points.grainlineTo = new Point(100, 10);
macro("grainline", {
from: points.grainlineFrom,
to: points.grainlineTo
});
return part;
}
};
export default pluginGrainline;

View file

@ -1,25 +0,0 @@
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;

View file

@ -1,16 +0,0 @@
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;

View file

@ -1,29 +0,0 @@
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;

View file

@ -0,0 +1,23 @@
export default part => {
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;
};

View file

@ -0,0 +1,49 @@
export default part => {
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;
};

View file

@ -0,0 +1,13 @@
export default part => {
let { Point, points, macro } = part.shorthand();
points.grainlineFrom = new Point(10, 10);
points.grainlineTo = new Point(100, 10);
macro("grainline", {
from: points.grainlineFrom,
to: points.grainlineTo
});
return part;
};

View file

@ -0,0 +1,20 @@
export default part => {
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;
};

View file

@ -0,0 +1,11 @@
export default part => {
let { Point, points, Path, paths, macro } = part.shorthand();
points.anchor = new Point(0, 0);
macro("scalebox", {
at: points.anchor
});
return part;
};

View file

@ -0,0 +1,24 @@
export default part => {
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;
};

View file

@ -1,58 +0,0 @@
import freesewing from "freesewing";
var pointAngle = {
draft: function(part) {
// prettier-ignore
let {Point, points, Path, paths, Snippet, snippets} = part.shorthand();
points.sun = new Point(40, 40);
points.moon1 = new Point(70, 40)
.attr("data-text", "0")
.attr("data-text-class", "text-xl");
points.moon2 = new Point(40, 10)
.attr("data-text", 90)
.attr("data-text-class", "text-xl");
points.moon3 = new Point(10, 40)
.attr("data-text", 180)
.attr("data-text-class", "text-xl");
points.moon4 = new Point(40, 70)
.attr("data-text", 270)
.attr("data-text-class", "text-xl");
points.moon5 = points.moon1.rotate(-45, points.sun);
points.moon5
.attr("data-text", points.sun.angle(points.moon5))
.attr("data-text-class", "text-xl");
paths.moon1 = new Path()
.move(points.sun)
.line(points.moon1)
.attr("class", "dashed note");
paths.moon2 = new Path()
.move(points.sun)
.line(points.moon2)
.attr("class", "dashed note");
paths.moon3 = new Path()
.move(points.sun)
.line(points.moon3)
.attr("class", "dashed note");
paths.moon4 = new Path()
.move(points.sun)
.line(points.moon4)
.attr("class", "dashed note");
paths.moon5 = new Path()
.move(points.sun)
.line(points.moon5)
.attr("class", "dashed note");
snippets.notch = new Snippet("notch", points.sun);
snippets.notch1 = new Snippet("x", points.moon1);
snippets.notch2 = new Snippet("x", points.moon2);
snippets.notch3 = new Snippet("x", points.moon3);
snippets.notch4 = new Snippet("x", points.moon4);
snippets.notch5 = new Snippet("x", points.moon5);
return part;
}
};
export default pointAngle;

View file

@ -1,22 +0,0 @@
import freesewing from "freesewing";
import { box } from "./shared";
var pointAttr = {
draft: function(part) {
// prettier-ignore
let {Point, points, Snippet, snippets} = part.shorthand();
box(part);
points.anchor = new Point(50, 25)
.attr("data-text", "Hello world!\nThis is\na line break.")
.attr("data-text-class", "text-xl center")
.attr("data-text-lineheight", 10);
snippets.notch = new Snippet("x", points.anchor);
return part;
}
};
export default pointAttr;

View file

@ -1,23 +0,0 @@
import freesewing from "freesewing";
import { box } from "./shared";
var pointClone = {
draft: function(part) {
// prettier-ignore
let {Point, points, Snippet, snippets} = part.shorthand();
box(part);
points.A = new Point(25, 25)
.attr("data-text", "Point A")
.attr("data-text-class", "text-xl")
.attr("data-text-fill-opacity", "0.5");
points.B = points.A.clone().attr("data-text", "Point B");
snippets.x = new Snippet("x", points.A);
return part;
}
};
export default pointClone;

View file

@ -1,22 +0,0 @@
import freesewing from "freesewing";
import { box } from "./shared";
var pointCopy = {
draft: function(part) {
// prettier-ignore
let {Point, points, Snippet, snippets} = part.shorthand();
box(part);
points.A = new Point(50, 25)
.attr("data-text", "Point A")
.attr("data-text-class", "text-xl");
points.B = points.A.copy().attr("data-text", "Point B");
snippets.x = new Snippet("x", points.A);
return part;
}
};
export default pointCopy;

View file

@ -1,23 +0,0 @@
import freesewing from "freesewing";
var pointDist = {
draft: function(part) {
// prettier-ignore
let {Point, points, Snippet, snippets, macro} = part.shorthand();
points.from = new Point(10, 10);
points.to = new Point(90, 40);
macro("ld", {
from: points.from,
to: points.to
});
snippets.notch1 = new Snippet("x", points.from);
snippets.notch2 = new Snippet("x", points.to);
return part;
}
};
export default pointDist;

View file

@ -1,24 +0,0 @@
import freesewing from "freesewing";
var pointDx = {
draft: function(part) {
// prettier-ignore
let {Point, points, Snippet, snippets, macro} = part.shorthand();
points.from = new Point(10, 10);
points.to = new Point(90, 40);
macro("hd", {
from: points.from,
to: points.to,
y: 25
});
snippets.notch1 = new Snippet("x", points.from);
snippets.notch2 = new Snippet("x", points.to);
return part;
}
};
export default pointDx;

View file

@ -1,24 +0,0 @@
import freesewing from "freesewing";
var pointDy = {
draft: function(part) {
// prettier-ignore
let {Point, points, Snippet, snippets, macro} = part.shorthand();
points.from = new Point(10, 10);
points.to = new Point(90, 40);
macro("vd", {
from: points.to,
to: points.from,
x: 50
});
snippets.notch1 = new Snippet("x", points.from);
snippets.notch2 = new Snippet("x", points.to);
return part;
}
};
export default pointDy;

View file

@ -1,55 +0,0 @@
import freesewing from "freesewing";
var pointFlipX = {
draft: function(part) {
// prettier-ignore
let {Point, points, Path, paths, Snippet, snippets, macro} = part.shorthand();
points.top = new Point(50, 10);
points.out1 = new Point(70, 30);
points.in1 = new Point(55, 35);
points.out2 = new Point(75, 50);
points.in2 = new Point(60, 55);
points.out3 = new Point(80, 70);
points.in3 = new Point(55, 70);
points.trunkOut = new Point(55, 80);
points.trunkIn = new Point(50, 80);
points._out1 = points.out1.flipX(points.top);
points._in1 = points.in1.flipX(points.top);
points._out2 = points.out2.flipX(points.top);
points._in2 = points.in2.flipX(points.top);
points._out3 = points.out3.flipX(points.top);
points._in3 = points.in3.flipX(points.top);
points._trunkOut = points.trunkOut.flipX(points.top);
points.bottom = new Point(50, 80);
paths.tree = new Path()
.move(points.top)
.line(points.out1)
.line(points.in1)
.line(points.out2)
.line(points.in2)
.line(points.out3)
.line(points.in3)
.line(points.trunkOut)
.line(points._trunkOut)
.line(points._in3)
.line(points._out3)
.line(points._in2)
.line(points._out2)
.line(points._in1)
.line(points._out1)
.close();
paths.mirror = new Path()
.move(points.top)
.line(points.bottom)
.attr("class", "note dashed");
return part;
}
};
export default pointFlipX;

View file

@ -1,84 +0,0 @@
import freesewing from "freesewing";
var pointFlipX = {
draft: function(part) {
// prettier-ignore
let {Point, points, Path, paths, Snippet, snippets, macro} = part.shorthand();
points.start = new Point(0, 50);
points.churchTowerWallLeft = new Point(10, 50);
points.churchTowerRoofLeft = new Point(10, 30);
points.churchTowerTop = new Point(15, 10);
points.churchTowerRoofRight = new Point(20, 30);
points.churchRoofRight = new Point(50, 30);
points.churchWallRight = new Point(50, 50);
points.houseWallLeft = new Point(65, 50);
points.houseRoofLeft = new Point(65, 35);
points.houseRoofTop = new Point(75, 25);
points.houseRoofRight = new Point(85, 35);
points.houseWallRight = new Point(85, 50);
points.end = new Point(95, 50);
points.mirror = new Point(0, 60);
points.mirrorLineEnd = new Point(95, 60);
points._start = points.start.flipY(points.mirror);
points._churchTowerWallLeft = points.churchTowerWallLeft.flipY(
points.mirror
);
points._churchTowerRoofLeft = points.churchTowerRoofLeft.flipY(
points.mirror
);
points._churchTowerTop = points.churchTowerTop.flipY(points.mirror);
points._churchTowerRoofRight = points.churchTowerRoofRight.flipY(
points.mirror
);
points._churchRoofRight = points.churchRoofRight.flipY(points.mirror);
points._churchWallRight = points.churchWallRight.flipY(points.mirror);
points._houseWallLeft = points.houseWallLeft.flipY(points.mirror);
points._houseRoofLeft = points.houseRoofLeft.flipY(points.mirror);
points._houseRoofTop = points.houseRoofTop.flipY(points.mirror);
points._houseRoofRight = points.houseRoofRight.flipY(points.mirror);
points._houseWallRight = points.houseWallRight.flipY(points.mirror);
points._end = points.end.flipY(points.mirror);
paths.skylineTop = new Path()
.move(points.start)
.line(points.churchTowerWallLeft)
.line(points.churchTowerRoofLeft)
.line(points.churchTowerTop)
.line(points.churchTowerRoofRight)
.line(points.churchRoofRight)
.line(points.churchWallRight)
.line(points.houseWallLeft)
.line(points.houseRoofLeft)
.line(points.houseRoofTop)
.line(points.houseRoofRight)
.line(points.houseWallRight)
.line(points.end);
paths.skylineBottom = new Path()
.move(points._start)
.line(points._churchTowerWallLeft)
.line(points._churchTowerRoofLeft)
.line(points._churchTowerTop)
.line(points._churchTowerRoofRight)
.line(points._churchRoofRight)
.line(points._churchWallRight)
.line(points._houseWallLeft)
.line(points._houseRoofLeft)
.line(points._houseRoofTop)
.line(points._houseRoofRight)
.line(points._houseWallRight)
.line(points._end);
paths.mirrorLine = new Path()
.move(points.mirror)
.line(points.mirrorLineEnd)
.attr("class", "note dashed");
return part;
}
};
export default pointFlipX;

View file

@ -1,24 +0,0 @@
import freesewing from "freesewing";
var pointRotate = {
draft: function(part) {
// prettier-ignore
let {Point, points, Path, paths, Snippet, snippets} = part.shorthand();
points.sun = new Point(40, 40);
snippets.sun = new Snippet("notch", points.sun);
points.moon = new Point(70, 40);
let angle = 0;
let step = 360 / 36;
for (let i = 1; i < 37; i++) {
let angle = step * i;
points[`moon${i}`] = points.moon.rotate(angle, points.sun);
paths[`moon${i}`] = new Path().move(points.sun).line(points[`moon${i}`]);
snippets[`moon${i}`] = new Snippet("x", points[`moon${i}`]);
}
return part;
}
};
export default pointRotate;

View file

@ -1,31 +0,0 @@
import freesewing from "freesewing";
var pointShift = {
draft: function(part) {
// prettier-ignore
let {Point, points, Snippet, snippets, macro} = part.shorthand();
points.A = new Point(90, 40)
.attr("data-text", "Point A")
.attr("data-text-class", "right");
points.B = points.A.shift(155, 70)
.attr(
"data-text",
"Point B is point A shifted 7cm\nat a 155 degree angle"
)
.attr("data-text-lineheight", 6);
snippets.A = new Snippet("x", points.A);
snippets.B = new Snippet("x", points.B);
macro("ld", {
from: points.B,
to: points.A,
d: -10
});
return part;
}
};
export default pointShift;

View file

@ -1,43 +0,0 @@
import freesewing from "freesewing";
var pointShiftFractionTowards = {
draft: function(part) {
// prettier-ignore
let {Point, points, Path, paths, Snippet, snippets, macro} = part.shorthand();
points.A = new Point(90, 70).attr("data-text", "Point A");
points.B = new Point(10, 10).attr("data-text", "Point B");
points.C = points.A.shiftFractionTowards(points.B, 0.5)
.attr(
"data-text",
"Point C is point A shifted 50%\nin the direction of point B"
)
.attr("data-text-class", "center")
.attr("data-text-lineheight", 6);
snippets.A = new Snippet("x", points.A);
snippets.B = new Snippet("x", points.B);
snippets.C = new Snippet("x", points.C);
paths.direction = new Path()
.move(points.A)
.line(points.B)
.attr("class", "note dashed");
macro("ld", {
from: points.C,
to: points.A,
d: -10
});
macro("ld", {
from: points.B,
to: points.A,
d: 20
});
return part;
}
};
export default pointShiftFractionTowards;

View file

@ -1,33 +0,0 @@
import freesewing from "freesewing";
var pointShiftOutwards = {
draft: function(part) {
// prettier-ignore
let {Point, points, Path, paths, Snippet, snippets, macro} = part.shorthand();
points.A = new Point(90, 70).attr("data-text", "Point A");
points.B = new Point(10, 10).attr("data-text", "Point B");
points.C = points.A.shiftOutwards(points.B, 30)
.attr("data-text", "Point C is point A shifted 3cm\nbeyond point B")
.attr("data-text-lineheight", 6);
snippets.A = new Snippet("x", points.A);
snippets.B = new Snippet("x", points.B);
snippets.C = new Snippet("x", points.C);
paths.direction = new Path()
.move(points.A)
.line(points.C)
.attr("class", "note dashed");
macro("ld", {
from: points.C,
to: points.B,
d: -10
});
return part;
}
};
export default pointShiftOutwards;

View file

@ -1,37 +0,0 @@
import freesewing from "freesewing";
var pointShiftTowards = {
draft: function(part) {
// prettier-ignore
let {Point, points, Path, paths, Snippet, snippets, macro} = part.shorthand();
points.A = new Point(90, 70).attr("data-text", "Point A");
points.B = new Point(10, 10).attr("data-text", "Point B");
points.C = points.A.shiftTowards(points.B, 35)
.attr(
"data-text",
"Point C is point A shifted 3.5cm\nin the direction of point B"
)
.attr("data-text-class", "center")
.attr("data-text-lineheight", 6);
snippets.A = new Snippet("x", points.A);
snippets.B = new Snippet("x", points.B);
snippets.C = new Snippet("x", points.C);
paths.direction = new Path()
.move(points.A)
.line(points.B)
.attr("class", "note dashed");
macro("ld", {
from: points.C,
to: points.A,
d: -10
});
return part;
}
};
export default pointShiftTowards;

View file

@ -1,25 +0,0 @@
import freesewing from "freesewing";
import { box } from "./shared";
var pointDx = {
draft: function(part) {
// prettier-ignore
let {Point, points, Snippet, snippets, macro} = part.shorthand();
box(part);
let s;
for (let i = 0; i < 10; i++) {
points[`a${i}`] = new Point(i * 10, 40);
points[`b${i}`] = new Point(i * 10, i * 8);
if (points[`a${i}`].sitsOn(points[`b${i}`])) s = "notch";
else s = "x";
snippets[`b${i}`] = new Snippet(s, points[`b${i}`]);
snippets[`a${i}`] = new Snippet(s, points[`a${i}`]);
}
return part;
}
};
export default pointDx;

View file

@ -1,30 +0,0 @@
var pointTranslate = {
draft: function(part) {
// prettier-ignore
let {Point, points, Snippet, snippets, macro} = part.shorthand();
points.A = new Point(10, 10).attr("data-text", "Point A");
points.B = points.A.translate(120, 60)
.attr(
"data-text",
"Point B is point A with a\ntranslate(120, 60)\ntransform applied"
)
.attr("data-text-class", "right")
.attr("data-text-dy", -6)
.attr("data-text-lineheight", 6);
snippets.A = new Snippet("x", points.A);
snippets.B = new Snippet("x", points.B);
macro("ld", {
from: points.A,
to: points.B,
text: "translate(120,60)",
noStartMarker: true
});
return part;
}
};
export default pointTranslate;

View file

@ -0,0 +1,51 @@
export default part => {
let { Point, points, Path, paths, Snippet, snippets } = part.shorthand();
points.sun = new Point(40, 40);
points.moon1 = new Point(70, 40)
.attr("data-text", "0")
.attr("data-text-class", "text-xl");
points.moon2 = new Point(40, 10)
.attr("data-text", 90)
.attr("data-text-class", "text-xl");
points.moon3 = new Point(10, 40)
.attr("data-text", 180)
.attr("data-text-class", "text-xl");
points.moon4 = new Point(40, 70)
.attr("data-text", 270)
.attr("data-text-class", "text-xl");
points.moon5 = points.moon1.rotate(-45, points.sun);
points.moon5
.attr("data-text", points.sun.angle(points.moon5))
.attr("data-text-class", "text-xl");
paths.moon1 = new Path()
.move(points.sun)
.line(points.moon1)
.attr("class", "dashed note");
paths.moon2 = new Path()
.move(points.sun)
.line(points.moon2)
.attr("class", "dashed note");
paths.moon3 = new Path()
.move(points.sun)
.line(points.moon3)
.attr("class", "dashed note");
paths.moon4 = new Path()
.move(points.sun)
.line(points.moon4)
.attr("class", "dashed note");
paths.moon5 = new Path()
.move(points.sun)
.line(points.moon5)
.attr("class", "dashed note");
snippets.notch = new Snippet("notch", points.sun);
snippets.notch1 = new Snippet("x", points.moon1);
snippets.notch2 = new Snippet("x", points.moon2);
snippets.notch3 = new Snippet("x", points.moon3);
snippets.notch4 = new Snippet("x", points.moon4);
snippets.notch5 = new Snippet("x", points.moon5);
return part;
};

View file

@ -0,0 +1,16 @@
import { box } from "./shared";
export default part => {
let { Point, points, Snippet, snippets } = part.shorthand();
box(part);
points.anchor = new Point(50, 25)
.attr("data-text", "Hello world!\nThis is\na line break.")
.attr("data-text-class", "text-xl center")
.attr("data-text-lineheight", 10);
snippets.notch = new Snippet("x", points.anchor);
return part;
};

View file

@ -0,0 +1,17 @@
import { box } from "./shared";
export default part => {
let { Point, points, Snippet, snippets } = part.shorthand();
box(part);
points.A = new Point(25, 25)
.attr("data-text", "Point A")
.attr("data-text-class", "text-xl")
.attr("data-text-fill-opacity", "0.5");
points.B = points.A.clone().attr("data-text", "Point B");
snippets.x = new Snippet("x", points.A);
return part;
};

View file

@ -0,0 +1,16 @@
import { box } from "./shared";
export default part => {
let { Point, points, Snippet, snippets } = part.shorthand();
box(part);
points.A = new Point(50, 25)
.attr("data-text", "Point A")
.attr("data-text-class", "text-xl");
points.B = points.A.copy().attr("data-text", "Point B");
snippets.x = new Snippet("x", points.A);
return part;
};

View file

@ -0,0 +1,16 @@
export default part => {
let { Point, points, Snippet, snippets, macro } = part.shorthand();
points.from = new Point(10, 10);
points.to = new Point(90, 40);
macro("ld", {
from: points.from,
to: points.to
});
snippets.notch1 = new Snippet("x", points.from);
snippets.notch2 = new Snippet("x", points.to);
return part;
};

View file

@ -0,0 +1,17 @@
export default part => {
let { Point, points, Snippet, snippets, macro } = part.shorthand();
points.from = new Point(10, 10);
points.to = new Point(90, 40);
macro("hd", {
from: points.from,
to: points.to,
y: 25
});
snippets.notch1 = new Snippet("x", points.from);
snippets.notch2 = new Snippet("x", points.to);
return part;
};

View file

@ -0,0 +1,17 @@
export default part => {
let { Point, points, Snippet, snippets, macro } = part.shorthand();
points.from = new Point(10, 10);
points.to = new Point(90, 40);
macro("vd", {
from: points.to,
to: points.from,
x: 50
});
snippets.notch1 = new Snippet("x", points.from);
snippets.notch2 = new Snippet("x", points.to);
return part;
};

View file

@ -0,0 +1,56 @@
export default part => {
let {
Point,
points,
Path,
paths,
Snippet,
snippets,
macro
} = part.shorthand();
points.top = new Point(50, 10);
points.out1 = new Point(70, 30);
points.in1 = new Point(55, 35);
points.out2 = new Point(75, 50);
points.in2 = new Point(60, 55);
points.out3 = new Point(80, 70);
points.in3 = new Point(55, 70);
points.trunkOut = new Point(55, 80);
points.trunkIn = new Point(50, 80);
points._out1 = points.out1.flipX(points.top);
points._in1 = points.in1.flipX(points.top);
points._out2 = points.out2.flipX(points.top);
points._in2 = points.in2.flipX(points.top);
points._out3 = points.out3.flipX(points.top);
points._in3 = points.in3.flipX(points.top);
points._trunkOut = points.trunkOut.flipX(points.top);
points.bottom = new Point(50, 80);
paths.tree = new Path()
.move(points.top)
.line(points.out1)
.line(points.in1)
.line(points.out2)
.line(points.in2)
.line(points.out3)
.line(points.in3)
.line(points.trunkOut)
.line(points._trunkOut)
.line(points._in3)
.line(points._out3)
.line(points._in2)
.line(points._out2)
.line(points._in1)
.line(points._out1)
.close();
paths.mirror = new Path()
.move(points.top)
.line(points.bottom)
.attr("class", "note dashed");
return part;
};

View file

@ -0,0 +1,81 @@
export default part => {
let {
Point,
points,
Path,
paths,
Snippet,
snippets,
macro
} = part.shorthand();
points.start = new Point(0, 50);
points.churchTowerWallLeft = new Point(10, 50);
points.churchTowerRoofLeft = new Point(10, 30);
points.churchTowerTop = new Point(15, 10);
points.churchTowerRoofRight = new Point(20, 30);
points.churchRoofRight = new Point(50, 30);
points.churchWallRight = new Point(50, 50);
points.houseWallLeft = new Point(65, 50);
points.houseRoofLeft = new Point(65, 35);
points.houseRoofTop = new Point(75, 25);
points.houseRoofRight = new Point(85, 35);
points.houseWallRight = new Point(85, 50);
points.end = new Point(95, 50);
points.mirror = new Point(0, 60);
points.mirrorLineEnd = new Point(95, 60);
points._start = points.start.flipY(points.mirror);
points._churchTowerWallLeft = points.churchTowerWallLeft.flipY(points.mirror);
points._churchTowerRoofLeft = points.churchTowerRoofLeft.flipY(points.mirror);
points._churchTowerTop = points.churchTowerTop.flipY(points.mirror);
points._churchTowerRoofRight = points.churchTowerRoofRight.flipY(
points.mirror
);
points._churchRoofRight = points.churchRoofRight.flipY(points.mirror);
points._churchWallRight = points.churchWallRight.flipY(points.mirror);
points._houseWallLeft = points.houseWallLeft.flipY(points.mirror);
points._houseRoofLeft = points.houseRoofLeft.flipY(points.mirror);
points._houseRoofTop = points.houseRoofTop.flipY(points.mirror);
points._houseRoofRight = points.houseRoofRight.flipY(points.mirror);
points._houseWallRight = points.houseWallRight.flipY(points.mirror);
points._end = points.end.flipY(points.mirror);
paths.skylineTop = new Path()
.move(points.start)
.line(points.churchTowerWallLeft)
.line(points.churchTowerRoofLeft)
.line(points.churchTowerTop)
.line(points.churchTowerRoofRight)
.line(points.churchRoofRight)
.line(points.churchWallRight)
.line(points.houseWallLeft)
.line(points.houseRoofLeft)
.line(points.houseRoofTop)
.line(points.houseRoofRight)
.line(points.houseWallRight)
.line(points.end);
paths.skylineBottom = new Path()
.move(points._start)
.line(points._churchTowerWallLeft)
.line(points._churchTowerRoofLeft)
.line(points._churchTowerTop)
.line(points._churchTowerRoofRight)
.line(points._churchRoofRight)
.line(points._churchWallRight)
.line(points._houseWallLeft)
.line(points._houseRoofLeft)
.line(points._houseRoofTop)
.line(points._houseRoofRight)
.line(points._houseWallRight)
.line(points._end);
paths.mirrorLine = new Path()
.move(points.mirror)
.line(points.mirrorLineEnd)
.attr("class", "note dashed");
return part;
};

View file

@ -0,0 +1,17 @@
export default part => {
let { Point, points, Path, paths, Snippet, snippets } = part.shorthand();
points.sun = new Point(40, 40);
snippets.sun = new Snippet("notch", points.sun);
points.moon = new Point(70, 40);
let angle = 0;
let step = 360 / 36;
for (let i = 1; i < 37; i++) {
let angle = step * i;
points[`moon${i}`] = points.moon.rotate(angle, points.sun);
paths[`moon${i}`] = new Path().move(points.sun).line(points[`moon${i}`]);
snippets[`moon${i}`] = new Snippet("x", points[`moon${i}`]);
}
return part;
};

View file

@ -0,0 +1,21 @@
export default part => {
let { Point, points, Snippet, snippets, macro } = part.shorthand();
points.A = new Point(90, 40)
.attr("data-text", "Point A")
.attr("data-text-class", "right");
points.B = points.A.shift(155, 70)
.attr("data-text", "Point B is point A shifted 7cm\nat a 155 degree angle")
.attr("data-text-lineheight", 6);
snippets.A = new Snippet("x", points.A);
snippets.B = new Snippet("x", points.B);
macro("ld", {
from: points.B,
to: points.A,
d: -10
});
return part;
};

View file

@ -0,0 +1,44 @@
export default part => {
let {
Point,
points,
Path,
paths,
Snippet,
snippets,
macro
} = part.shorthand();
points.A = new Point(90, 70).attr("data-text", "Point A");
points.B = new Point(10, 10).attr("data-text", "Point B");
points.C = points.A.shiftFractionTowards(points.B, 0.5)
.attr(
"data-text",
"Point C is point A shifted 50%\nin the direction of point B"
)
.attr("data-text-class", "center")
.attr("data-text-lineheight", 6);
snippets.A = new Snippet("x", points.A);
snippets.B = new Snippet("x", points.B);
snippets.C = new Snippet("x", points.C);
paths.direction = new Path()
.move(points.A)
.line(points.B)
.attr("class", "note dashed");
macro("ld", {
from: points.C,
to: points.A,
d: -10
});
macro("ld", {
from: points.B,
to: points.A,
d: 20
});
return part;
};

View file

@ -0,0 +1,34 @@
export default part => {
let {
Point,
points,
Path,
paths,
Snippet,
snippets,
macro
} = part.shorthand();
points.A = new Point(90, 70).attr("data-text", "Point A");
points.B = new Point(10, 10).attr("data-text", "Point B");
points.C = points.A.shiftOutwards(points.B, 30)
.attr("data-text", "Point C is point A shifted 3cm\nbeyond point B")
.attr("data-text-lineheight", 6);
snippets.A = new Snippet("x", points.A);
snippets.B = new Snippet("x", points.B);
snippets.C = new Snippet("x", points.C);
paths.direction = new Path()
.move(points.A)
.line(points.C)
.attr("class", "note dashed");
macro("ld", {
from: points.C,
to: points.B,
d: -10
});
return part;
};

View file

@ -0,0 +1,38 @@
export default part => {
let {
Point,
points,
Path,
paths,
Snippet,
snippets,
macro
} = part.shorthand();
points.A = new Point(90, 70).attr("data-text", "Point A");
points.B = new Point(10, 10).attr("data-text", "Point B");
points.C = points.A.shiftTowards(points.B, 35)
.attr(
"data-text",
"Point C is point A shifted 3.5cm\nin the direction of point B"
)
.attr("data-text-class", "center")
.attr("data-text-lineheight", 6);
snippets.A = new Snippet("x", points.A);
snippets.B = new Snippet("x", points.B);
snippets.C = new Snippet("x", points.C);
paths.direction = new Path()
.move(points.A)
.line(points.B)
.attr("class", "note dashed");
macro("ld", {
from: points.C,
to: points.A,
d: -10
});
return part;
};

View file

@ -0,0 +1,20 @@
import { box } from "./shared";
export default part => {
// prettier-ignore
let {Point, points, Snippet, snippets, macro} = part.shorthand();
box(part);
let s;
for (let i = 0; i < 10; i++) {
points[`a${i}`] = new Point(i * 10, 40);
points[`b${i}`] = new Point(i * 10, i * 8);
if (points[`a${i}`].sitsOn(points[`b${i}`])) s = "notch";
else s = "x";
snippets[`b${i}`] = new Snippet(s, points[`b${i}`]);
snippets[`a${i}`] = new Snippet(s, points[`a${i}`]);
}
return part;
};

View file

@ -0,0 +1,25 @@
export default part => {
let { Point, points, Snippet, snippets, macro } = part.shorthand();
points.A = new Point(10, 10).attr("data-text", "Point A");
points.B = points.A.translate(120, 60)
.attr(
"data-text",
"Point B is point A with a\ntranslate(120, 60)\ntransform applied"
)
.attr("data-text-class", "right")
.attr("data-text-dy", -6)
.attr("data-text-lineheight", 6);
snippets.A = new Snippet("x", points.A);
snippets.B = new Snippet("x", points.B);
macro("ld", {
from: points.A,
to: points.B,
text: "translate(120,60)",
noStartMarker: true
});
return part;
};

View file

@ -1,28 +0,0 @@
import freesewing from "freesewing";
var pathOffset = {
draft: function(part) {
// prettier-ignore
let {Point, points, Path, paths, Snippet, snippets, macro} = part.shorthand();
points.A = new Point(45, 60);
points.B = new Point(10, 30);
points.BCp2 = new Point(40, 20);
points.C = new Point(90, 30);
points.CCp1 = new Point(50, -30);
paths.example = new Path()
.move(points.A)
.line(points.B)
.curve(points.BCp2, points.CCp1, points.C)
.line(points.A)
.close()
.attr("class", "fabric");
paths.offset = paths.example.offset(-10).attr("class", "fabric sa");
return part;
}
};
export default pathOffset;

View file

@ -0,0 +1,22 @@
export default part => {
// prettier-ignore
let {Point, points, Path, paths, Snippet, snippets, macro} = part.shorthand();
points.A = new Point(45, 60);
points.B = new Point(10, 30);
points.BCp2 = new Point(40, 20);
points.C = new Point(90, 30);
points.CCp1 = new Point(50, -30);
paths.example = new Path()
.move(points.A)
.line(points.B)
.curve(points.BCp2, points.CCp1, points.C)
.line(points.A)
.close()
.attr("class", "fabric");
paths.offset = paths.example.offset(-10).attr("class", "fabric sa");
return part;
};

View file

@ -1,53 +0,0 @@
import freesewing from "freesewing";
var utilsBeamIntersectsCircle = {
draft: function(part) {
// prettier-ignore
let {debug, Point, points, Path, paths, Snippet, snippets, utils} = part.shorthand();
points.A = new Point(45, 45)
.attr("data-circle", 35)
.attr("data-circle-class", "fabric");
points.B = new Point(5, 50);
points.C = new Point(25, 30);
points.D = new Point(5, 65);
points.E = new Point(65, 5);
points.F = new Point(15, 75);
points.G = new Point(75, 15);
paths.line1 = new Path().move(points.B).line(points.C);
paths.line2 = new Path().move(points.D).line(points.E);
paths.line3 = new Path().move(points.F).line(points.G);
let intersections1 = utils.beamIntersectsCircle(
points.A,
points.A.attributes.get("data-circle"),
points.B,
points.C
);
let intersections2 = utils.beamIntersectsCircle(
points.A,
points.A.attributes.get("data-circle"),
points.D,
points.E,
"y"
);
let intersections3 = utils.beamIntersectsCircle(
points.A,
points.A.attributes.get("data-circle"),
points.F,
points.G
);
snippets.first1 = new Snippet("bnotch", intersections1[0]);
snippets.second1 = new Snippet("x", intersections1[1]);
snippets.first2 = new Snippet("bnotch", intersections2[0]);
snippets.second2 = new Snippet("x", intersections2[1]);
snippets.first3 = new Snippet("bnotch", intersections3[0]);
snippets.second3 = new Snippet("x", intersections3[1]);
return part;
}
};
export default utilsBeamIntersectsCircle;

View file

@ -1,27 +0,0 @@
import freesewing from "freesewing";
var utilsBeamIntersectsX = {
draft: function(part) {
// prettier-ignore
let {debug, Point, points, Path, paths, Snippet, snippets, utils} = part.shorthand();
points.A = new Point(10, 10);
points.B = new Point(50, 40);
paths.AB = new Path().move(points.A).line(points.B);
snippets.X = new Snippet(
"x",
utils.beamIntersectsX(points.A, points.B, 40)
);
paths.help = new Path()
.move(new Point(40, 0))
.line(new Point(40, 50))
.attr("class", "note dashed");
return part;
}
};
export default utilsBeamIntersectsX;

View file

@ -1,27 +0,0 @@
import freesewing from "freesewing";
var utilsBeamIntersectsY = {
draft: function(part) {
// prettier-ignore
let {debug, Point, points, Path, paths, Snippet, snippets, utils} = part.shorthand();
points.A = new Point(10, 10);
points.B = new Point(50, 40);
paths.AB = new Path().move(points.A).line(points.B);
snippets.X = new Snippet(
"x",
utils.beamIntersectsY(points.A, points.B, 30)
);
paths.help = new Path()
.move(new Point(0, 30))
.line(new Point(50, 30))
.attr("class", "note dashed");
return part;
}
};
export default utilsBeamIntersectsY;

View file

@ -1,25 +0,0 @@
import freesewing from "freesewing";
var utilsBeamsIntersect = {
draft: function(part) {
// prettier-ignore
let {debug, Point, points, Path, paths, Snippet, snippets, utils} = part.shorthand();
points.A = new Point(10, 10);
points.B = new Point(50, 40);
points.C = new Point(45, 20);
points.D = new Point(60, 15);
paths.AB = new Path().move(points.A).line(points.B);
paths.CD = new Path().move(points.C).line(points.D);
snippets.X = new Snippet(
"x",
utils.beamsIntersect(points.A, points.B, points.C, points.D)
);
return part;
}
};
export default utilsBeamsIntersect;

View file

@ -1,44 +0,0 @@
import freesewing from "freesewing";
var utilsCirclesIntersect = {
draft: function(part) {
// prettier-ignore
let {debug, Point, points, Path, paths, Snippet, snippets, utils} = part.shorthand();
points.A = new Point(10, 10)
.attr("data-circle", 15)
.attr("data-circle-class", "fabric");
points.B = new Point(30, 30)
.attr("data-circle", 35)
.attr("data-circle-class", "fabric");
points.C = new Point(90, 10)
.attr("data-circle", 15)
.attr("data-circle-class", "various");
points.D = new Point(110, 30)
.attr("data-circle", 35)
.attr("data-circle-class", "various");
let intersections1 = utils.circlesIntersect(
points.A,
points.A.attributes.get("data-circle"),
points.B,
points.B.attributes.get("data-circle")
);
let intersections2 = utils.circlesIntersect(
points.C,
points.C.attributes.get("data-circle"),
points.D,
points.D.attributes.get("data-circle"),
"y"
);
snippets.first1 = new Snippet("bnotch", intersections1[0]);
snippets.second1 = new Snippet("x", intersections1[1]);
snippets.first2 = new Snippet("bnotch", intersections2[0]);
snippets.second2 = new Snippet("x", intersections2[1]);
return part;
}
};
export default utilsCirclesIntersect;

View file

@ -1,40 +0,0 @@
import freesewing from "freesewing";
var utilsCurvesIntersect = {
draft: function(part) {
// prettier-ignore
let {debug, Point, points, Path, paths, Snippet, snippets, utils} = part.shorthand();
points.A = new Point(10, 10);
points.Acp = new Point(310, 40);
points.B = new Point(110, 70);
points.Bcp = new Point(-210, 40);
points.C = new Point(20, -5);
points.Ccp = new Point(60, 300);
points.D = new Point(100, 85);
points.Dcp = new Point(70, -220);
paths.curveA = new Path()
.move(points.A)
.curve(points.Acp, points.Bcp, points.B);
paths.curveB = new Path()
.move(points.C)
.curve(points.Ccp, points.Dcp, points.D);
for (let p of utils.curvesIntersect(
points.A,
points.Acp,
points.Bcp,
points.B,
points.C,
points.Ccp,
points.Dcp,
points.D
))
snippets[part.getId()] = new Snippet("x", p);
return part;
}
};
export default utilsCurvesIntersect;

View file

@ -1,52 +0,0 @@
import freesewing from "freesewing";
var utilsLineIntersectsCircle = {
draft: function(part) {
// prettier-ignore
let {debug, Point, points, Path, paths, Snippet, snippets, utils} = part.shorthand();
points.A = new Point(45, 45)
.attr("data-circle", 35)
.attr("data-circle-class", "fabric");
points.B = new Point(5, 50);
points.C = new Point(25, 30);
points.D = new Point(5, 65);
points.E = new Point(65, 5);
points.F = new Point(15, 75);
points.G = new Point(75, 15);
paths.line1 = new Path().move(points.B).line(points.C);
paths.line2 = new Path().move(points.D).line(points.E);
paths.line3 = new Path().move(points.F).line(points.G);
let intersections1 = utils.lineIntersectsCircle(
points.A,
points.A.attributes.get("data-circle"),
points.B,
points.C
);
let intersections2 = utils.lineIntersectsCircle(
points.A,
points.A.attributes.get("data-circle"),
points.D,
points.E,
"y"
);
let intersections3 = utils.lineIntersectsCircle(
points.A,
points.A.attributes.get("data-circle"),
points.F,
points.G
);
snippets.first1 = new Snippet("bnotch", intersections1[0]);
snippets.first2 = new Snippet("bnotch", intersections2[0]);
snippets.second2 = new Snippet("x", intersections2[1]);
snippets.first3 = new Snippet("bnotch", intersections3[0]);
snippets.second3 = new Snippet("x", intersections3[1]);
return part;
}
};
export default utilsLineIntersectsCircle;

View file

@ -1,33 +0,0 @@
import freesewing from "freesewing";
var utilsLineIntersectsCurve = {
draft: function(part) {
// prettier-ignore
let {debug, Point, points, Path, paths, Snippet, snippets, utils} = part.shorthand();
points.A = new Point(10, 10);
points.Acp = new Point(310, 40);
points.B = new Point(110, 70);
points.Bcp = new Point(-210, 40);
points.E = new Point(20, -5);
points.D = new Point(100, 85);
paths.curve = new Path()
.move(points.A)
.curve(points.Acp, points.Bcp, points.B);
paths.line = new Path().move(points.E).line(points.D);
for (let p of freesewing.utils.lineIntersectsCurve(
points.D,
points.E,
points.A,
points.Acp,
points.Bcp,
points.B
))
snippets[part.getId()] = new Snippet("x", p);
return part;
}
};
export default utilsLineIntersectsCurve;

View file

@ -1,25 +0,0 @@
import freesewing from "freesewing";
var utilsLinesIntersect = {
draft: function(part) {
// prettier-ignore
let {debug, Point, points, Path, paths, Snippet, snippets, utils} = part.shorthand();
points.A = new Point(10, 10);
points.B = new Point(50, 40);
points.C = new Point(15, 30);
points.D = new Point(60, 15);
paths.AB = new Path().move(points.A).line(points.B);
paths.CD = new Path().move(points.C).line(points.D);
snippets.X = new Snippet(
"x",
utils.linesIntersect(points.A, points.B, points.C, points.D)
);
return part;
}
};
export default utilsLinesIntersect;

View file

@ -1,52 +0,0 @@
import freesewing from "freesewing";
var utilsPointOnBeam = {
draft: function(part) {
// prettier-ignore
let {debug, Point, points, Path, paths, Snippet, snippets, utils} = part.shorthand();
points.from1 = new Point(10, 10);
points.to1 = new Point(90, 60);
points.from2 = new Point(10, 30);
points.to2 = new Point(90, 80);
points.b1 = new Point(170, 110);
points.b2 = new Point(170, 130);
let scatter = [];
for (let i = 1; i < 36; i++) {
for (let j = 1; j < 27; j++) {
scatter.push(new Point(i * 5, j * 5));
}
}
let snippet;
for (let point of scatter) {
if (utils.pointOnBeam(points.from1, points.to1, point)) snippet = "notch";
else snippet = "x";
snippets[part.getId()] = new Snippet(snippet, point);
if (utils.pointOnBeam(points.from2, points.to2, point, 0.01))
snippet = "notch";
else snippet = "x";
snippets[part.getId()] = new Snippet(snippet, point);
}
paths.line1 = new Path()
.move(points.from1)
.line(points.to1)
.attr("class", "fabric stroke-lg");
paths.lne1 = new Path()
.move(points.to1)
.line(points.b1)
.attr("class", "fabric dashed");
paths.line2 = new Path()
.move(points.from2)
.line(points.to2)
.attr("class", "fabric stroke-lg");
paths.lne2 = new Path()
.move(points.to2)
.line(points.b2)
.attr("class", "fabric dashed");
return part;
}
};
export default utilsPointOnBeam;

View file

@ -1,43 +0,0 @@
import freesewing from "freesewing";
var utilsPointOnCurve = {
draft: function(part) {
// prettier-ignore
let {debug, Point, points, Path, paths, Snippet, snippets, utils} = part.shorthand();
points.start = new Point(10, 10);
points.cp1 = new Point(90, 10);
points.cp2 = new Point(10, 60);
points.end = new Point(90, 60);
let scatter = [];
for (let i = 1; i < 19; i++) {
for (let j = 1; j < 14; j++) {
scatter.push(new Point(i * 5, j * 5));
}
}
let snippet;
for (let point of scatter) {
if (
utils.pointOnCurve(
points.start,
points.cp1,
points.cp2,
points.end,
point
)
)
snippet = "notch";
else snippet = "x";
snippets[part.getId()] = new Snippet(snippet, point);
}
paths.curve = new Path()
.move(points.start)
.curve(points.cp1, points.cp2, points.end)
.attr("class", "fabric stroke-lg");
return part;
}
};
export default utilsPointOnCurve;

View file

@ -1,52 +0,0 @@
import freesewing from "freesewing";
var utilsPointOnLine = {
draft: function(part) {
// prettier-ignore
let {debug, Point, points, Path, paths, Snippet, snippets, utils} = part.shorthand();
points.from1 = new Point(10, 10);
points.to1 = new Point(90, 60);
points.from2 = new Point(10, 30);
points.to2 = new Point(90, 80);
points.b1 = new Point(170, 110);
points.b2 = new Point(170, 130);
let scatter = [];
for (let i = 1; i < 36; i++) {
for (let j = 1; j < 27; j++) {
scatter.push(new Point(i * 5, j * 5));
}
}
let snippet;
for (let point of scatter) {
if (utils.pointOnLine(points.from1, points.to1, point)) snippet = "notch";
else snippet = "x";
snippets[part.getId()] = new Snippet(snippet, point);
if (utils.pointOnLine(points.from2, points.to2, point, 0.01))
snippet = "notch";
else snippet = "x";
snippets[part.getId()] = new Snippet(snippet, point);
}
paths.line1 = new Path()
.move(points.from1)
.line(points.to1)
.attr("class", "fabric stroke-lg");
paths.lne1 = new Path()
.move(points.to1)
.line(points.b1)
.attr("class", "fabric dashed");
paths.line2 = new Path()
.move(points.from2)
.line(points.to2)
.attr("class", "fabric stroke-lg");
paths.lne2 = new Path()
.move(points.to2)
.line(points.b2)
.attr("class", "fabric dashed");
return part;
}
};
export default utilsPointOnLine;

View file

@ -0,0 +1,55 @@
export default part => {
let {
debug,
Point,
points,
Path,
paths,
Snippet,
snippets,
utils
} = part.shorthand();
points.A = new Point(45, 45)
.attr("data-circle", 35)
.attr("data-circle-class", "fabric");
points.B = new Point(5, 50);
points.C = new Point(25, 30);
points.D = new Point(5, 65);
points.E = new Point(65, 5);
points.F = new Point(15, 75);
points.G = new Point(75, 15);
paths.line1 = new Path().move(points.B).line(points.C);
paths.line2 = new Path().move(points.D).line(points.E);
paths.line3 = new Path().move(points.F).line(points.G);
let intersections1 = utils.beamIntersectsCircle(
points.A,
points.A.attributes.get("data-circle"),
points.B,
points.C
);
let intersections2 = utils.beamIntersectsCircle(
points.A,
points.A.attributes.get("data-circle"),
points.D,
points.E,
"y"
);
let intersections3 = utils.beamIntersectsCircle(
points.A,
points.A.attributes.get("data-circle"),
points.F,
points.G
);
snippets.first1 = new Snippet("bnotch", intersections1[0]);
snippets.second1 = new Snippet("x", intersections1[1]);
snippets.first2 = new Snippet("bnotch", intersections2[0]);
snippets.second2 = new Snippet("x", intersections2[1]);
snippets.first3 = new Snippet("bnotch", intersections3[0]);
snippets.second3 = new Snippet("x", intersections3[1]);
return part;
};

View file

@ -0,0 +1,26 @@
export default part => {
let {
debug,
Point,
points,
Path,
paths,
Snippet,
snippets,
utils
} = part.shorthand();
points.A = new Point(10, 10);
points.B = new Point(50, 40);
paths.AB = new Path().move(points.A).line(points.B);
snippets.X = new Snippet("x", utils.beamIntersectsX(points.A, points.B, 40));
paths.help = new Path()
.move(new Point(40, 0))
.line(new Point(40, 50))
.attr("class", "note dashed");
return part;
};

View file

@ -0,0 +1,26 @@
export default part => {
let {
debug,
Point,
points,
Path,
paths,
Snippet,
snippets,
utils
} = part.shorthand();
points.A = new Point(10, 10);
points.B = new Point(50, 40);
paths.AB = new Path().move(points.A).line(points.B);
snippets.X = new Snippet("x", utils.beamIntersectsY(points.A, points.B, 30));
paths.help = new Path()
.move(new Point(0, 30))
.line(new Point(50, 30))
.attr("class", "note dashed");
return part;
};

View file

@ -0,0 +1,27 @@
export default part => {
let {
debug,
Point,
points,
Path,
paths,
Snippet,
snippets,
utils
} = part.shorthand();
points.A = new Point(10, 10);
points.B = new Point(50, 40);
points.C = new Point(45, 20);
points.D = new Point(60, 15);
paths.AB = new Path().move(points.A).line(points.B);
paths.CD = new Path().move(points.C).line(points.D);
snippets.X = new Snippet(
"x",
utils.beamsIntersect(points.A, points.B, points.C, points.D)
);
return part;
};

Some files were not shown because too many files have changed in this diff Show more