1
0
Fork 0

🚧 Benjamin WIP

This commit is contained in:
Joost De Cock 2019-07-08 15:54:19 +02:00 committed by Joost De Cock
parent 45498afbba
commit c68c219fe3
9 changed files with 301 additions and 10831 deletions

View file

@ -15,9 +15,13 @@ export default {
},
measurements: ["neckCircumference"],
dependencies: {},
inject: {},
hide: [],
parts: ["base"],
inject: {
bow1: "base",
bow2: "base",
bow3: "base"
},
hide: ["base"],
parts: ["ribbon"],
options: {
transitionLength: 0.7, // 70% of bandLength
bandLength: {
@ -32,13 +36,13 @@ export default {
},
tipWidth: {
pct: 15,
min: 5,
min: 10,
max: 20
},
knotWidth: {
pct: 7,
min: 6,
max: 9
min: 5,
max: 10
},
bowLength: {
pct: 28,

View file

@ -18,11 +18,13 @@
"@material-ui/core": "^4.0.1",
"@material-ui/icons": "^4.0.1",
"@material-ui/lab": "^v4.0.0-alpha.14",
"axios": "^0.19.0",
"pattern": "link:..",
"prismjs": "1.16.0",
"react": "^16.8",
"react-dom": "^16.8",
"react-scripts": "^3.0.0",
"tlds": "^1.203.1",
"typeface-roboto-condensed": "latest"
},
"scripts": {

File diff suppressed because it is too large Load diff

View file

@ -1,12 +1,3 @@
function FlipAllPointsY(points, mirror, start, end) {
for (var point in points) {
if (point.substr(0, start.length) == start) {
console.log(points[point]);
points[end + point.substr(start.length)] = points[point].flipY(mirror);
}
}
}
export default function(part) {
let {
store,
@ -19,7 +10,7 @@ export default function(part) {
snippets,
options,
measurements,
final,
complete,
paperless,
macro
} = part.shorthand();
@ -45,33 +36,64 @@ export default function(part) {
const bow = store.get("bowLength");
// Points
points.bandTopLeft = new Point(0, ribbon / -2);
points.bandBottomLeft = points.bandTopLeft.flipY();
points.bandTopRight = points.bandTopLeft.shift(0, band);
points.bandBottomRight = points.bandTopRight.flipY();
points.bandBottomLeft = new Point(0, ribbon / 2);
points.bandTopLeft = points.bandBottomLeft.flipY();
points.bandBottomRight = points.bandBottomLeft.shift(0, band);
points.bandTopRight = points.bandBottomRight.flipY();
points.transitionTopRight = new Point(band + transition, knot / -2);
points.transitionBottomRight = points.transitionTopRight.flipY();
points.transitionBottomRight = new Point(band + transition, knot / 2);
points.transitionTopRight = points.transitionBottomRight.flipY();
points.tip1Top = new Point(band + transition + 0.5 * bow, tip / -2);
points.tip1Bottom = points.tip1Top.flipY();
points.tip2Top = new Point(band + transition + 1.5 * bow, tip / -2);
points.tip2Bottom = points.tip2Top.flipY();
points.knotTop = new Point(band + transition + bow, knot / -2);
points.knotBottom = points.knotTop.flipY();
points.tip1Bottom = new Point(band + transition + 0.5 * bow, tip / 2);
points.tip1Top = points.tip1Bottom.flipY();
points.tip2Bottom = new Point(band + transition + 1.5 * bow, tip / 2);
points.tip2Top = points.tip2Bottom.flipY();
points.knotBottom = new Point(band + transition + bow, knot / 2);
points.knotTop = points.knotBottom.flipY();
if (options.endStyle === "pointed" || options.endStyle === "rounded") {
points.tip = new Point(points.tip2Bottom.x + points.tip2Bottom.y, 0);
} else points.tip = new Point(points.tip2Bottom.x, 0);
points.grainlineStart = new Point(0, 0);
points.titleAnchor = new Point(points.tip1Top.x, 0);
// Paths
paths.cap = new Path().move(points.tip2Bottom);
if (options.endStyle === "straight") {
paths.cap = new Path().move(points.tip2Bottom).line(points.tip2Top);
} else if (options.endStyle === "pointed") {
paths.cap = new Path()
.move(points.tip2Bottom)
.line(points.tip)
.line(points.tip2Top);
} else {
points.roundBottom = new Point(points.tip.x, points.tip2Bottom.y);
points.roundTop = points.roundBottom.flipY();
macro("round", {
from: points.tip2Bottom,
to: points.tip,
via: points.roundBottom,
prefix: "bottom"
});
macro("round", {
from: points.tip,
to: points.tip2Top,
via: points.roundTop,
prefix: "top"
});
paths.cap = paths.bottomRounded.join(paths.topRounded);
}
paths.cap.render = false;
if (options.bowStyle === "diamond" || options.bowStyle === "butterfly") {
const cpl = options.bowStyle === "diamond" ? bow / 10 : bow / 4;
points.transitionBottomRightCp1 = points.bandBottomRight.shiftOutwards(
points.transitionBottomRightCp2 = points.bandBottomRight.shiftOutwards(
points.transitionBottomRight,
cpl
);
points.transitionTopRightCp2 = points.transitionBottomRightCp1.flipY();
points.transitionTopRightCp1 = points.transitionBottomRightCp2.flipY();
points.tip1TopCp2 = points.tip1Top.shift(180, cpl);
points.tip1TopCp1 = points.tip1Top.shift(0, cpl);
points.tip1BottomCp1 = points.tip1Bottom.shift(180, cpl);
@ -82,219 +104,120 @@ export default function(part) {
points.knotBottomCp1 = points.knotBottom.shift(180, cpl);
points.tip2TopCp2 = points.tip2Top.shift(180, cpl);
points.tip2BottomCp1 = points.tip2Bottom.shift(180, cpl);
}
paths.test = new Path()
.move(points.bandTopLeft)
.line(points.bandTopRight)
.line(points.transitionTopRight)
.line(points.tip2Top)
.line(points.tip)
.line(points.tip2Bottom)
.line(points.transitionBottomRight)
.line(points.bandBottomRight)
.line(points.bandBottomLeft)
.line(points.bandTopLeft)
.close();
return part;
let butterfly =
options.bowStyle == "butterfly" || options.bowStyle == "diamond";
//const bcAdjust = options.bowStyle == "diamond" ? 10 : hhbl - 5;
points.LowTip = points.LowTipEdge.shift(
0,
bandLength + transitionLength + halfBowLength * 3
);
points.Tip = points.Origin.shift(
0,
bandLength + transitionLength + halfBowLength * 3 + tipAdjustment
);
if (butterfly) {
points.LowTransitionEndCp2 = points.LowBandEnd.shiftOutwards(
points.LowTransitionEnd,
bcAdjust
);
points.LowHump = points.LowTipEdge.shift(
0,
bandLength + transitionLength + halfBowLength
);
points.LowHumpCp1 = points.LowHump.shift(180, bcAdjust);
points.LowHumpCp2 = points.LowHump.shift(0, bcAdjust);
points.LowValley = points.LowKnotEdge.shift(
0,
bandLength + transitionLength + halfBowLength * 2
);
points.LowValleyCp1 = points.LowValley.shift(180, bcAdjust);
points.LowValleyCp2 = points.LowValley.shift(0, bcAdjust);
points.LowTipCp1 = points.LowTip.shift(180, bcAdjust);
}
points.LowTipCp2 = points.LowTip.shiftTowards(
points.LowTipEdge,
-tipAdjustment
);
points.TipCp1 = points.Tip.shift(-90, halfTipWidth / 4);
points.TipCp2 = points.Tip.shift(90, halfTipWidth / 4);
FlipAllPointsY(points, points.Origin, "Low", "Top");
if (options.endStyle == "rounded") {
tieTip
.move(points.LowTip)
.curve(points.LowTipCp2, points.TipCp1, points.Tip)
.curve(points.TipCp2, points.TopTipCp2, points.TopTip);
paths.seam = new Path()
.move(points.bandTopLeft)
.line(points.bandBottomLeft)
.line(points.bandBottomRight)
.line(points.transitionBottomRight)
.curve(
points.transitionBottomRightCp2,
points.tip1BottomCp1,
points.tip1Bottom
)
.curve(points.tip1BottomCp2, points.knotBottomCp1, points.knotBottom)
.curve(points.knotBottomCp2, points.tip2BottomCp1, points.tip2Bottom)
.join(paths.cap)
.line(points.tip2Top)
.curve(points.tip2TopCp2, points.knotTopCp1, points.knotTop)
.curve(points.knotTopCp2, points.tip1TopCp1, points.tip1Top)
.curve(
points.tip1TopCp2,
points.transitionTopRightCp1,
points.transitionTopRight
)
.line(points.bandTopRight)
.line(points.bandTopLeft)
.close();
} else {
tieTip
.move(points.LowTip)
.line(points.Tip)
.line(points.TopTip);
paths.seam = new Path()
.move(points.bandTopLeft)
.line(points.bandBottomLeft)
.line(points.bandBottomRight)
.line(points.transitionBottomRight)
.line(points.tip2Bottom)
.join(paths.cap)
.line(points.tip2Top)
.line(points.transitionTopRight)
.line(points.bandTopRight)
.line(points.bandTopLeft)
.close();
}
if (butterfly) {
tieLowKnot
.move(points.LowTransitionEnd)
.curve(points.LowTransitionEndCp2, points.LowHumpCp1, points.LowHump)
.curve(points.LowHumpCp2, points.LowValleyCp1, points.LowValley)
.curve(points.LowValleyCp2, points.LowTipCp1, points.LowTip);
tieTopKnot = tieTopKnot
.move(points.TopTransitionEnd)
.curve(points.TopTransitionEndCp2, points.TopHumpCp1, points.TopHump)
.curve(points.TopHumpCp2, points.TopValleyCp1, points.TopValley)
.curve(points.TopValleyCp2, points.TopTipCp1, points.TopTip)
.reverse();
}
paths.seam.attr("class", "fabric");
tieEnd
.move(points.TopTransitionEnd)
.line(points.TopBandEnd)
.line(points.TopBandStart)
.line(points.Origin);
// Complete?
if (complete) {
if (sa) paths.sa = paths.seam.offset(sa).attr("class", "fabric sa");
paths.tie = new Path()
.move(points.Origin)
.join(tieStart)
.join(tieLowKnot)
.join(tieTip)
.join(tieTopKnot)
.join(tieEnd)
.close()
.attr("class", "fabric");
// Final?
if (final) {
points.grainlineLeft = points.Origin.shift(0, 30);
points.grainlineRight = points.Origin.shift(
0,
bandLength + transitionLength
);
macro("grainline", {
from: points.grainlineLeft,
to: points.grainlineRight
from: points.grainlineStart,
to: points.tip
});
points.titleAnchor = points.Origin.shift(
0,
bandLength + transitionLength + halfBowLength + 6
points.logoAnchor = points.tip.shift(180, 20);
snippets.logo = new Snippet("logo", points.logoAnchor).attr(
"data-scale",
0.5
);
macro("title", { at: points.titleAnchor, nr: 1, title: "Bow Tie" });
if (!paperless) {
let scaleboxAnchor = points.LowTipEdge.shift(-90, 30).shift(0, 50);
macro("scalebox", { at: scaleboxAnchor });
}
let logoAnchor = points.Tip.shift(0, 40);
snippets.logo = new Snippet("logo", logoAnchor);
// Dummy line
let h1 = logoAnchor.shift(0, 50);
let h2 = h1.shift(0, 1);
paths.hidden = new Path()
.move(h1)
.line(h2)
.attr("class", "hidden");
}
if (sa) {
paths.sa = paths.tie.offset(sa).attr("class", "fabric sa");
}
// Paperless?
if (paperless) {
macro("hd", {
from: points.LowBandStart,
to: points.LowBandEnd,
y: points.LowBandEdge.y + 15
});
macro("hd", {
from: points.LowBandEnd,
to: points.LowTransitionEnd,
y: points.LowBandEdge.y + 15
});
macro("vd", {
from: points.LowBandStart,
to: points.TopBandStart,
x: points.LowBandStart.x - 15
});
macro("vd", {
from: points.LowTip,
to: points.TopTip,
x: points.Tip.x + 15
});
if (butterfly) {
macro("hd", {
from: points.LowTransitionEnd,
to: points.LowHump,
y: points.LowTip.y + 15
});
macro("hd", {
from: points.LowHump,
to: points.LowValley,
y: points.LowTip.y + 15
});
macro("hd", {
from: points.LowValley,
to: points.LowTip,
y: points.LowTip.y + 15
});
//macro('vd', { from: points.LowTransitionEnd, to: points.TopTransitionEnd, x: points.LowTransitionEnd.x });
macro("vd", {
from: points.LowHump,
to: points.TopHump,
x: points.LowHump.x
});
macro("vd", {
from: points.LowValley,
to: points.TopValley,
x: points.LowValley.x
});
} else {
if (options.bowStyle == "widesquare") {
// Paperless?
if (paperless) {
let baseY = points.tip2Bottom.y + 15 + sa;
if (options.bowStyle === "butterfly" || options.bowStyle === "diamond") {
macro("hd", {
from: points.knotBottom,
to: points.tip2Bottom,
y: baseY
});
baseY += 15;
macro("hd", {
from: points.tip1Bottom,
to: points.tip2Bottom,
y: baseY
});
baseY += 15;
macro("vd", {
from: points.LowTransitionEnd,
to: points.TopTransitionEnd,
x: points.LowTransitionEnd.x
from: points.tip1Bottom,
to: points.tip1Top
});
}
macro("hd", {
from: points.LowTransitionEnd,
to: points.LowTip,
y: points.LowTip.y + 15
from: points.transitionBottomRight,
to: points.tip2Bottom,
y: baseY
});
}
if (tipAdjustment) {
baseY += 15;
macro("hd", {
from: points.LowTip,
to: points.Tip,
y: points.LowTip.y + 15
from: points.bandBottomRight,
to: points.tip2Bottom,
y: baseY
});
baseY += 15;
macro("hd", {
from: points.bandBottomLeft,
to: points.tip2Bottom,
y: baseY
});
macro("vd", {
from: points.bandBottomRight,
to: points.bandTopRight
});
macro("vd", {
from: points.transitionBottomRight,
to: points.transitionTopRight
});
macro("vd", {
from: points.tip2Bottom,
to: points.tip2Top,
x: points.tip.x + 15 + sa
});
if (options.endStyle !== "straight") {
macro("hd", {
from: points.tip2Bottom,
to: points.tip,
y: points.tip2Bottom.y + 15 + sa
});
}
}
}

View file

@ -0,0 +1,27 @@
export default function(part) {
let {
complete,
macro,
points,
paths,
snippets,
Snippet,
sa
} = part.shorthand();
paths.seam.render = true;
if (complete) {
if (sa) paths.sa.render = true;
macro("title", {
at: points.titleAnchor,
nr: 1,
title: "bowTie",
scale: 0.8
});
points.scaleboxAnchor = points.bandTopLeft.shift(30, 80);
macro("scalebox", { at: points.scaleboxAnchor });
}
return part;
}

View file

@ -0,0 +1,22 @@
export default function(part) {
let { options, points, paths, complete, macro, sa } = part.shorthand();
if (options.adjustmentRibbon) {
part.render = false;
return part;
}
paths.seam.render = true;
if (complete) {
if (sa) paths.sa.render = true;
macro("title", {
at: points.titleAnchor,
nr: 2,
title: "bowTie",
scale: 0.8
});
}
return part;
}

View file

@ -0,0 +1,20 @@
export default function(part) {
let { options, points, paths, complete, macro, sa } = part.shorthand();
if (options.adjustmentRibbon) {
part.render = false;
return part;
}
if (complete) {
if (sa) paths.sa.render = true;
macro("title", {
at: points.titleAnchor,
nr: 3,
title: "bowTie",
scale: 0.8
});
}
return part;
}

View file

@ -3,11 +3,19 @@ import plugins from "@freesewing/plugin-bundle";
import config from "../config";
// Parts
import draftBase from "./base";
import draftBow1 from "./bow1";
import draftBow2 from "./bow2";
import draftBow3 from "./bow3";
import draftRibbon from "./ribbon";
// Create new design
const benjamin = new freesewing.Design(config, plugins);
// Attach draft methods to prototype
benjamin.prototype.draftBase = draftBase;
benjamin.prototype.draftBow1 = draftBow1;
benjamin.prototype.draftBow2 = draftBow2;
benjamin.prototype.draftBow3 = draftBow3;
benjamin.prototype.draftRibbon = draftRibbon;
export default benjamin;

View file

@ -0,0 +1,69 @@
export default function(part) {
let {
Point,
Path,
measurements,
store,
options,
complete,
macro,
points,
paths,
sa,
paperless
} = part.shorthand();
if (!options.adjustmentRibbon) {
part.render = false;
return part;
}
// Points
points.bottomLeft = new Point(0, 0.5 * store.get("ribbonWidth"));
points.topLeft = points.bottomLeft.flipY();
// FIXME: How long should this adjustment ribbon be?
points.bottomRight = points.bottomLeft.shift(
0,
measurements.neckCircumference
);
points.topRight = points.bottomRight.flipY();
points.titleAnchor = points.topLeft.shiftFractionTowards(
points.bottomRight,
0.5
);
// Paths
paths.seam = new Path()
.move(points.topLeft)
.line(points.bottomLeft)
.line(points.bottomRight)
.line(points.topRight)
.line(points.topLeft)
.close()
.attr("class", "fabric");
if (complete) {
if (sa) paths.sa = paths.seam.offset(sa).attr("class", "fabric sa");
macro("title", {
at: points.titleAnchor,
nr: 4,
title: "ribbon",
scale: 0.5
});
if (paperless) {
macro("hd", {
from: points.bottomLeft,
to: points.bottomRight,
y: points.bottomLeft.y + 15 + sa
});
macro("vd", {
from: points.bottomRight,
to: points.topRight,
x: points.topRight.x + 15 + sa
});
}
}
return part;
}