1
0
Fork 0

art: Prettier code

This commit is contained in:
Joost De Cock 2019-01-26 17:50:36 +01:00
parent cb10ffef15
commit 0c24881616
55 changed files with 579 additions and 439 deletions

View file

@ -1 +0,0 @@
../freesewing/dist/browser.js

View file

@ -68,64 +68,150 @@ var pattern = new freesewing.Pattern({ version: version, ...config }).with(
);
pattern.draft = function() {
if (this.needs('pointAttr')) this.parts.pointAttr = this.draftPointAttr(new pattern.Part());
if (this.needs('pointDist')) this.parts.pointDist = this.draftPointDist(new pattern.Part());
if (this.needs('pointDx')) this.parts.pointDx = this.draftPointDx(new pattern.Part());
if (this.needs('pointDy')) this.parts.pointDy = this.draftPointDy(new pattern.Part());
if (this.needs('pointAngle')) this.parts.pointAngle = this.draftPointAngle(new pattern.Part());
if (this.needs('pointRotate')) this.parts.pointRotate = this.draftPointRotate(new pattern.Part());
if (this.needs('pointCopy')) this.parts.pointCopy = this.draftPointCopy(new pattern.Part());
if (this.needs('pointFlipX')) this.parts.pointFlipX = this.draftPointFlipX(new pattern.Part());
if (this.needs('pointFlipY')) this.parts.pointFlipY = this.draftPointFlipY(new pattern.Part());
if (this.needs('pointShift')) this.parts.pointShift = this.draftPointShift(new pattern.Part());
if (this.needs('pointShiftTowards')) this.parts.pointShiftTowards = this.draftPointShiftTowards(new pattern.Part());
if (this.needs('pointShiftFractionTowards')) this.parts.pointShiftFractionTowards = this.draftPointShiftFractionTowards(new pattern.Part());
if (this.needs('pointShiftOutwards')) this.parts.pointShiftOutwards = this.draftPointShiftOutwards(new pattern.Part());
if (this.needs('pointTranslate')) this.parts.pointTranslate = this.draftPointTranslate(new pattern.Part());
if (this.needs('pointSitsOn')) this.parts.pointSitsOn = this.draftPointSitsOn(new pattern.Part());
if (this.needs('pointClone')) this.parts.pointClone = this.draftPointClone(new pattern.Part());
if (this.needs("pointAttr"))
this.parts.pointAttr = this.draftPointAttr(new pattern.Part());
if (this.needs("pointDist"))
this.parts.pointDist = this.draftPointDist(new pattern.Part());
if (this.needs("pointDx"))
this.parts.pointDx = this.draftPointDx(new pattern.Part());
if (this.needs("pointDy"))
this.parts.pointDy = this.draftPointDy(new pattern.Part());
if (this.needs("pointAngle"))
this.parts.pointAngle = this.draftPointAngle(new pattern.Part());
if (this.needs("pointRotate"))
this.parts.pointRotate = this.draftPointRotate(new pattern.Part());
if (this.needs("pointCopy"))
this.parts.pointCopy = this.draftPointCopy(new pattern.Part());
if (this.needs("pointFlipX"))
this.parts.pointFlipX = this.draftPointFlipX(new pattern.Part());
if (this.needs("pointFlipY"))
this.parts.pointFlipY = this.draftPointFlipY(new pattern.Part());
if (this.needs("pointShift"))
this.parts.pointShift = this.draftPointShift(new pattern.Part());
if (this.needs("pointShiftTowards"))
this.parts.pointShiftTowards = this.draftPointShiftTowards(
new pattern.Part()
);
if (this.needs("pointShiftFractionTowards"))
this.parts.pointShiftFractionTowards = this.draftPointShiftFractionTowards(
new pattern.Part()
);
if (this.needs("pointShiftOutwards"))
this.parts.pointShiftOutwards = this.draftPointShiftOutwards(
new pattern.Part()
);
if (this.needs("pointTranslate"))
this.parts.pointTranslate = this.draftPointTranslate(new pattern.Part());
if (this.needs("pointSitsOn"))
this.parts.pointSitsOn = this.draftPointSitsOn(new pattern.Part());
if (this.needs("pointClone"))
this.parts.pointClone = this.draftPointClone(new pattern.Part());
if (this.needs('pathOps')) this.parts.pathOps = this.draftPathOps(new pattern.Part());
if (this.needs('pathAttr')) this.parts.pathAttr = this.draftPathAttr(new pattern.Part());
if (this.needs('pathOffset')) this.parts.pathOffset = this.draftPathOffset(new pattern.Part());
if (this.needs('pathLength')) this.parts.pathLength = this.draftPathLength(new pattern.Part());
if (this.needs('pathStart')) this.parts.pathStart = this.draftPathStart(new pattern.Part());
if (this.needs('pathEnd')) this.parts.pathEnd = this.draftPathEnd(new pattern.Part());
if (this.needs('pathClone')) this.parts.pathClone = this.draftPathClone(new pattern.Part());
if (this.needs('pathJoin')) this.parts.pathJoin = this.draftPathJoin(new pattern.Part());
if (this.needs('pathReverse')) this.parts.pathReverse = this.draftPathReverse(new pattern.Part());
if (this.needs('pathShiftAlong')) this.parts.pathShiftAlong = this.draftPathShiftAlong(new pattern.Part());
if (this.needs('pathShiftFractionAlong')) this.parts.pathShiftFractionAlong = this.draftPathShiftFractionAlong(new pattern.Part());
if (this.needs('pathEdge')) this.parts.pathEdge = this.draftPathEdge(new pattern.Part());
if (this.needs('pathTrim')) this.parts.pathTrim = this.draftPathTrim(new pattern.Part());
if (this.needs('pathIntersectsX')) this.parts.pathIntersectsX = this.draftPathIntersectsX(new pattern.Part());
if (this.needs('pathIntersectsY')) this.parts.pathIntersectsY = this.draftPathIntersectsY(new pattern.Part());
if (this.needs('pathIntersects')) this.parts.pathIntersects = this.draftPathIntersects(new pattern.Part());
if (this.needs('pathDivide')) this.parts.pathDivide = this.draftPathDivide(new pattern.Part());
if (this.needs('pathSplit')) this.parts.pathSplit = this.draftPathSplit(new pattern.Part());
if (this.needs('pathTranslate')) this.parts.pathTranslate = this.draftPathTranslate(new pattern.Part());
if (this.needs("pathOps"))
this.parts.pathOps = this.draftPathOps(new pattern.Part());
if (this.needs("pathAttr"))
this.parts.pathAttr = this.draftPathAttr(new pattern.Part());
if (this.needs("pathOffset"))
this.parts.pathOffset = this.draftPathOffset(new pattern.Part());
if (this.needs("pathLength"))
this.parts.pathLength = this.draftPathLength(new pattern.Part());
if (this.needs("pathStart"))
this.parts.pathStart = this.draftPathStart(new pattern.Part());
if (this.needs("pathEnd"))
this.parts.pathEnd = this.draftPathEnd(new pattern.Part());
if (this.needs("pathClone"))
this.parts.pathClone = this.draftPathClone(new pattern.Part());
if (this.needs("pathJoin"))
this.parts.pathJoin = this.draftPathJoin(new pattern.Part());
if (this.needs("pathReverse"))
this.parts.pathReverse = this.draftPathReverse(new pattern.Part());
if (this.needs("pathShiftAlong"))
this.parts.pathShiftAlong = this.draftPathShiftAlong(new pattern.Part());
if (this.needs("pathShiftFractionAlong"))
this.parts.pathShiftFractionAlong = this.draftPathShiftFractionAlong(
new pattern.Part()
);
if (this.needs("pathEdge"))
this.parts.pathEdge = this.draftPathEdge(new pattern.Part());
if (this.needs("pathTrim"))
this.parts.pathTrim = this.draftPathTrim(new pattern.Part());
if (this.needs("pathIntersectsX"))
this.parts.pathIntersectsX = this.draftPathIntersectsX(new pattern.Part());
if (this.needs("pathIntersectsY"))
this.parts.pathIntersectsY = this.draftPathIntersectsY(new pattern.Part());
if (this.needs("pathIntersects"))
this.parts.pathIntersects = this.draftPathIntersects(new pattern.Part());
if (this.needs("pathDivide"))
this.parts.pathDivide = this.draftPathDivide(new pattern.Part());
if (this.needs("pathSplit"))
this.parts.pathSplit = this.draftPathSplit(new pattern.Part());
if (this.needs("pathTranslate"))
this.parts.pathTranslate = this.draftPathTranslate(new pattern.Part());
if (this.needs('utilsLinesIntersect')) this.parts.utilsLinesIntersect = this.draftUtilsLinesIntersect(new pattern.Part());
if (this.needs('utilsBeamsIntersect')) this.parts.utilsBeamsIntersect = this.draftUtilsBeamsIntersect(new pattern.Part());
if (this.needs('utilsBeamIntersectsX')) this.parts.utilsBeamIntersectsX = this.draftUtilsBeamIntersectsX(new pattern.Part());
if (this.needs('utilsBeamIntersectsY')) this.parts.utilsBeamIntersectsY = this.draftUtilsBeamIntersectsY(new pattern.Part());
if (this.needs('utilsLineIntersectsCurve')) this.parts.utilsLineIntersectsCurve = this.draftUtilsLineIntersectsCurve(new pattern.Part());
if (this.needs('utilsCurvesIntersect')) this.parts.utilsCurvesIntersect = this.draftUtilsCurvesIntersect(new pattern.Part());
if (this.needs('utilsPointOnLine')) this.parts.utilsPointOnLine = this.draftUtilsPointOnLine(new pattern.Part());
if (this.needs('utilsPointOnBeam')) this.parts.utilsPointOnBeam = this.draftUtilsPointOnBeam(new pattern.Part());
if (this.needs('utilsPointOnCurve')) this.parts.utilsPointOnCurve = this.draftUtilsPointOnCurve(new pattern.Part());
if (this.needs('utilsCirclesIntersect')) this.parts.utilsCirclesIntersect = this.draftUtilsCirclesIntersect(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("utilsLinesIntersect"))
this.parts.utilsLinesIntersect = this.draftUtilsLinesIntersect(
new pattern.Part()
);
if (this.needs("utilsBeamsIntersect"))
this.parts.utilsBeamsIntersect = this.draftUtilsBeamsIntersect(
new pattern.Part()
);
if (this.needs("utilsBeamIntersectsX"))
this.parts.utilsBeamIntersectsX = this.draftUtilsBeamIntersectsX(
new pattern.Part()
);
if (this.needs("utilsBeamIntersectsY"))
this.parts.utilsBeamIntersectsY = this.draftUtilsBeamIntersectsY(
new pattern.Part()
);
if (this.needs("utilsLineIntersectsCurve"))
this.parts.utilsLineIntersectsCurve = this.draftUtilsLineIntersectsCurve(
new pattern.Part()
);
if (this.needs("utilsCurvesIntersect"))
this.parts.utilsCurvesIntersect = this.draftUtilsCurvesIntersect(
new pattern.Part()
);
if (this.needs("utilsPointOnLine"))
this.parts.utilsPointOnLine = this.draftUtilsPointOnLine(
new pattern.Part()
);
if (this.needs("utilsPointOnBeam"))
this.parts.utilsPointOnBeam = this.draftUtilsPointOnBeam(
new pattern.Part()
);
if (this.needs("utilsPointOnCurve"))
this.parts.utilsPointOnCurve = this.draftUtilsPointOnCurve(
new pattern.Part()
);
if (this.needs("utilsCirclesIntersect"))
this.parts.utilsCirclesIntersect = this.draftUtilsCirclesIntersect(
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('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("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());
return pattern;
};
@ -140,7 +226,8 @@ pattern.draftPointFlipX = part => pointFlipX.draft(part);
pattern.draftPointFlipY = part => pointFlipY.draft(part);
pattern.draftPointShift = part => pointShift.draft(part);
pattern.draftPointShiftTowards = part => pointShiftTowards.draft(part);
pattern.draftPointShiftFractionTowards = part => pointShiftFractionTowards.draft(part);
pattern.draftPointShiftFractionTowards = part =>
pointShiftFractionTowards.draft(part);
pattern.draftPointShiftOutwards = part => pointShiftOutwards.draft(part);
pattern.draftPointTranslate = part => pointTranslate.draft(part);
pattern.draftPointSitsOn = part => pointSitsOn.draft(part);
@ -156,7 +243,8 @@ pattern.draftPathClone = part => pathClone.draft(part);
pattern.draftPathJoin = part => pathJoin.draft(part);
pattern.draftPathReverse = part => pathReverse.draft(part);
pattern.draftPathShiftAlong = part => pathShiftAlong.draft(part);
pattern.draftPathShiftFractionAlong = part => pathShiftFractionAlong.draft(part);
pattern.draftPathShiftFractionAlong = part =>
pathShiftFractionAlong.draft(part);
pattern.draftPathEdge = part => pathEdge.draft(part);
pattern.draftPathTrim = part => pathTrim.draft(part);
pattern.draftPathIntersectsX = part => pathIntersectsX.draft(part);
@ -170,14 +258,17 @@ pattern.draftUtilsLinesIntersect = part => utilsLinesIntersect.draft(part);
pattern.draftUtilsBeamsIntersect = part => utilsBeamsIntersect.draft(part);
pattern.draftUtilsBeamIntersectsX = part => utilsBeamIntersectsX.draft(part);
pattern.draftUtilsBeamIntersectsY = part => utilsBeamIntersectsY.draft(part);
pattern.draftUtilsLineIntersectsCurve = part => utilsLineIntersectsCurve.draft(part);
pattern.draftUtilsLineIntersectsCurve = part =>
utilsLineIntersectsCurve.draft(part);
pattern.draftUtilsCurvesIntersect = part => utilsCurvesIntersect.draft(part);
pattern.draftUtilsPointOnBeam = part => utilsPointOnBeam.draft(part);
pattern.draftUtilsPointOnLine = part => utilsPointOnLine.draft(part);
pattern.draftUtilsPointOnCurve = part => utilsPointOnCurve.draft(part);
pattern.draftUtilsCirclesIntersect = part => utilsCirclesIntersect.draft(part);
pattern.draftUtilsBeamIntersectsCircle = part => utilsBeamIntersectsCircle.draft(part);
pattern.draftUtilsLineIntersectsCircle = part => utilsLineIntersectsCircle.draft(part);
pattern.draftUtilsBeamIntersectsCircle = part =>
utilsBeamIntersectsCircle.draft(part);
pattern.draftUtilsLineIntersectsCircle = part =>
utilsLineIntersectsCircle.draft(part);
pattern.draftPluginGrainline = part => pluginGrainline.draft(part);
pattern.draftPluginCutonfold = part => pluginCutonfold.draft(part);
@ -189,7 +280,7 @@ pattern.draftPluginScalebox = part => pluginScalebox.draft(part);
pattern.draftSettingsSa = part => settingsSa.draft(part);
// Add custom snippet
pattern.on('preRender', function(next) {
pattern.on("preRender", function(next) {
this.defs += `
<g id="x">
<path d="M -1.1 -1.1 L 1.1 1.1 M 1.1 -1.1 L -1.1 1.1" class="note"></path>
@ -197,7 +288,6 @@ pattern.on('preRender', function(next) {
</g>
`;
next();
});
export default pattern;

View file

@ -13,9 +13,9 @@ var pathAttrs = {
paths.example = new Path()
.move(points.B)
.curve(points.BCp2, points.CCp1, points.C)
.attr('class', 'stroke-xl canvas')
.attr('data-text', 'I am text placed on a path')
.attr('data-text-class', 'center fill-note');
.attr("class", "stroke-xl canvas")
.attr("data-text", "I am text placed on a path")
.attr("data-text-class", "center fill-note");
return part;
}

View file

@ -16,8 +16,7 @@ var pathClone = {
.line(points.B)
.curve(points.BCp2, points.CCp1, points.C);
paths.clone = paths.example.clone()
.attr('class', 'note lashed stroke-xl');
paths.clone = paths.example.clone().attr("class", "note lashed stroke-xl");
return part;
}

View file

@ -21,8 +21,12 @@ var pathDivide = {
.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%)`);
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++;
}

View file

@ -20,14 +20,14 @@ var pathEdge = {
.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'));
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

@ -14,9 +14,9 @@ var pathEnd = {
paths.example = new Path()
.move(points.A)
.line(points.B)
.curve(points.BCp2, points.CCp1, points.C)
.curve(points.BCp2, points.CCp1, points.C);
snippets.x = new Snippet('x', paths.example.end());
snippets.x = new Snippet("x", paths.example.end());
return part;
}
};

View file

@ -32,7 +32,8 @@ var pathIntersects = {
.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);
for (let p of paths.example1.intersects(paths.example2))
snippets[part.getId()] = new Snippet("x", p);
return part;
}

View file

@ -13,19 +13,20 @@ var pathIntersectsX = {
points.D = new Point(50, 130);
points.DCp1 = new Point(150, 30);
points.top = new Point(60,-10);
points.bot = new Point(60,140);
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');
.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);
for (let p of paths.example.intersectsX(60))
snippets[part.getId()] = new Snippet("x", p);
return part;
}

View file

@ -18,13 +18,14 @@ var pathIntersectsY = {
paths.line = new Path()
.move(points.top)
.line(points.bot)
.attr('class', 'lining dashed');
.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);
for (let p of paths.example.intersectsY(58))
snippets[part.getId()] = new Snippet("x", p);
return part;
}

View file

@ -14,15 +14,16 @@ var pathJoin = {
paths.path1 = new Path()
.move(points.A)
.line(points.B)
.attr('class', 'various');
.attr("class", "various");
paths.path2 = new Path()
.move(points.B)
.curve(points.BCp2, points.CCp1, points.C)
.attr('class', 'canvas');
.attr("class", "canvas");
paths.joint = paths.path1.join(paths.path2)
.attr('class', 'note lashed stroke-xl');
paths.joint = paths.path1
.join(paths.path2)
.attr("class", "note lashed stroke-xl");
return part;
}

View file

@ -14,24 +14,20 @@ var pathLength = {
paths.example = new Path()
.move(points.A)
.line(points.B)
.curve(points.BCp2, points.CCp1, points.C)
.curve(points.BCp2, points.CCp1, points.C);
macro('pd', {
macro("pd", {
path: paths.example,
d: -20
});
macro('pd', {
path: new Path()
.move(points.B)
.line(points.A),
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),
macro("pd", {
path: new Path().move(points.B).curve(points.BCp2, points.CCp1, points.C),
d: -10
});

View file

@ -19,19 +19,19 @@ var pathOffset = {
.line(points.A)
.close();
paths.offset = paths.example.offset(-10)
.attr('class', 'interfacing');
paths.offset = paths.example.offset(-10).attr("class", "interfacing");
paths.lineOffset = new Path()
.move(points.A)
.line(points.B).offset(-5)
.attr('class', 'various');
.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');
.attr("class", "canvas");
return part;
}

View file

@ -6,8 +6,8 @@ var pathOps = {
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');
.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);
@ -19,33 +19,41 @@ var pathOps = {
.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");
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);
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');
.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');
.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');
.attr("data-text", "Close path")
.attr("data-text-class", "center text-xs");
return part;
}

View file

@ -14,10 +14,11 @@ var pathReverse = {
paths.example = new Path()
.move(points.B)
.curve(points.BCp2, points.CCp1, points.C)
.attr('data-text', 'I am the original path');
.attr("data-text", "I am the original path");
paths.reverse = paths.example.reverse()
.attr('data-text', 'I am the reversed path');
paths.reverse = paths.example
.reverse()
.attr("data-text", "I am the reversed path");
return part;
}

View file

@ -16,18 +16,19 @@ var pathShiftAlong = {
.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);
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);
snippets.Xl = new Snippet("x", points.X1);
snippets.X2 = new Snippet("x", points.X2);
return part;
}

View file

@ -16,18 +16,19 @@ var pathShiftFractionAlong = {
.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);
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);
snippets.Xl = new Snippet("x", points.X1);
snippets.X2 = new Snippet("x", points.X2);
return part;
}

View file

@ -23,14 +23,18 @@ var pathSplit = {
.move(points.D)
.curve(points.DCp1, points.DCp1, points.C)
.curve(points.CCp1, points.BCp2, points.B)
.line(points.A)
.line(points.A);
points.split = paths.example.shiftAlong(20);
snippets.x = new Snippet('x', points.split);
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%)`);
paths[i] = halves[i].attr(
"style",
`stroke-width: 3; stroke-opacity: 0.5; stroke: hsl(${i *
70}, 100%, 50%)`
);
}
return part;

View file

@ -14,9 +14,9 @@ var pathStart = {
paths.example = new Path()
.move(points.A)
.line(points.B)
.curve(points.BCp2, points.CCp1, points.C)
.curve(points.BCp2, points.CCp1, points.C);
snippets.x = new Snippet('x', paths.example.start());
snippets.x = new Snippet("x", paths.example.start());
return part;
}
};

View file

@ -13,20 +13,22 @@ var pathTranslate = {
.move(points.A)
.line(points.B)
.curve(points.BCp2, points.CCp1, points.C)
.attr('data-text', 'Path A')
.attr('data-text-class', 'center');
.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');
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', {
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', {
macro("ld", {
from: points.step1,
to: points.step2,
noStartMarker: true

View file

@ -9,30 +9,40 @@ var pathTrim = {
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) {
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]);
.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]);
.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.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;');
paths.trimmed = paths.offset
.trim()
.attr("class", "various stroke-xl")
.attr("style", "stroke-opacity: 0.5;");
return part;
}
};

