sparkles: Added path.translate example
This commit is contained in:
parent
373ecb4c88
commit
5c15acc6ab
6 changed files with 85 additions and 10 deletions
1
packages/examples/freesewing.js
Symbolic link
1
packages/examples/freesewing.js
Symbolic link
|
@ -0,0 +1 @@
|
|||
../freesewing/dist/browser.js
|
|
@ -3,7 +3,8 @@
|
|||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Examples</title>
|
||||
<script type="text/javascript" src="freesewing.js"></script>
|
||||
<!-- <script type="text/javascript" src="freesewing.js"></script> -->
|
||||
<script type="text/javascript" src="node_modules/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>
|
||||
|
@ -20,7 +21,7 @@
|
|||
.with(freesewing.plugins.debug)
|
||||
.with(freesewing.plugins.theme)
|
||||
//.with(freesewing.plugins.designer)
|
||||
.with(freesewing.plugins.validate)
|
||||
//.with(freesewing.plugins.validate)
|
||||
;
|
||||
pattern.settings.measurements = freesewing.models.men.manSize36;
|
||||
|
||||
|
@ -30,7 +31,7 @@
|
|||
pattern.settings.sa = 10;
|
||||
pattern.settings.units = 'metric';
|
||||
// console.log(pattern);
|
||||
pattern.settings.only = ['utilsLineIntersectsCircle', 'utilsPointOnLine'];
|
||||
pattern.settings.only = ['pathTranslate'];
|
||||
//pattern.on('preRender', function(next) {
|
||||
// this.style += 'g { border: 1px solid red; background: red;}';
|
||||
// next();
|
||||
|
|
14
packages/examples/package-lock.json
generated
14
packages/examples/package-lock.json
generated
|
@ -923,12 +923,12 @@
|
|||
"dev": true
|
||||
},
|
||||
"@freesewing/plugin-bundle": {
|
||||
"version": "0.1.9",
|
||||
"resolved": "https://registry.npmjs.org/@freesewing/plugin-bundle/-/plugin-bundle-0.1.9.tgz",
|
||||
"integrity": "sha512-sD/RBtE5dXV0JWSrcpJhQwanJreppWQr+eQn3r2mrBBv5H1nLn9mmrb+/FMB9cPgNr8OxeKbNcf4MoYR+7rjKg==",
|
||||
"version": "0.2.0",
|
||||
"resolved": "https://registry.npmjs.org/@freesewing/plugin-bundle/-/plugin-bundle-0.2.0.tgz",
|
||||
"integrity": "sha512-FQyKbgRo6Es87611EoNWmXur7vivE5ti5B8wVc+TSDIbVBWB/eRB0scRfC0sd/DB+gzg0XQhMF3/I7LNekvHLA==",
|
||||
"requires": {
|
||||
"@freesewing/plugin-cutonfold": "0.9.0",
|
||||
"@freesewing/plugin-dimension": "0.5.2",
|
||||
"@freesewing/plugin-dimension": "0.6.0",
|
||||
"@freesewing/plugin-grainline": "0.0.3",
|
||||
"@freesewing/plugin-logo": "0.3.3",
|
||||
"@freesewing/plugin-scalebox": "0.1.2",
|
||||
|
@ -953,9 +953,9 @@
|
|||
"dev": true
|
||||
},
|
||||
"@freesewing/plugin-dimension": {
|
||||
"version": "0.5.2",
|
||||
"resolved": "https://registry.npmjs.org/@freesewing/plugin-dimension/-/plugin-dimension-0.5.2.tgz",
|
||||
"integrity": "sha512-84wqa905cwprdKw8vqs5/y8VvphXdkeUgCgzfY28Y6N1L1MhKOn/Dpux2C9AN5xUpFv/aopuId/9b8fGjTuZww=="
|
||||
"version": "0.6.0",
|
||||
"resolved": "https://registry.npmjs.org/@freesewing/plugin-dimension/-/plugin-dimension-0.6.0.tgz",
|
||||
"integrity": "sha512-oSoL8eJOZDTvE9hj/4JxClo8h9W25Z1vbwGK36HEF+7keWNhJJiDUoisPa2cBJn6w3Gsr8iOZkT3lFyO3trzVw=="
|
||||
},
|
||||
"@freesewing/plugin-grainline": {
|
||||
"version": "0.0.3",
|
||||
|
|
|
@ -17,6 +17,7 @@ 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";
|
||||
|
||||
|
@ -38,6 +39,7 @@ 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 utilsLinesIntersect from "./utils.linesintersect";
|
||||
import utilsBeamsIntersect from "./utils.beamsintersect";
|
||||
|
@ -79,6 +81,7 @@ pattern.draft = function() {
|
|||
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());
|
||||
|
||||
|
@ -100,6 +103,7 @@ pattern.draft = function() {
|
|||
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());
|
||||
|
@ -138,6 +142,7 @@ pattern.draftPointShift = part => pointShift.draft(part);
|
|||
pattern.draftPointShiftTowards = part => pointShiftTowards.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);
|
||||
pattern.draftPointClone = part => pointClone.draft(part);
|
||||
|
||||
|
@ -159,6 +164,7 @@ pattern.draftPathIntersectsY = part => pathIntersectsY.draft(part);
|
|||
pattern.draftPathIntersects = part => pathIntersects.draft(part);
|
||||
pattern.draftPathDivide = part => pathDivide.draft(part);
|
||||
pattern.draftPathSplit = part => pathSplit.draft(part);
|
||||
pattern.draftPathTranslate = part => pathTranslate.draft(part);
|
||||
|
||||
pattern.draftUtilsLinesIntersect = part => utilsLinesIntersect.draft(part);
|
||||
pattern.draftUtilsBeamsIntersect = part => utilsBeamsIntersect.draft(part);
|
||||
|
|
39
packages/examples/src/path.translate.js
Normal file
39
packages/examples/src/path.translate.js
Normal file
|
@ -0,0 +1,39 @@
|
|||
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;
|
28
packages/examples/src/point.translate.js
Normal file
28
packages/examples/src/point.translate.js
Normal file
|
@ -0,0 +1,28 @@
|
|||
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;
|
Loading…
Add table
Add a link
Reference in a new issue