sparkles: Added missing utils examples
This commit is contained in:
parent
89a926cab9
commit
a2ba2ec923
6 changed files with 152 additions and 3 deletions
|
@ -67,6 +67,9 @@ export default {
|
||||||
"utils_pointoncurve",
|
"utils_pointoncurve",
|
||||||
"utils_circlesintersect",
|
"utils_circlesintersect",
|
||||||
"utils_beamintersectscircle",
|
"utils_beamintersectscircle",
|
||||||
"utils_lineintersectscircle"
|
"utils_lineintersectscircle",
|
||||||
|
"utils_curveintersectsy",
|
||||||
|
"utils_curveintersectsx",
|
||||||
|
"utils_splitcurve"
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
|
@ -19,11 +19,11 @@
|
||||||
var pattern = new freesewing.patterns.examples();
|
var pattern = new freesewing.patterns.examples();
|
||||||
pattern.use(freesewing.plugins.debug)
|
pattern.use(freesewing.plugins.debug)
|
||||||
.use(freesewing.plugins.theme)
|
.use(freesewing.plugins.theme)
|
||||||
//.use(freesewing.plugins.designer)
|
.use(freesewing.plugins.designer)
|
||||||
.use(freesewing.plugins.validate)
|
.use(freesewing.plugins.validate)
|
||||||
;
|
;
|
||||||
|
|
||||||
//pattern.settings.only = ['snippet_clone'];
|
pattern.settings.only = ['utils_splitcurve'];
|
||||||
pattern.draft();
|
pattern.draft();
|
||||||
document.getElementById("svg").innerHTML = pattern.render();
|
document.getElementById("svg").innerHTML = pattern.render();
|
||||||
|
|
||||||
|
|
|
@ -60,6 +60,9 @@ import draftUtils_pointoncurve from "./utils_pointoncurve";
|
||||||
import draftUtils_circlesintersect from "./utils_circlesintersect";
|
import draftUtils_circlesintersect from "./utils_circlesintersect";
|
||||||
import draftUtils_beamintersectscircle from "./utils_beamintersectscircle";
|
import draftUtils_beamintersectscircle from "./utils_beamintersectscircle";
|
||||||
import draftUtils_lineintersectscircle from "./utils_lineintersectscircle";
|
import draftUtils_lineintersectscircle from "./utils_lineintersectscircle";
|
||||||
|
import draftUtils_curveintersectsx from "./utils_curveintersectsx";
|
||||||
|
import draftUtils_curveintersectsy from "./utils_curveintersectsy";
|
||||||
|
import draftUtils_splitcurve from "./utils_splitcurve";
|
||||||
|
|
||||||
import draftSettings_sa from "./settings_sa";
|
import draftSettings_sa from "./settings_sa";
|
||||||
|
|
||||||
|
@ -139,5 +142,8 @@ Examples.prototype.draftUtils_pointoncurve = draftUtils_pointoncurve;
|
||||||
Examples.prototype.draftUtils_circlesintersect = draftUtils_circlesintersect;
|
Examples.prototype.draftUtils_circlesintersect = draftUtils_circlesintersect;
|
||||||
Examples.prototype.draftUtils_beamintersectscircle = draftUtils_beamintersectscircle;
|
Examples.prototype.draftUtils_beamintersectscircle = draftUtils_beamintersectscircle;
|
||||||
Examples.prototype.draftUtils_lineintersectscircle = draftUtils_lineintersectscircle;
|
Examples.prototype.draftUtils_lineintersectscircle = draftUtils_lineintersectscircle;
|
||||||
|
Examples.prototype.draftUtils_curveintersectsx = draftUtils_curveintersectsx;
|
||||||
|
Examples.prototype.draftUtils_curveintersectsy = draftUtils_curveintersectsy;
|
||||||
|
Examples.prototype.draftUtils_splitcurve = draftUtils_splitcurve;
|
||||||
|
|
||||||
export default Examples;
|
export default Examples;
|
||||||
|
|
45
packages/examples/src/utils_curveintersectsx.js
Normal file
45
packages/examples/src/utils_curveintersectsx.js
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
export default part => {
|
||||||
|
let {
|
||||||
|
Point,
|
||||||
|
points,
|
||||||
|
Path,
|
||||||
|
paths,
|
||||||
|
utils,
|
||||||
|
snippets,
|
||||||
|
Snippet
|
||||||
|
} = part.shorthand();
|
||||||
|
|
||||||
|
points.start = new Point(10, 15);
|
||||||
|
points.cp1 = new Point(80, 10);
|
||||||
|
points.cp2 = new Point(-50, 80);
|
||||||
|
points.end = new Point(110, 70);
|
||||||
|
|
||||||
|
paths.curve = new Path()
|
||||||
|
.move(points.start)
|
||||||
|
.curve(points.cp1, points.cp2, points.end);
|
||||||
|
|
||||||
|
for (let x of [30, 40]) {
|
||||||
|
points["from" + x] = new Point(x, 10);
|
||||||
|
points["to" + x] = new Point(x, 80);
|
||||||
|
paths["line" + x] = new Path()
|
||||||
|
.move(points["from" + x])
|
||||||
|
.line(points["to" + x])
|
||||||
|
.attr("class", "lining dashed");
|
||||||
|
}
|
||||||
|
|
||||||
|
snippets.i40 = new Snippet(
|
||||||
|
"notch",
|
||||||
|
utils.curveIntersectsX(points.start, points.cp1, points.cp2, points.end, 40)
|
||||||
|
);
|
||||||
|
|
||||||
|
for (let p of utils.curveIntersectsX(
|
||||||
|
points.start,
|
||||||
|
points.cp1,
|
||||||
|
points.cp2,
|
||||||
|
points.end,
|
||||||
|
30
|
||||||
|
))
|
||||||
|
snippets[p.y] = new Snippet("notch", p);
|
||||||
|
|
||||||
|
return part;
|
||||||
|
};
|
45
packages/examples/src/utils_curveintersectsy.js
Normal file
45
packages/examples/src/utils_curveintersectsy.js
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
export default part => {
|
||||||
|
let {
|
||||||
|
Point,
|
||||||
|
points,
|
||||||
|
Path,
|
||||||
|
paths,
|
||||||
|
utils,
|
||||||
|
snippets,
|
||||||
|
Snippet
|
||||||
|
} = part.shorthand();
|
||||||
|
|
||||||
|
points.start = new Point(10, 45);
|
||||||
|
points.cp1 = new Point(50, 10);
|
||||||
|
points.cp2 = new Point(0, 80);
|
||||||
|
points.end = new Point(110, 70);
|
||||||
|
|
||||||
|
paths.curve = new Path()
|
||||||
|
.move(points.start)
|
||||||
|
.curve(points.cp1, points.cp2, points.end);
|
||||||
|
|
||||||
|
for (let y of [40, 50]) {
|
||||||
|
points["from" + y] = new Point(10, y);
|
||||||
|
points["to" + y] = new Point(110, y);
|
||||||
|
paths["line" + y] = new Path()
|
||||||
|
.move(points["from" + y])
|
||||||
|
.line(points["to" + y])
|
||||||
|
.attr("class", "lining dashed");
|
||||||
|
}
|
||||||
|
|
||||||
|
snippets.i50 = new Snippet(
|
||||||
|
"notch",
|
||||||
|
utils.curveIntersectsY(points.start, points.cp1, points.cp2, points.end, 50)
|
||||||
|
);
|
||||||
|
|
||||||
|
for (let p of utils.curveIntersectsY(
|
||||||
|
points.start,
|
||||||
|
points.cp1,
|
||||||
|
points.cp2,
|
||||||
|
points.end,
|
||||||
|
40
|
||||||
|
))
|
||||||
|
snippets[p.x] = new Snippet("notch", p);
|
||||||
|
|
||||||
|
return part;
|
||||||
|
};
|
50
packages/examples/src/utils_splitcurve.js
Normal file
50
packages/examples/src/utils_splitcurve.js
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
export default part => {
|
||||||
|
let {
|
||||||
|
Point,
|
||||||
|
points,
|
||||||
|
Path,
|
||||||
|
paths,
|
||||||
|
utils,
|
||||||
|
snippets,
|
||||||
|
Snippet
|
||||||
|
} = part.shorthand();
|
||||||
|
|
||||||
|
points.from = new Point(40, 10);
|
||||||
|
points.to = new Point(40, 80);
|
||||||
|
paths.line = new Path()
|
||||||
|
.move(points.from)
|
||||||
|
.line(points.to)
|
||||||
|
.attr("class", "lining dashed");
|
||||||
|
|
||||||
|
points.start = new Point(10, 15);
|
||||||
|
points.cp1 = new Point(80, 10);
|
||||||
|
points.cp2 = new Point(-50, 80);
|
||||||
|
points.end = new Point(110, 70);
|
||||||
|
|
||||||
|
points.i40 = utils.curveIntersectsX(
|
||||||
|
points.start,
|
||||||
|
points.cp1,
|
||||||
|
points.cp2,
|
||||||
|
points.end,
|
||||||
|
40
|
||||||
|
);
|
||||||
|
|
||||||
|
let parts = utils.splitCurve(
|
||||||
|
points.start,
|
||||||
|
points.cp1,
|
||||||
|
points.cp2,
|
||||||
|
points.end,
|
||||||
|
points.i40
|
||||||
|
);
|
||||||
|
|
||||||
|
let colors = ["lining", "interfacing"];
|
||||||
|
for (let p of parts) {
|
||||||
|
let color = colors.pop();
|
||||||
|
paths[color] = new Path()
|
||||||
|
.move(p.start)
|
||||||
|
.curve(p.cp1, p.cp2, p.end)
|
||||||
|
.attr("class", "stroke-xl " + color);
|
||||||
|
}
|
||||||
|
|
||||||
|
return part;
|
||||||
|
};
|
Loading…
Add table
Add a link
Reference in a new issue