View file

@ -5,19 +5,19 @@ var pluginCutonfold = {
// 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);
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()
.close();
macro('cutonfold', {
macro("cutonfold", {
from: points.topRight,
to: points.topLeft,
grainline: true

View file

@ -5,11 +5,11 @@ var pluginDimension = {
// 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);
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)
@ -17,34 +17,34 @@ var pluginDimension = {
.line(points.C)
.line(points.D)
.curve(points.DCp1, points.A, points.A)
.close()
.close();
macro('vd', {
macro("vd", {
from: points.A,
to: points.B,
x: points.A.x - 15
});
macro('hd', {
macro("hd", {
from: points.B,
to: points.C,
y: points.B.y + 15
});
macro('ld', {
macro("ld", {
from: points.C,
to: points.D,
d: -15
});
macro('ld', {
macro("ld", {
from: points.C,
to: points.D,
d: -30,
text: 'Custom text'
text: "Custom text"
});
macro('pd', {
macro("pd", {
path: new Path().move(points.A).curve(points.A, points.DCp1, points.D),
d: -15
});

View file

@ -8,7 +8,7 @@ var pluginGrainline = {
points.grainlineFrom = new Point(10, 10);
points.grainlineTo = new Point(100, 10);
macro('grainline', {
macro("grainline", {
from: points.grainlineFrom,
to: points.grainlineTo
});

View file

@ -3,20 +3,20 @@ var pluginLogo = {
// 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);
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()
.close();
snippets.logo = new Snippet('logo', points.logoAnchor);
snippets.logo = new Snippet("logo", points.logoAnchor);
return part;
}

View file

@ -3,9 +3,9 @@ var pluginScalebox = {
// prettier-ignore
let {Point, points, Path, paths, macro} = part.shorthand();
points.anchor = new Point(0,0);
points.anchor = new Point(0, 0);
macro('scalebox', {
macro("scalebox", {
at: points.anchor
});

View file

@ -3,20 +3,20 @@ var pluginTitle = {
// 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);
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()
.close();
macro('title', {
macro("title", {
at: points.titleAnchor,
nr: 4,
title: "sleeve"

View file

@ -6,18 +6,43 @@ var pointAngle = {
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.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');
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');
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);

View file

@ -8,11 +8,11 @@ var pointClone = {
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');
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);

View file

@ -8,8 +8,10 @@ var pointCopy = {
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');
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);

View file

@ -8,7 +8,7 @@ var pointDist = {
points.from = new Point(10, 10);
points.to = new Point(90, 40);
macro('ld', {
macro("ld", {
from: points.from,
to: points.to
});

View file

@ -8,7 +8,7 @@ var pointDx = {
points.from = new Point(10, 10);
points.to = new Point(90, 40);
macro('hd', {
macro("hd", {
from: points.from,
to: points.to,
y: 25

View file

@ -8,7 +8,7 @@ var pointDy = {
points.from = new Point(10, 10);
points.to = new Point(90, 40);
macro('vd', {
macro("vd", {
from: points.to,
to: points.from,
x: 50

View file

@ -46,7 +46,7 @@ var pointFlipX = {
paths.mirror = new Path()
.move(points.top)
.line(points.bottom)
.attr('class', 'note dashed');
.attr("class", "note dashed");
return part;
}

View file

@ -19,21 +19,27 @@ var pointFlipX = {
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.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._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._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._houseWallRight = points.houseWallRight.flipY(points.mirror);
points._end = points.end.flipY(points.mirror);
paths.skylineTop = new Path()
@ -49,8 +55,7 @@ var pointFlipX = {
.line(points.houseRoofTop)
.line(points.houseRoofRight)
.line(points.houseWallRight)
.line(points.end)
;
.line(points.end);
paths.skylineBottom = new Path()
.move(points._start)
@ -65,13 +70,12 @@ var pointFlipX = {
.line(points._houseRoofTop)
.line(points._houseRoofRight)
.line(points._houseWallRight)
.line(points._end)
;
.line(points._end);
paths.mirrorLine = new Path()
.move(points.mirror)
.line(points.mirrorLineEnd)
.attr('class', 'note dashed');
.attr("class", "note dashed");
return part;
}

View file

@ -10,7 +10,7 @@ var pointRotate = {
points.moon = new Point(70, 40);
let angle = 0;
let step = 360 / 36;
for(let i=1; i<37; i++) {
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}`]);

View file

@ -6,16 +6,19 @@ var pointShift = {
let {Point, points, Snippet, snippets, macro} = part.shorthand();
points.A = new Point(90, 40)
.attr('data-text', 'Point A')
.attr('data-text-class', 'right');
.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);
.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', {
macro("ld", {
from: points.B,
to: points.A,
d: -10

View file

@ -5,12 +5,15 @@ var pointShiftFractionTowards = {
// 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.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);
.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);
@ -19,15 +22,15 @@ var pointShiftFractionTowards = {
paths.direction = new Path()
.move(points.A)
.line(points.B)
.attr('class', 'note dashed');
.attr("class", "note dashed");
macro('ld', {
macro("ld", {
from: points.C,
to: points.A,
d: -10
});
macro('ld', {
macro("ld", {
from: points.B,
to: points.A,
d: 20

View file

@ -5,11 +5,11 @@ var pointShiftOutwards = {
// 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.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);
.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);
@ -18,9 +18,9 @@ var pointShiftOutwards = {
paths.direction = new Path()
.move(points.A)
.line(points.C)
.attr('class', 'note dashed');
.attr("class", "note dashed");
macro('ld', {
macro("ld", {
from: points.C,
to: points.B,
d: -10

View file

@ -5,12 +5,15 @@ var pointShiftTowards = {
// 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.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);
.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);
@ -19,9 +22,9 @@ var pointShiftTowards = {
paths.direction = new Path()
.move(points.A)
.line(points.B)
.attr('class', 'note dashed');
.attr("class", "note dashed");
macro('ld', {
macro("ld", {
from: points.C,
to: points.A,
d: -10

View file

@ -9,11 +9,11 @@ var pointDx = {
box(part);
let s;
for(let i=0; i<10; i++) {
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';
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}`]);
}

View file

@ -3,21 +3,23 @@ var pointTranslate = {
// prettier-ignore
let {Point, points, Snippet, snippets, macro} = part.shorthand();
points.A = new Point(10, 10)
.attr('data-text', 'Point A')
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);
.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', {
macro("ld", {
from: points.A,
to: points.B,
text: 'translate(120,60)',
text: "translate(120,60)",
noStartMarker: true
});

View file

@ -17,10 +17,9 @@ var pathOffset = {
.curve(points.BCp2, points.CCp1, points.C)
.line(points.A)
.close()
.attr('class', 'fabric');
.attr("class", "fabric");
paths.offset = paths.example.offset(-10)
.attr('class', 'fabric sa');
paths.offset = paths.example.offset(-10).attr("class", "fabric sa");
return part;
}

View file

@ -6,8 +6,8 @@ var utilsBeamIntersectsCircle = {
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');
.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);
@ -15,43 +15,36 @@ var utilsBeamIntersectsCircle = {
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);
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.A.attributes.get("data-circle"),
points.B,
points.C
);
let intersections2 = utils.beamIntersectsCircle(
points.A,
points.A.attributes.get('data-circle'),
points.A.attributes.get("data-circle"),
points.D,
points.E,
'y'
"y"
);
let intersections3 = utils.beamIntersectsCircle(
points.A,
points.A.attributes.get('data-circle'),
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]);
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

@ -8,20 +8,17 @@ var utilsBeamIntersectsX = {
points.A = new Point(10, 10);
points.B = new Point(50, 40);
paths.AB = new Path()
.move(points.A)
.line(points.B);
paths.AB = new Path().move(points.A).line(points.B);
snippets.X = new Snippet('x', utils.beamIntersectsX(
points.A,
points.B,
40)
);
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');
.move(new Point(40, 0))
.line(new Point(40, 50))
.attr("class", "note dashed");
return part;
}

View file

@ -8,20 +8,17 @@ var utilsBeamIntersectsY = {
points.A = new Point(10, 10);
points.B = new Point(50, 40);
paths.AB = new Path()
.move(points.A)
.line(points.B);
paths.AB = new Path().move(points.A).line(points.B);
snippets.X = new Snippet('x', utils.beamIntersectsY(
points.A,
points.B,
30)
);
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');
.move(new Point(0, 30))
.line(new Point(50, 30))
.attr("class", "note dashed");
return part;
}

View file

@ -10,19 +10,13 @@ var utilsBeamsIntersect = {
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);
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)
);
snippets.X = new Snippet(
"x",
utils.beamsIntersect(points.A, points.B, points.C, points.D)
);
return part;
}

View file

@ -6,36 +6,36 @@ var utilsCirclesIntersect = {
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');
.attr("data-circle", 15)
.attr("data-circle-class", "fabric");
points.B = new Point(30, 30)
.attr('data-circle', 35)
.attr('data-circle-class', 'fabric');
.attr("data-circle", 35)
.attr("data-circle-class", "fabric");
points.C = new Point(90, 10)
.attr('data-circle', 15)
.attr('data-circle-class', 'various');
.attr("data-circle", 15)
.attr("data-circle-class", "various");
points.D = new Point(110, 30)
.attr('data-circle', 35)
.attr('data-circle-class', 'various');
.attr("data-circle", 35)
.attr("data-circle-class", "various");
let intersections1 = utils.circlesIntersect(
points.A,
points.A.attributes.get('data-circle'),
points.A.attributes.get("data-circle"),
points.B,
points.B.attributes.get('data-circle')
points.B.attributes.get("data-circle")
);
let intersections2 = utils.circlesIntersect(
points.C,
points.C.attributes.get('data-circle'),
points.C.attributes.get("data-circle"),
points.D,
points.D.attributes.get('data-circle'),
'y'
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]);
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;
}

View file

@ -12,8 +12,8 @@ var utilsCurvesIntersect = {
points.C = new Point(20, -5);
points.Ccp = new Point(60, 300);
points.D = new Point (100, 85);
points.Dcp = new Point (70, -220);
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);
@ -22,14 +22,16 @@ var utilsCurvesIntersect = {
.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);
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;
}

View file

@ -6,8 +6,8 @@ var utilsLineIntersectsCircle = {
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');
.attr("data-circle", 35)
.attr("data-circle-class", "fabric");
points.B = new Point(5, 50);
points.C = new Point(25, 30);
@ -16,41 +16,34 @@ var utilsLineIntersectsCircle = {
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);
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.A.attributes.get("data-circle"),
points.B,
points.C
);
let intersections2 = utils.lineIntersectsCircle(
points.A,
points.A.attributes.get('data-circle'),
points.A.attributes.get("data-circle"),
points.D,
points.E,
'y'
"y"
);
let intersections3 = utils.lineIntersectsCircle(
points.A,
points.A.attributes.get('data-circle'),
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]);
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;
}

View file

@ -10,21 +10,21 @@ var utilsLineIntersectsCurve = {
points.B = new Point(110, 70);
points.Bcp = new Point(-210, 40);
points.E = new Point(20, -5);
points.D = new Point (100, 85);
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);
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);
points.D,
points.E,
points.A,
points.Acp,
points.Bcp,
points.B
))
snippets[part.getId()] = new Snippet("x", p);
return part;
}

View file

@ -10,19 +10,13 @@ var utilsLinesIntersect = {
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);
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)
);
snippets.X = new Snippet(
"x",
utils.linesIntersect(points.A, points.B, points.C, points.D)
);
return part;
}

View file

@ -13,37 +13,37 @@ var utilsPointOnBeam = {
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));
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';
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';
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');
.attr("class", "fabric stroke-lg");
paths.lne1 = new Path()
.move(points.to1)
.line(points.b1)
.attr('class', 'fabric dashed');
.attr("class", "fabric dashed");
paths.line2 = new Path()
.move(points.from2)
.line(points.to2)
.attr('class', 'fabric stroke-lg');
.attr("class", "fabric stroke-lg");
paths.lne2 = new Path()
.move(points.to2)
.line(points.b2)
.attr('class', 'fabric dashed');
.attr("class", "fabric dashed");
return part;
}

View file

@ -11,21 +11,30 @@ var utilsPointOnCurve = {
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));
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';
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');
.attr("class", "fabric stroke-lg");
return part;
}

View file

@ -13,36 +13,37 @@ var utilsPointOnLine = {
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));
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';
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';
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');
.attr("class", "fabric stroke-lg");
paths.lne1 = new Path()
.move(points.to1)
.line(points.b1)
.attr('class', 'fabric dashed');
.attr("class", "fabric dashed");
paths.line2 = new Path()
.move(points.from2)
.line(points.to2)
.attr('class', 'fabric stroke-lg');
.attr("class", "fabric stroke-lg");
paths.lne2 = new Path()
.move(points.to2)
.line(points.b2)
.attr('class', 'fabric dashed');
.attr("class", "fabric dashed");
return part;
}