1
0
Fork 0

🚧 Benjamin WIP

This commit is contained in:
Joost De Cock 2019-07-08 11:54:47 +02:00
parent 7542e2f6b9
commit f96ccc95e7
3 changed files with 328 additions and 311 deletions

View file

@ -17,27 +17,38 @@ export default {
dependencies: {}, dependencies: {},
inject: {}, inject: {},
hide: [], hide: [],
parts: ["front"], parts: ["base"],
options: { options: {
transitionLength: 0.7, // 70% of bandLength
bandLength: {
pct: 17,
min: 15,
max: 20
},
ribbonWidth: {
pct: 6,
min: 4,
max: 8
},
tipWidth: { tipWidth: {
mm: 65, pct: 15,
min: 24, min: 5,
max: 80 max: 20
}, },
knotWidth: { knotWidth: {
mm: 30, pct: 7,
min: 24, min: 6,
max: 40 max: 9
}, },
bowLength: { bowLength: {
mm: 120, pct: 28,
min: 100, min: 23,
max: 140 max: 33
}, },
collarEase: { collarEase: {
mm: 15, pct: 3,
min: 0, min: 0,
max: 15 max: 6
}, },
bowStyle: { bowStyle: {
dflt: "butterfly", dflt: "butterfly",
@ -47,9 +58,6 @@ export default {
dflt: "straight", dflt: "straight",
list: ["straight", "pointed", "rounded"] list: ["straight", "pointed", "rounded"]
}, },
adjustmentRibbon: { adjustmentRibbon: { bool: false }
dflt: "0",
list: ["0", "1"]
}
} }
}; };

View file

