sparkles: Added some more examples
This commit is contained in:
parent
7972178c6c
commit
e2fb7a48ba
6 changed files with 67 additions and 3 deletions
|
@ -3,7 +3,7 @@
|
|||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Examples</title>
|
||||
<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>
|
||||
|
@ -30,6 +30,13 @@
|
|||
// Some default settings
|
||||
pattern.settings.sa = 10;
|
||||
pattern.settings.units = 'metric';
|
||||
pattern.settings.only = 'macroGrainline';
|
||||
console.log('need1', pattern.needs('pointShift'));
|
||||
console.log('need2', pattern.needs('pointShiftTowards'));
|
||||
pattern.on('preRender', function(next) {
|
||||
this.style += 'svg { background: yellow;}';
|
||||
next();
|
||||
});
|
||||
|
||||
//pattern.sampleOption('chestEase');
|
||||
//pattern.sampleMeasurement('chestCircumference');
|
||||
|
|
|
@ -37,6 +37,9 @@ import utilsBeamsCross from "./utils.beamscross";
|
|||
import utilsBeamCrossesX from "./utils.beamcrossesx";
|
||||
import utilsBeamCrossesY from "./utils.beamcrossesy";
|
||||
|
||||
import settingsSa from "./settings.sa";
|
||||
import macroGrainline from "./macro.grainline";
|
||||
|
||||
var pattern = new freesewing.Pattern({ version: version, ...config }).with(
|
||||
pluginBundle
|
||||
);
|
||||
|
@ -75,6 +78,8 @@ pattern.draft = function() {
|
|||
this.parts.utilsBeamCrossesX = this.draftUtilsBeamCrossesX(new pattern.Part());
|
||||
this.parts.utilsbeamCrossesY = this.draftUtilsBeamCrossesY(new pattern.Part());
|
||||
|
||||
this.parts.settingsSa = this.draftSettingsSa(new pattern.Part());
|
||||
this.parts.macroGrainline = this.draftMacroGrainline(new pattern.Part());
|
||||
return pattern;
|
||||
};
|
||||
|
||||
|
@ -111,6 +116,9 @@ pattern.draftUtilsBeamsCross = part => utilsBeamsCross.draft(part);
|
|||
pattern.draftUtilsBeamCrossesX = part => utilsBeamCrossesX.draft(part);
|
||||
pattern.draftUtilsBeamCrossesY = part => utilsBeamCrossesY.draft(part);
|
||||
|
||||
pattern.draftSettingsSa = part => settingsSa.draft(part);
|
||||
pattern.draftMacroGrainline = part => macroGrainline.draft(part);
|
||||
|
||||
// Add custom snippet
|
||||
pattern.on('preRender', function(next) {
|
||||
this.defs += `
|
||||
|
|
19
packages/examples/src/macro.grainline.js
Normal file
19
packages/examples/src/macro.grainline.js
Normal file
|
@ -0,0 +1,19 @@
|
|||
import freesewing from "freesewing";
|
||||
|
||||
var macroGrainline = {
|
||||
draft: function(part) {
|
||||
// prettier-ignore
|
||||
let {Point, points, macro} = part.shorthand();
|
||||
|
||||
points.grainlineFrom = new Point(10, 10);
|
||||
points.grainlineTo = new Point(100, 10);
|
||||
|
||||
macro('grainline', {
|
||||
from: points.grainlineFrom,
|
||||
to: points.grainlineTo
|
||||
});
|
||||
return part;
|
||||
}
|
||||
};
|
||||
|
||||
export default macroGrainline;
|
|
@ -18,7 +18,7 @@ var pathShiftFractionAlong = {
|
|||
.curve(points.BCp2, points.CCp1, points.C);
|
||||
|
||||
|
||||
points.X1 = paths.example.shiftFractionAlong(0.25)
|
||||
points.X1 = paths.example.shiftFractionAlong(0.2)
|
||||
.attr('data-text', 'Shifted 20% along this path')
|
||||
.attr('data-text-class', 'center');
|
||||
points.X2 = paths.example.shiftFractionAlong(0.9)
|
||||
|
|
|
@ -8,7 +8,7 @@ var pointClone = {
|
|||
|
||||
box(part);
|
||||
|
||||
points.A= new Point(50, 25)
|
||||
points.A= new Point(25, 25)
|
||||
.attr('data-text', 'Point A')
|
||||
.attr('data-text-class', 'text-xl')
|
||||
.attr('data-text-fill-opacity', '0.5');
|
||||
|
|
30
packages/examples/src/settings.sa.js
Normal file
30
packages/examples/src/settings.sa.js
Normal file
|
@ -0,0 +1,30 @@
|
|||
import freesewing from "freesewing";
|
||||
import { box } from "./shared";
|
||||
|
||||
var pathOffset = {
|
||||
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.example = new Path()
|
||||
.move(points.A)
|
||||
.line(points.B)
|
||||
.curve(points.BCp2, points.CCp1, points.C)
|
||||
.line(points.A)
|
||||
.close()
|
||||
.attr('class', 'fabric');
|
||||
|
||||
paths.offset = paths.example.offset(-10)
|
||||
.attr('class', 'fabric sa');
|
||||
|
||||
return part;
|
||||
}
|
||||
};
|
||||
|
||||
export default pathOffset;
|
Loading…
Add table
Add a link
Reference in a new issue