1
0
Fork 0

sparkles: Added _curve and curve_ to path.ops example

This commit is contained in:
Joost De Cock 2019-01-28 14:34:55 +01:00
parent 9fbcafbe38
commit 5ad7a7ede9
6 changed files with 50 additions and 53 deletions

View file

@ -6,10 +6,12 @@ export default {
// 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"
path_attr: "path_ops"
},
parts: [
"point_attr",
"path__curve",
"path_curve_",
"path_attr",
"path_clone",
"path_divide",

View file

@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<title>Examples</title>
<script type="text/javascript" src="node_modules/freesewing/dist/browser.js"></script>
<script type="text/javascript" src="../../freesewing//dist/browser.js"></script>
<script type="text/javascript" src="node_modules/@freesewing/plugin-bundle/dist/browser.js"></script>
<script type="text/javascript" src="dist/browser.js"></script>
<script type="text/javascript" src="node_modules/@freesewing/plugin-theme/dist/browser.js"></script>
@ -23,7 +23,7 @@
.use(freesewing.plugins.validate)
;
//pattern.settings.only = ['pathAttr'];
pattern.settings.only = ['path_ops'];
pattern.draft();
document.getElementById("svg").innerHTML = pattern.render();

View file

@ -16,12 +16,12 @@ export default {
commonjs(),
babel({
exclude: "node_modules/**"
}),
terser({
output: {
preamble: `/**\n * ${name} | v${version}\n * ${description}\n * (c) ${new Date().getFullYear()} ${author}\n * @license ${license}\n */`
}
})
//terser({
// output: {
// preamble: `/**\n * ${name} | v${version}\n * ${description}\n * (c) ${new Date().getFullYear()} ${author}\n * @license ${license}\n */`
// }
//})
],
external: ["freesewing", "@freesewing/plugin-bundle"],
output: {

View file

@ -4,6 +4,7 @@ import plugins from "@freesewing/plugin-bundle";
import config from "../config/";
import { version } from "../package.json";
import draftPath_ops from "./path_ops";
import draftPath_attr from "./path_attr";
import draftPath_clone from "./path_clone";
import draftPath_divide from "./path_divide";
@ -15,7 +16,6 @@ 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";
@ -76,7 +76,13 @@ 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_move = draftPath_ops;
Examples.prototype.draftPath_line = draftPath_ops;
Examples.prototype.draftPath_curve = draftPath_ops;
Examples.prototype.draftPath__curve = draftPath_ops;
Examples.prototype.draftPath_curve_ = draftPath_ops;
Examples.prototype.draftPath_close = draftPath_ops;
Examples.prototype.draftPath_attr = draftPath_attr;
Examples.prototype.draftPath_clone = draftPath_clone;
@ -105,6 +111,7 @@ Examples.prototype.draftPlugin_logo = draftPlugin_logo;
Examples.prototype.draftPlugin_scalebox = draftPlugin_scalebox;
Examples.prototype.draftPlugin_title = draftPlugin_title;
Examples.prototype.draftPoint_attr = draftPoint_attr;
Examples.prototype.draftPoint_angle = draftPoint_angle;
Examples.prototype.draftPoint_attr = draftPoint_attr;
Examples.prototype.draftPoint_clone = draftPoint_clone;

View file

@ -1,63 +1,53 @@
export default part => {
let {
Point,
points,
Path,
paths,
Snippet,
snippets,
macro
} = part.shorthand();
let { Point, points, Path, paths } = part.shorthand();
points.A = new Point(10, 10)
.attr("data-text", "Move to point A")
.attr("data-text", "msg_move")
.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);
points.D = new Point(20, -50);
points.DCp = new Point(40, 0);
points.E = new Point(-20, -20);
points.ECp = new Point(-20, -50);
paths.example = new Path()
paths.line = new Path()
.move(points.A)
.line(points.B)
.curve(points.BCp2, points.CCp1, points.C)
.close();
.attr("data-text", "msg_line")
.attr("data-text-class", "center text-xs");
paths.handle1 = new Path()
paths.curve = new Path()
.move(points.B)
.line(points.BCp2)
.attr("class", "note dashed");
paths.handle2 = new Path()
.curve(points.BCp2, points.CCp1, points.C)
.attr("data-text", "msg_curve")
.attr("data-text-class", "center text-xs");
paths._curve = 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")
._curve(points.DCp, points.D)
.attr("data-text", "msg__curve")
.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"
)
paths.curve_ = new Path()
.move(points.D)
.curve_(points.ECp, points.E)
.attr("data-text", "msg_curve_")
.attr("data-text-class", "center text-xs");
paths.textClose = new Path()
.move(points.A)
.line(points.C)
.attr("data-text", "Close path")
paths.close = new Path()
.move(points.E)
.line(points.A)
.attr("data-text", "msg_close")
.attr("data-text-class", "center text-xs");
paths.example = paths.line
.join(paths.curve)
.join(paths._curve)
.join(paths.curve_)
.close();
return part;
};

View file

@ -8,7 +8,5 @@ export default part => {
.attr("data-text-class", "text-xl center")
.attr("data-text-lineheight", 10);
snippets.notch = new Snippet("x", points.anchor);
return box(part);
};