@ -1,293 +1,302 @@
function FlipAllPointsY(points, mirror, start, end) { function FlipAllPointsY(points, mirror, start, end) {
for (var point in points) { for (var point in points) {
if (point.substr(0, start.length) == start) { if (point.substr(0, start.length) == start) {
console.log(points[point]); console.log(points[point]);
points[end + point.substr(start.length)] = points[point].flipY(mirror); points[end + point.substr(start.length)] = points[point].flipY(mirror);
} }
} }
} }
export default function(part) { export default function(part) {
let { let {
store, store,
sa, sa,
Point, Point,
points, points,
Path, Path,
paths, paths,
Snippet, Snippet,
snippets, snippets,
options, options,
measurements, measurements,
final, final,
paperless, paperless,
macro macro
} = part.shorthand(); } = part.shorthand();
// Remove from here if (options.bowStyle === "square") options.tipWidth = options.knotWidth;
//options.bowStyle = 'butterfly';
//options.bowStyle = 'square'; for (let option of [
//options.bowStyle = 'widesquare'; "ribbonWidth",
//options.bowStyle = 'diamond'; "bandLength",
//options.endStyle = 'straight' ; "tipWidth",
//options.endStyle = 'rounded' ; "knotWidth",
//options.endStyle = 'pointed' ; "bowLength",
"collarEase"
//final = true; ])
//paperless = true; store.set(option, measurements.neckCircumference * options[option]);
//sa = 10;
// Remove to here // For easy access
const knot = store.get("knotWidth");
if (options.bowStyle == "square") options.tipWidth = options.knotWidth; const ribbon = store.get("ribbonWidth");
const tip = store.get("tipWidth");
let backWidth = 24; const band = store.get("bandLength");
let bandLength = 70; const transition = band * options.transitionLength;
let transitionLength = 50; const bow = store.get("bowLength");
let halfBackWidth = backWidth / 2;
let halfTipWidth = options.tipWidth / 2; // Points
let halfBowLength = options.bowLength / 2; points.bandTopLeft = new Point(0, ribbon / -2);
let halfKnotWidth = options.knotWidth / 2; points.bandBottomLeft = points.bandTopLeft.flipY();
points.bandTopRight = points.bandTopLeft.shift(0, band);
console.log(options.bowStyle); points.bandBottomRight = points.bandTopRight.flipY();
console.log(options.knotWidth);
points.transitionTopRight = new Point(band + transition, knot / -2);
let butterfly = points.transitionBottomRight = points.transitionTopRight.flipY();
options.bowStyle == "butterfly" || options.bowStyle == "diamond";
points.tip1Top = new Point(band + transition + 0.5 * bow, tip / -2);
let tipAdjustment = 0; points.tip1Bottom = points.tip1Top.flipY();
switch (options.endStyle) { points.tip2Top = new Point(band + transition + 1.5 * bow, tip / -2);
case "pointed": points.tip2Bottom = points.tip2Top.flipY();
tipAdjustment = halfTipWidth / 1.3; points.knotTop = new Point(band + transition + bow, knot / -2);
break; points.knotBottom = points.knotTop.flipY();
case "rounded":
tipAdjustment = halfTipWidth; if (options.endStyle === "pointed" || options.endStyle === "rounded") {
break; points.tip = new Point(points.tip2Bottom.x + points.tip2Bottom.y, 0);
} } else points.tip = new Point(points.tip2Bottom.x, 0);
let hhbl /*halfHalfBowLength */ = halfBowLength / 2; if (options.bowStyle === "diamond" || options.bowStyle === "butterfly") {
let bcAdjust = options.bowStyle == "diamond" ? 10 : hhbl - 5; const cpl = options.bowStyle === "diamond" ? bow / 10 : bow / 4;
let tieStart = new Path(); points.transitionBottomRightCp1 = points.bandBottomRight.shiftOutwards(
let tieLowKnot = new Path(); points.transitionBottomRight,
let tieTip = new Path(); cpl
let tieTopKnot = new Path(); );
let tieEnd = new Path(); points.transitionTopRightCp2 = points.transitionBottomRightCp1.flipY();
points.tip1TopCp2 = points.tip1Top.shift(180, cpl);
points.Origin = new Point(0, 0); points.tip1TopCp1 = points.tip1Top.shift(0, cpl);
points.tip1BottomCp1 = points.tip1Bottom.shift(180, cpl);
points.LowBandEdge = points.Origin.shift(-90, halfBackWidth); points.tip1BottomCp2 = points.tip1Bottom.shift(0, cpl);
points.LowKnotEdge = points.Origin.shift(-90, halfKnotWidth); points.knotTopCp2 = points.knotTop.shift(180, cpl);
points.LowTipEdge = points.Origin.shift(-90, halfTipWidth); points.knotTopCp1 = points.knotTop.shift(0, cpl);
points.knotBottomCp2 = points.knotBottom.shift(0, cpl);
points.LowBandStart = points.LowBandEdge.clone(); points.knotBottomCp1 = points.knotBottom.shift(180, cpl);
points.LowBandEnd = points.LowBandEdge.shift(0, bandLength); points.tip2TopCp2 = points.tip2Top.shift(180, cpl);
points.LowTransitionEnd = points.LowKnotEdge.shift( points.tip2BottomCp1 = points.tip2Bottom.shift(180, cpl);
0, }
bandLength + transitionLength
); paths.test = new Path()
.move(points.bandTopLeft)
console.log(points["LowBandEdge"].x); .line(points.bandTopRight)
.line(points.transitionTopRight)
tieStart .line(points.tip2Top)
.move(points.Origin) .line(points.tip)
.line(points.LowBandStart) .line(points.tip2Bottom)
.line(points.LowBandEnd) .line(points.transitionBottomRight)
.line(points.LowTransitionEnd); .line(points.bandBottomRight)
.line(points.bandBottomLeft)
points.LowTip = points.LowTipEdge.shift( .line(points.bandTopLeft)
0, .close();
bandLength + transitionLength + halfBowLength * 3
); return part;
points.Tip = points.Origin.shift(
0, let butterfly =
bandLength + transitionLength + halfBowLength * 3 + tipAdjustment options.bowStyle == "butterfly" || options.bowStyle == "diamond";
); //const bcAdjust = options.bowStyle == "diamond" ? 10 : hhbl - 5;
if (butterfly) { points.LowTip = points.LowTipEdge.shift(
points.LowTransitionEndCp2 = points.LowBandEnd.shiftOutwards( 0,
points.LowTransitionEnd, bandLength + transitionLength + halfBowLength * 3
bcAdjust );
); points.Tip = points.Origin.shift(
points.LowHump = points.LowTipEdge.shift( 0,
0, bandLength + transitionLength + halfBowLength * 3 + tipAdjustment
bandLength + transitionLength + halfBowLength );
);
points.LowHumpCp1 = points.LowHump.shift(180, bcAdjust); if (butterfly) {
points.LowHumpCp2 = points.LowHump.shift(0, bcAdjust); points.LowTransitionEndCp2 = points.LowBandEnd.shiftOutwards(
points.LowValley = points.LowKnotEdge.shift( points.LowTransitionEnd,
0, bcAdjust
bandLength + transitionLength + halfBowLength * 2 );
); points.LowHump = points.LowTipEdge.shift(
points.LowValleyCp1 = points.LowValley.shift(180, bcAdjust); 0,
points.LowValleyCp2 = points.LowValley.shift(0, bcAdjust); bandLength + transitionLength + halfBowLength
points.LowTipCp1 = points.LowTip.shift(180, bcAdjust); );
} points.LowHumpCp1 = points.LowHump.shift(180, bcAdjust);
points.LowHumpCp2 = points.LowHump.shift(0, bcAdjust);
points.LowTipCp2 = points.LowTip.shiftTowards( points.LowValley = points.LowKnotEdge.shift(
points.LowTipEdge, 0,
-tipAdjustment bandLength + transitionLength + halfBowLength * 2
); );
points.TipCp1 = points.Tip.shift(-90, halfTipWidth / 4); points.LowValleyCp1 = points.LowValley.shift(180, bcAdjust);
points.TipCp2 = points.Tip.shift(90, halfTipWidth / 4); points.LowValleyCp2 = points.LowValley.shift(0, bcAdjust);
points.LowTipCp1 = points.LowTip.shift(180, bcAdjust);
FlipAllPointsY(points, points.Origin, "Low", "Top"); }
if (options.endStyle == "rounded") { points.LowTipCp2 = points.LowTip.shiftTowards(
tieTip points.LowTipEdge,
.move(points.LowTip) -tipAdjustment
.curve(points.LowTipCp2, points.TipCp1, points.Tip) );
.curve(points.TipCp2, points.TopTipCp2, points.TopTip); points.TipCp1 = points.Tip.shift(-90, halfTipWidth / 4);
} else { points.TipCp2 = points.Tip.shift(90, halfTipWidth / 4);
tieTip
.move(points.LowTip) FlipAllPointsY(points, points.Origin, "Low", "Top");
.line(points.Tip)
.line(points.TopTip); if (options.endStyle == "rounded") {
} tieTip
.move(points.LowTip)
if (butterfly) { .curve(points.LowTipCp2, points.TipCp1, points.Tip)
tieLowKnot .curve(points.TipCp2, points.TopTipCp2, points.TopTip);
.move(points.LowTransitionEnd) } else {
.curve(points.LowTransitionEndCp2, points.LowHumpCp1, points.LowHump) tieTip
.curve(points.LowHumpCp2, points.LowValleyCp1, points.LowValley) .move(points.LowTip)
.curve(points.LowValleyCp2, points.LowTipCp1, points.LowTip); .line(points.Tip)
tieTopKnot = tieTopKnot .line(points.TopTip);
.move(points.TopTransitionEnd) }
.curve(points.TopTransitionEndCp2, points.TopHumpCp1, points.TopHump)
.curve(points.TopHumpCp2, points.TopValleyCp1, points.TopValley) if (butterfly) {
.curve(points.TopValleyCp2, points.TopTipCp1, points.TopTip) tieLowKnot
.reverse(); .move(points.LowTransitionEnd)
} .curve(points.LowTransitionEndCp2, points.LowHumpCp1, points.LowHump)
.curve(points.LowHumpCp2, points.LowValleyCp1, points.LowValley)
tieEnd .curve(points.LowValleyCp2, points.LowTipCp1, points.LowTip);
.move(points.TopTransitionEnd) tieTopKnot = tieTopKnot
.line(points.TopBandEnd) .move(points.TopTransitionEnd)
.line(points.TopBandStart) .curve(points.TopTransitionEndCp2, points.TopHumpCp1, points.TopHump)
.line(points.Origin); .curve(points.TopHumpCp2, points.TopValleyCp1, points.TopValley)
.curve(points.TopValleyCp2, points.TopTipCp1, points.TopTip)
paths.tie = new Path() .reverse();
.move(points.Origin) }
.join(tieStart)
.join(tieLowKnot) tieEnd
.join(tieTip) .move(points.TopTransitionEnd)
.join(tieTopKnot) .line(points.TopBandEnd)
.join(tieEnd) .line(points.TopBandStart)
.close() .line(points.Origin);
.attr("class", "fabric");
paths.tie = new Path()
// Final? .move(points.Origin)
if (final) { .join(tieStart)
points.grainlineLeft = points.Origin.shift(0, 30); .join(tieLowKnot)
points.grainlineRight = points.Origin.shift( .join(tieTip)
0, .join(tieTopKnot)
bandLength + transitionLength .join(tieEnd)
); .close()
macro("grainline", { .attr("class", "fabric");
from: points.grainlineLeft,
to: points.grainlineRight // Final?
}); if (final) {
points.grainlineLeft = points.Origin.shift(0, 30);
points.titleAnchor = points.Origin.shift( points.grainlineRight = points.Origin.shift(
0, 0,
bandLength + transitionLength + halfBowLength + 6 bandLength + transitionLength
); );
macro("title", { at: points.titleAnchor, nr: 1, title: "Bow Tie" }); macro("grainline", {
from: points.grainlineLeft,
if (!paperless) { to: points.grainlineRight
let scaleboxAnchor = points.LowTipEdge.shift(-90, 30).shift(0, 50); });
macro("scalebox", { at: scaleboxAnchor });
} points.titleAnchor = points.Origin.shift(
0,
let logoAnchor = points.Tip.shift(0, 40); bandLength + transitionLength + halfBowLength + 6
snippets.logo = new Snippet("logo", logoAnchor); );
macro("title", { at: points.titleAnchor, nr: 1, title: "Bow Tie" });
// Dummy line
let h1 = logoAnchor.shift(0, 50); if (!paperless) {
let h2 = h1.shift(0, 1); let scaleboxAnchor = points.LowTipEdge.shift(-90, 30).shift(0, 50);
macro("scalebox", { at: scaleboxAnchor });
paths.hidden = new Path() }
.move(h1)
.line(h2) let logoAnchor = points.Tip.shift(0, 40);
.attr("class", "hidden"); snippets.logo = new Snippet("logo", logoAnchor);
}
// Dummy line
if (sa) { let h1 = logoAnchor.shift(0, 50);
paths.sa = paths.tie.offset(sa).attr("class", "fabric sa"); let h2 = h1.shift(0, 1);
}
paths.hidden = new Path()
// Paperless? .move(h1)
if (paperless) { .line(h2)
macro("hd", { .attr("class", "hidden");
from: points.LowBandStart, }
to: points.LowBandEnd,
y: points.LowBandEdge.y + 15 if (sa) {
}); paths.sa = paths.tie.offset(sa).attr("class", "fabric sa");
macro("hd", { }
from: points.LowBandEnd,
to: points.LowTransitionEnd, // Paperless?
y: points.LowBandEdge.y + 15 if (paperless) {
}); macro("hd", {
macro("vd", { from: points.LowBandStart,
from: points.LowBandStart, to: points.LowBandEnd,
to: points.TopBandStart, y: points.LowBandEdge.y + 15
x: points.LowBandStart.x - 15 });
}); macro("hd", {
macro("vd", { from: points.LowBandEnd,
from: points.LowTip, to: points.LowTransitionEnd,
to: points.TopTip, y: points.LowBandEdge.y + 15
x: points.Tip.x + 15 });
}); macro("vd", {
from: points.LowBandStart,
if (butterfly) { to: points.TopBandStart,
macro("hd", { x: points.LowBandStart.x - 15
from: points.LowTransitionEnd, });
to: points.LowHump, macro("vd", {
y: points.LowTip.y + 15 from: points.LowTip,
}); to: points.TopTip,
macro("hd", { x: points.Tip.x + 15
from: points.LowHump, });
to: points.LowValley,
y: points.LowTip.y + 15 if (butterfly) {
}); macro("hd", {
macro("hd", { from: points.LowTransitionEnd,
from: points.LowValley, to: points.LowHump,
to: points.LowTip, y: points.LowTip.y + 15
y: points.LowTip.y + 15 });
}); macro("hd", {
from: points.LowHump,
//macro('vd', { from: points.LowTransitionEnd, to: points.TopTransitionEnd, x: points.LowTransitionEnd.x }); to: points.LowValley,
macro("vd", { y: points.LowTip.y + 15
from: points.LowHump, });
to: points.TopHump, macro("hd", {
x: points.LowHump.x from: points.LowValley,
}); to: points.LowTip,
macro("vd", { y: points.LowTip.y + 15
from: points.LowValley, });
to: points.TopValley,
x: points.LowValley.x //macro('vd', { from: points.LowTransitionEnd, to: points.TopTransitionEnd, x: points.LowTransitionEnd.x });
}); macro("vd", {
} else { from: points.LowHump,
if (options.bowStyle == "widesquare") { to: points.TopHump,
macro("vd", { x: points.LowHump.x
from: points.LowTransitionEnd, });
to: points.TopTransitionEnd, macro("vd", {
x: points.LowTransitionEnd.x from: points.LowValley,
}); to: points.TopValley,
} x: points.LowValley.x
macro("hd", { });
from: points.LowTransitionEnd, } else {
to: points.LowTip, if (options.bowStyle == "widesquare") {
y: points.LowTip.y + 15 macro("vd", {
}); from: points.LowTransitionEnd,
} to: points.TopTransitionEnd,
x: points.LowTransitionEnd.x
if (tipAdjustment) { });
macro("hd", { }
from: points.LowTip, macro("hd", {
to: points.Tip, from: points.LowTransitionEnd,
y: points.LowTip.y + 15 to: points.LowTip,
}); y: points.LowTip.y + 15
} });
} }
return part; if (tipAdjustment) {
} macro("hd", {
from: points.LowTip,
to: points.Tip,
y: points.LowTip.y + 15
});
}
}
return part;
}

View file

@ -2,12 +2,12 @@ import freesewing from "@freesewing/core";
import plugins from "@freesewing/plugin-bundle"; import plugins from "@freesewing/plugin-bundle";
import config from "../config"; import config from "../config";
// Parts // Parts
import draftFront from "./front"; import draftBase from "./base";
// Create new design // Create new design
const benjamin = new freesewing.Design(config, plugins); const benjamin = new freesewing.Design(config, plugins);
// Attach draft methods to prototype // Attach draft methods to prototype
benjamin.prototype.draftFront = draftFront; benjamin.prototype.draftBase = draftBase;
export default benjamin; export default benjamin;