sparkles: Examples up to freesewing 10.0
This commit is contained in:
parent
4947124e13
commit
1098736aac
20 changed files with 456 additions and 95 deletions
|
@ -25,12 +25,12 @@
|
|||
pattern.settings.measurements = freesewing.models.men.manSize36;
|
||||
|
||||
// Uncomment this line to enable paperless
|
||||
pattern.settings.paperless = true;
|
||||
|
||||
//pattern.settings.paperless = true;
|
||||
// Some default settings
|
||||
pattern.settings.sa = 10;
|
||||
pattern.settings.units = 'metric';
|
||||
pattern.settings.only = 'pathEdge';
|
||||
// console.log(pattern);
|
||||
pattern.settings.only = ['utilsLineIntersectsCircle', 'utilsPointOnLine'];
|
||||
//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
|
@ -2911,9 +2911,9 @@
|
|||
}
|
||||
},
|
||||
"freesewing": {
|
||||
"version": "0.8.3",
|
||||
"resolved": "https://registry.npmjs.org/freesewing/-/freesewing-0.8.3.tgz",
|
||||
"integrity": "sha512-CxvkFFkQOYFnV8EDOdFqB6b1BpczX/P4MJ24X671Y7l44VUK5EOGk+MrFBoIGZj9UcL7PttNE9sH2Q+FHIcGPw==",
|
||||
"version": "0.9.0",
|
||||
"resolved": "https://registry.npmjs.org/freesewing/-/freesewing-0.9.0.tgz",
|
||||
"integrity": "sha512-I54nRwNrr+ymMYLJ3+q38K5EwTx1xE1iKWXUkAlajdh8xwWC1De7ql0QQKa4VUaOAaA6uJgSH6qnHN69Ok4dwg==",
|
||||
"requires": {
|
||||
"bezier-js": "2.2.14",
|
||||
"bin-pack": "1.0.2",
|
||||
|
@ -4828,7 +4828,7 @@
|
|||
"integrity": "sha1-RJhkS7+Bpm8Y3Y3/3vYcTBw3TKM=",
|
||||
"requires": {
|
||||
"chokidar": "1.7.0",
|
||||
"colors": "1.3.1",
|
||||
"colors": "1.3.2",
|
||||
"connect": "3.5.1",
|
||||
"cors": "2.8.4",
|
||||
"event-stream": "3.3.4",
|
||||
|
@ -4843,9 +4843,9 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"colors": {
|
||||
"version": "1.3.1",
|
||||
"resolved": "https://registry.npmjs.org/colors/-/colors-1.3.1.tgz",
|
||||
"integrity": "sha512-jg/vxRmv430jixZrC+La5kMbUWqIg32/JsYNZb94+JEmzceYbWKTsv1OuTp+7EaqiaWRR2tPcykibwCRgclIsw=="
|
||||
"version": "1.3.2",
|
||||
"resolved": "https://registry.npmjs.org/colors/-/colors-1.3.2.tgz",
|
||||
"integrity": "sha512-rhP0JSBGYvpcNQj4s5AdShMeE5ahMop96cTeDl/v9qQQm2fYClE2QXZRi8wLzc+GmXSxdIqqbOIAhyObEXDbfQ=="
|
||||
},
|
||||
"object-assign": {
|
||||
"version": "4.1.1",
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
]
|
||||
},
|
||||
"dependencies": {
|
||||
"freesewing": "^0.9.0",
|
||||
"freesewing": "^0.10.0",
|
||||
"@freesewing/plugin-bundle": "0.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
|
|
@ -32,17 +32,24 @@ import pathReverse from "./path.reverse";
|
|||
import pathShiftAlong from "./path.shiftalong";
|
||||
import pathShiftFractionAlong from "./path.shiftfractionalong";
|
||||
import pathEdge from "./path.edge";
|
||||
import pathCrossesX from "./path.crossesx";
|
||||
import pathCrossesY from "./path.crossesy";
|
||||
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 utilsLinesCross from "./utils.linescross";
|
||||
import utilsBeamsCross from "./utils.beamscross";
|
||||
import utilsBeamCrossesX from "./utils.beamcrossesx";
|
||||
import utilsBeamCrossesY from "./utils.beamcrossesy";
|
||||
import utilsCurveCrossesLine from "./utils.curvecrossesline";
|
||||
import utilsCurveCrossesCurve from "./utils.curvecrossescurve";
|
||||
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 settingsSa from "./settings.sa";
|
||||
import macroGrainline from "./macro.grainline";
|
||||
|
@ -52,48 +59,55 @@ var pattern = new freesewing.Pattern({ version: version, ...config }).with(
|
|||
);
|
||||
|
||||
pattern.draft = function() {
|
||||
this.parts.pointAttr = this.draftPointAttr(new pattern.Part());
|
||||
this.parts.pointDist = this.draftPointDist(new pattern.Part());
|
||||
this.parts.pointDx = this.draftPointDx(new pattern.Part());
|
||||
this.parts.pointDy = this.draftPointDy(new pattern.Part());
|
||||
this.parts.pointAngle = this.draftPointAngle(new pattern.Part());
|
||||
this.parts.pointRotate = this.draftPointRotate(new pattern.Part());
|
||||
this.parts.pointCopy = this.draftPointCopy(new pattern.Part());
|
||||
this.parts.pointFlipX = this.draftPointFlipX(new pattern.Part());
|
||||
this.parts.pointFlipY = this.draftPointFlipY(new pattern.Part());
|
||||
this.parts.pointShift = this.draftPointShift(new pattern.Part());
|
||||
this.parts.pointShiftTowards = this.draftPointShiftTowards(new pattern.Part());
|
||||
this.parts.pointShiftFractionTowards = this.draftPointShiftFractionTowards(new pattern.Part());
|
||||
this.parts.pointShiftOutwards = this.draftPointShiftOutwards(new pattern.Part());
|
||||
this.parts.pointSitsOn = this.draftPointSitsOn(new pattern.Part());
|
||||
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('pointSitsOn')) this.parts.pointSitsOn = this.draftPointSitsOn(new pattern.Part());
|
||||
if (this.needs('pointClone')) this.parts.pointClone = this.draftPointClone(new pattern.Part());
|
||||
|
||||
this.parts.pathOps = this.draftPathOps(new pattern.Part());
|
||||
this.parts.pathAttr = this.draftPathAttr(new pattern.Part());
|
||||
this.parts.pathOffset = this.draftPathOffset(new pattern.Part());
|
||||
this.parts.pathLength = this.draftPathLength(new pattern.Part());
|
||||
this.parts.pathStart = this.draftPathStart(new pattern.Part());
|
||||
this.parts.pathEnd = this.draftPathEnd(new pattern.Part());
|
||||
this.parts.pathClone = this.draftPathClone(new pattern.Part());
|
||||
this.parts.pathJoin = this.draftPathJoin(new pattern.Part());
|
||||
this.parts.pathReverse = this.draftPathReverse(new pattern.Part());
|
||||
this.parts.pathShiftAlong = this.draftPathShiftAlong(new pattern.Part());
|
||||
this.parts.pathShiftFractionAlong = this.draftPathShiftFractionAlong(new pattern.Part());
|
||||
this.parts.pathEdge = this.draftPathEdge(new pattern.Part());
|
||||
this.parts.pathCrossesX = this.draftPathCrossesX(new pattern.Part());
|
||||
this.parts.pathCrossesY = this.draftPathCrossesY(new pattern.Part());
|
||||
this.parts.pathIntersects = this.draftPathIntersects(new pattern.Part());
|
||||
this.parts.pathDivide = this.draftPathDivide(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('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());
|
||||
|
||||
this.parts.utilsLinesCross = this.draftUtilsLinesCross(new pattern.Part());
|
||||
this.parts.utilsBeamsCross = this.draftUtilsBeamsCross(new pattern.Part());
|
||||
this.parts.utilsBeamCrossesX = this.draftUtilsBeamCrossesX(new pattern.Part());
|
||||
this.parts.utilsBeamCrossesY = this.draftUtilsBeamCrossesY(new pattern.Part());
|
||||
this.parts.utilsCurveCrossesLine = this.draftUtilsCurveCrossesLine(new pattern.Part());
|
||||
this.parts.utilsCurveCrossesCurve = this.draftUtilsCurveCrossesCurve(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());
|
||||
|
||||
this.parts.settingsSa = this.draftSettingsSa(new pattern.Part());
|
||||
this.parts.macroGrainline = this.draftMacroGrainline(new pattern.Part());
|
||||
if (this.needs('settingsSa')) this.parts.settingsSa = this.draftSettingsSa(new pattern.Part());
|
||||
if (this.needs('macroGrainline')) this.parts.macroGrainline = this.draftMacroGrainline(new pattern.Part());
|
||||
return pattern;
|
||||
};
|
||||
|
||||
|
@ -125,17 +139,24 @@ pattern.draftPathReverse = part => pathReverse.draft(part);
|
|||
pattern.draftPathShiftAlong = part => pathShiftAlong.draft(part);
|
||||
pattern.draftPathShiftFractionAlong = part => pathShiftFractionAlong.draft(part);
|
||||
pattern.draftPathEdge = part => pathEdge.draft(part);
|
||||
pattern.draftPathCrossesX = part => pathCrossesX.draft(part);
|
||||
pattern.draftPathCrossesY = part => pathCrossesY.draft(part);
|
||||
pattern.draftPathIntersectsX = part => pathIntersectsX.draft(part);
|
||||
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.draftUtilsLinesCross = part => utilsLinesCross.draft(part);
|
||||
pattern.draftUtilsBeamsCross = part => utilsBeamsCross.draft(part);
|
||||
pattern.draftUtilsBeamCrossesX = part => utilsBeamCrossesX.draft(part);
|
||||
pattern.draftUtilsBeamCrossesY = part => utilsBeamCrossesY.draft(part);
|
||||
pattern.draftUtilsCurveCrossesLine = part => utilsCurveCrossesLine.draft(part);
|
||||
pattern.draftUtilsCurveCrossesCurve = part => utilsCurveCrossesCurve.draft(part);
|
||||
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.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.draftSettingsSa = part => settingsSa.draft(part);
|
||||
pattern.draftMacroGrainline = part => macroGrainline.draft(part);
|
||||
|
|
|
@ -32,7 +32,7 @@ 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.getUid()] = new Snippet('x', p);
|
||||
for (let p of paths.example1.intersects(paths.example2)) snippets[part.getId()] = new Snippet('x', p);
|
||||
|
||||
return part;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import freesewing from "freesewing";
|
||||
|
||||
var pathCrossesX = {
|
||||
var pathIntersectsX = {
|
||||
draft: function(part) {
|
||||
// prettier-ignore
|
||||
let {Point, points, Path, paths, Snippet, snippets, macro} = part.shorthand();
|
||||
|
@ -25,10 +25,10 @@ var pathCrossesX = {
|
|||
.curve(points.BCp2, points.CCp1, points.C)
|
||||
.curve(points.DCp1, points.DCp1, points.D);
|
||||
|
||||
for (let p of paths.example.crossesX(60)) snippets[part.getUid()] = new Snippet('x', p);
|
||||
for (let p of paths.example.intersectsX(60)) snippets[part.getId()] = new Snippet('x', p);
|
||||
|
||||
return part;
|
||||
}
|
||||
};
|
||||
|
||||
export default pathCrossesX;
|
||||
export default pathIntersectsX;
|
|
@ -1,6 +1,6 @@
|
|||
import freesewing from "freesewing";
|
||||
|
||||
var pathCrossesY = {
|
||||
var pathIntersectsY = {
|
||||
draft: function(part) {
|
||||
// prettier-ignore
|
||||
let {Point, points, Path, paths, Snippet, snippets, macro} = part.shorthand();
|
||||
|
@ -24,10 +24,10 @@ var pathCrossesY = {
|
|||
.line(points.B)
|
||||
.curve(points.BCp2, points.CCp1, points.C)
|
||||
.curve(points.DCp1, points.DCp1, points.D);
|
||||
for (let p of paths.example.crossesY(58)) snippets[part.getUid()] = new Snippet('x', p);
|
||||
for (let p of paths.example.intersectsY(58)) snippets[part.getId()] = new Snippet('x', p);
|
||||
|
||||
return part;
|
||||
}
|
||||
};
|
||||
|
||||
export default pathCrossesY;
|
||||
export default pathIntersectsY;
|
40
packages/examples/src/path.split.js
Normal file
40
packages/examples/src/path.split.js
Normal file
|
@ -0,0 +1,40 @@
|
|||
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;
|
60
packages/examples/src/utils.beamintersectscircle.js
Normal file
60
packages/examples/src/utils.beamintersectscircle.js
Normal file
|
@ -0,0 +1,60 @@
|
|||
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;
|
|
@ -1,6 +1,6 @@
|
|||
import freesewing from "freesewing";
|
||||
|
||||
var utilsBeamCrossesX = {
|
||||
var utilsBeamIntersectsX = {
|
||||
draft: function(part) {
|
||||
// prettier-ignore
|
||||
let {debug, Point, points, Path, paths, Snippet, snippets, utils} = part.shorthand();
|
||||
|
@ -12,7 +12,7 @@ var utilsBeamCrossesX = {
|
|||
.move(points.A)
|
||||
.line(points.B);
|
||||
|
||||
snippets.X = new Snippet('x', utils.beamCrossesX(
|
||||
snippets.X = new Snippet('x', utils.beamIntersectsX(
|
||||
points.A,
|
||||
points.B,
|
||||
40)
|
||||
|
@ -27,4 +27,4 @@ var utilsBeamCrossesX = {
|
|||
}
|
||||
};
|
||||
|
||||
export default utilsBeamCrossesX;
|
||||
export default utilsBeamIntersectsX;
|
|
@ -1,6 +1,6 @@
|
|||
import freesewing from "freesewing";
|
||||
|
||||
var utilsBeamCrossesY = {
|
||||
var utilsBeamIntersectsY = {
|
||||
draft: function(part) {
|
||||
// prettier-ignore
|
||||
let {debug, Point, points, Path, paths, Snippet, snippets, utils} = part.shorthand();
|
||||
|
@ -12,7 +12,7 @@ var utilsBeamCrossesY = {
|
|||
.move(points.A)
|
||||
.line(points.B);
|
||||
|
||||
snippets.X = new Snippet('x', utils.beamCrossesY(
|
||||
snippets.X = new Snippet('x', utils.beamIntersectsY(
|
||||
points.A,
|
||||
points.B,
|
||||
30)
|
||||
|
@ -27,4 +27,4 @@ var utilsBeamCrossesY = {
|
|||
}
|
||||
};
|
||||
|
||||
export default utilsBeamCrossesY;
|
||||
export default utilsBeamIntersectsY;
|
|
@ -1,6 +1,6 @@
|
|||
import freesewing from "freesewing";
|
||||
|
||||
var utilsBeamsCross = {
|
||||
var utilsBeamsIntersect = {
|
||||
draft: function(part) {
|
||||
// prettier-ignore
|
||||
let {debug, Point, points, Path, paths, Snippet, snippets, utils} = part.shorthand();
|
||||
|
@ -17,7 +17,7 @@ var utilsBeamsCross = {
|
|||
.move(points.C)
|
||||
.line(points.D);
|
||||
|
||||
snippets.X = new Snippet('x', utils.beamsCross(
|
||||
snippets.X = new Snippet('x', utils.beamsIntersect(
|
||||
points.A,
|
||||
points.B,
|
||||
points.C,
|
||||
|
@ -28,4 +28,4 @@ var utilsBeamsCross = {
|
|||
}
|
||||
};
|
||||
|
||||
export default utilsBeamsCross;
|
||||
export default utilsBeamsIntersect;
|
44
packages/examples/src/utils.circlesintersect.js
Normal file
44
packages/examples/src/utils.circlesintersect.js
Normal file
|
@ -0,0 +1,44 @@
|
|||
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;
|
|
@ -1,6 +1,6 @@
|
|||
import freesewing from "freesewing";
|
||||
|
||||
var utilsCurveCrossesCurve = {
|
||||
var utilsCurvesIntersect = {
|
||||
draft: function(part) {
|
||||
// prettier-ignore
|
||||
let {debug, Point, points, Path, paths, Snippet, snippets, utils} = part.shorthand();
|
||||
|
@ -21,7 +21,7 @@ var utilsCurveCrossesCurve = {
|
|||
.move(points.C)
|
||||
.curve(points.Ccp, points.Dcp, points.D);
|
||||
|
||||
for (let p of utils.curveCrossesCurve(
|
||||
for (let p of utils.curvesIntersect(
|
||||
points.A,
|
||||
points.Acp,
|
||||
points.Bcp,
|
||||
|
@ -29,10 +29,10 @@ var utilsCurveCrossesCurve = {
|
|||
points.C,
|
||||
points.Ccp,
|
||||
points.Dcp,
|
||||
points.D)) snippets[part.getUid()] = new Snippet('x', p);
|
||||
points.D)) snippets[part.getId()] = new Snippet('x', p);
|
||||
|
||||
return part;
|
||||
}
|
||||
};
|
||||
|
||||
export default utilsCurveCrossesCurve;
|
||||
export default utilsCurvesIntersect;
|
59
packages/examples/src/utils.lineintersectscircle.js
Normal file
59
packages/examples/src/utils.lineintersectscircle.js
Normal file
|
@ -0,0 +1,59 @@
|
|||
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;
|
|
@ -1,6 +1,6 @@
|
|||
import freesewing from "freesewing";
|
||||
|
||||
var utilsCurveCrossesLine = {
|
||||
var utilsLineIntersectsCurve = {
|
||||
draft: function(part) {
|
||||
// prettier-ignore
|
||||
let {debug, Point, points, Path, paths, Snippet, snippets, utils} = part.shorthand();
|
||||
|
@ -18,16 +18,16 @@ var utilsCurveCrossesLine = {
|
|||
.move(points.E)
|
||||
.line(points.D);
|
||||
|
||||
for (let p of freesewing.utils.curveCrossesLine(
|
||||
for (let p of freesewing.utils.lineIntersectsCurve(
|
||||
points.D,
|
||||
points.E,
|
||||
points.A,
|
||||
points.Acp,
|
||||
points.Bcp,
|
||||
points.B,
|
||||
points.E,
|
||||
points.D)) snippets[part.getUid()] = new Snippet('x', p);
|
||||
points.B)) snippets[part.getId()] = new Snippet('x', p);
|
||||
|
||||
return part;
|
||||
}
|
||||
};
|
||||
|
||||
export default utilsCurveCrossesLine;
|
||||
export default utilsLineIntersectsCurve;
|
|
@ -1,6 +1,6 @@
|
|||
import freesewing from "freesewing";
|
||||
|
||||
var utilsLinesCross = {
|
||||
var utilsLinesIntersect = {
|
||||
draft: function(part) {
|
||||
// prettier-ignore
|
||||
let {debug, Point, points, Path, paths, Snippet, snippets, utils} = part.shorthand();
|
||||
|
@ -17,7 +17,7 @@ var utilsLinesCross = {
|
|||
.move(points.C)
|
||||
.line(points.D);
|
||||
|
||||
snippets.X = new Snippet('x', utils.linesCross(
|
||||
snippets.X = new Snippet('x', utils.linesIntersect(
|
||||
points.A,
|
||||
points.B,
|
||||
points.C,
|
||||
|
@ -28,4 +28,4 @@ var utilsLinesCross = {
|
|||
}
|
||||
};
|
||||
|
||||
export default utilsLinesCross;
|
||||
export default utilsLinesIntersect;
|
52
packages/examples/src/utils.pointonbeam.js
Normal file
52
packages/examples/src/utils.pointonbeam.js
Normal file
|
@ -0,0 +1,52 @@
|
|||
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;
|
34
packages/examples/src/utils.pointoncurve.js
Normal file
34
packages/examples/src/utils.pointoncurve.js
Normal file
|
@ -0,0 +1,34 @@
|
|||
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;
|
51
packages/examples/src/utils.pointonline.js
Normal file
51
packages/examples/src/utils.pointonline.js
Normal file
|
@ -0,0 +1,51 @@
|
|||
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;
|
Loading…
Add table
Add a link
Reference in a new issue