1
0
Fork 0

construction: Pre work on offsets

This commit is contained in:
joostdecock 2018-07-26 13:43:45 +00:00 committed by Joost De Cock
parent 5e7c8f110a
commit fceb73f4ea
5 changed files with 175 additions and 8 deletions

View file

@ -8,12 +8,12 @@
<div id="svg"></div>
<script type="text/javascript" src="freesewing.js"></script>
<script type="text/javascript" src="dist/module.js"></script>
<script type="text/javascript" src="https://unpkg.com/@freesewing/plugin-theme"></script>
<script type="text/javascript" src="https://unpkg.com/@freesewing/plugin-designer"></script>
<script type="text/javascript" src="tmp/theme.js"></script>
<script type="text/javascript" src="tmp/designer.js"></script>
<script>
var pattern = brian
.with(freesewing.plugins.theme)
//.with(freesewing.plugins.designer);
.with(freesewing.plugins.designer);
pattern.settings.measurements = {
bicepsCircumference: 335,

View file

@ -48,6 +48,19 @@ var back = {
points.logo = points.title.shift(-90, 100);
snippets.logo = new F.snippet("logo", points.logo);
console.log("path offset");
points.t1 = new F.point(100, 400);
points.t2 = new F.point(200, 400);
points.t3 = new F.point(200, 500);
points.t4 = new F.point(100, 500);
paths.test = new F.path()
.move(points.t1)
.line(points.t2)
.line(points.t3)
.line(points.t4)
.close();
paths.test.offset(10);
};
if (final) {

View file

@ -5,15 +5,11 @@ import logo from "@freesewing/plugin-logo";
import config from "../config/config";
import back from "./back";
import { version } from "../package.json";
console.log("logo is", logo);
var pattern = new freesewing.pattern({ version: version, ...config })
.with(cutonfold)
.with(title)
.with(logo);
//pattern.on("preRenderSvg", function(next) {
// this.attributes.add(`freesewing:${name}`, version);
// next();
//});
pattern.draft = function() {
back.draft(pattern.parts.back);

View file

@ -0,0 +1,135 @@
/**
* @freesewing/plugin-designer | v0.4.2
* The plugin for freesewing to facilitate pattern design
* (c) 2018 Joost De Cock <joost@decock.org> (https://github.com/joostdecock)
* @license MIT
*/
(this.freesewing = this.freesewing || {}),
(this.freesewing.plugins = this.freesewing.plugins || {}),
(this.freesewing.plugins.designer = (function() {
"use strict";
return {
hooks: {
preRenderSvg: function(t) {
(this.script +=
"\nfunction pointHover(evt) {\n var point = evt.target;\n var id = point.id;\n var cx = point.getAttribute('x');\n var cy = point.getAttribute('y');\n var name = point.getAttribute('data-point');\n var part = point.getAttribute('data-part');\n console.log(name+' ('+cx+', '+cy+') @ '+part);\n var scale = 2;\n cx = cx-scale*cx;\n cy = cy-scale*cy;\n point.setAttribute(\"transform\", 'matrix('+scale+', 0, 0, '+scale+', '+cx+', '+cy+')');\n pointUnhover(id);\n}\nfunction pointUnhover(id) {\n setTimeout(function(){\n document.getElementById(id).removeAttribute(\"transform\", '');\n }, 500);\n}\n"),
(this.defs +=
'\n<g id="point">\n <circle cy="0" cx="0" r="2" class="note stroke-sm" />\n <circle cy="0" cx="0" r="0.8" class="fill-note" />\n</g>\n<g id="point-hidden">\n <circle cy="0" cx="0" r="1" class="canvas stroke-xs" />\n <path d="M -0.5,-0.5 L 0.5,0.5 M 0.5,-0.5 L -0.5,0.5" class="canvas stroke-sm" />\n</g>\n<g id="path-move-point">\n <circle cx="0" cy="0" r="2" class="interfacing stroke-lg" />\n <circle cx="0" cy="0" r="0.8" class="fill-interfacing" />\n</g>\n<g id="path-line-point">\n <circle cx="0" cy="0" r="2" class="note stroke-lg" />\n <circle cx="0" cy="0" r="0.8" class="fill-note" />\n</g>\n<g id="path-curve-point"> <use xlink:href = "#path-line-point"/> </g>\n<g id="path-handle-point">\n <circle cx="0" cy="0" r="1" class="fill-various" />\n</g>\n'),
this.attributes.add("freesewing:theme-designer", "0.4.2");
var e = function(t, e, n, i, a, r, s) {
(n[t] = new e(`path-${a}-point`, i, `Path ${r}: ${a}`)),
n[t].attributes.add("onmouseover", "pointHover(evt)"),
n[t].attributes.add("id", t),
n[t].attributes.add(
"data-point",
i.attributes.get("data-point")
),
n[t].attributes.add("data-path", r),
n[t].attributes.add("data-part", s);
},
n = function(t, e, n, i, a, r, s) {
let p = new e().move(i).line(a);
p.attributes.add(
"class",
"curve-control stroke-various stroke-sm"
),
p.attributes.add("id", t),
p.attributes.add("data-path", r),
p.attributes.add("data-part", s),
(n[t] = p);
};
!(function(t) {
for (let e in t.pattern.parts) {
let n = t.pattern.parts[e];
if (n.render)
for (let i in n.points) {
let a = n.points[i];
a.attributes.add("id", t.getUid()),
a.attributes.add("data-point", i),
a.attributes.add("data-part", e);
let r = "_" === i.substr(0, 1) ? "point-hidden" : "point",
s = t.getUid();
(n.snippets[s] = new t.pattern.snippet(
r,
a,
`Point ${i} in part ${e}`
)),
n.snippets[s].attributes.add(
"onmouseover",
"pointHover(evt)"
),
n.snippets[s].attributes.add("id", s),
n.snippets[s].attributes.add("data-point", i),
n.snippets[s].attributes.add("data-part", e);
}
}
})(this),
(function(t) {
for (let i in t.pattern.parts) {
let a = t.pattern.parts[i];
if (a.render)
for (let r in a.paths) {
let s,
p = a.paths[r];
if (!p.render) return !1;
for (let o of p.ops)
"close" !== o.type &&
e(
t.getUid(),
t.pattern.snippet,
a.snippets,
o.to,
o.type,
r,
i
),
"curve" === o.type &&
(e(
t.getUid(),
t.pattern.snippet,
a.snippets,
o.cp1,
"handle",
r,
i
),
e(
t.getUid(),
t.pattern.snippet,
a.snippets,
o.cp2,
"handle",
r,
i
),
n(
t.getUid(),
t.pattern.path,
a.paths,
s,
o.cp1,
r,
i
),
n(
t.getUid(),
t.pattern.path,
a.paths,
o.to,
o.cp2,
r,
i
)),
(s = o.to);
}
}
})(this),
console.log(
"Designer plugin: Here's the pattern object:",
this.pattern
),
t();
}
}
};
})());

View file

@ -0,0 +1,23 @@
/**
* @freesewing/plugin-theme | v0.6.0
* A freesewing plugin that provides a default theme
* (c) 2018 Joost De Cock <joost@decock.org> (https://github.com/joostdecock)
* @license MIT
*/
(this.freesewing = this.freesewing || {}),
(this.freesewing.plugins = this.freesewing.plugins || {}),
(this.freesewing.plugins.theme = (function() {
"use strict";
return {
hooks: {
preRenderSvg: function(e) {
(this.style +=
'path,circle,rect{fill:none;stroke:none}path{stroke:#000;stroke-opacity:1;stroke-width:.3;stroke-linecap:round;stroke-linejoin:round}.fabric{stroke-width:.6;stroke:#212121}.lining{stroke-width:.6;stroke:#ff5b77}.interfacing{stroke-width:.6;stroke:#64b5f6}.canvas{stroke-width:.6;stroke:#ff9000}.various{stroke-width:.6;stroke:#4caf50}.note{stroke-width:.4;stroke:#dd60dd}.fill-fabric{fill:#212121}.fill-lining{fill:#ff5b77}.fill-interfacing{fill:#64b5f6}.fill-canvas{fill:#ff9000}.fill-various{fill:#4caf50}.fill-note{fill:#dd69dd}text{font-size:5px;font-family:-apple-system,system-ui,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;fill:#000;text-anchor:start;font-weight:200;dominant-baseline:ideographic}.text-xs{font-size:3px}.text-sm{font-size:4px}.text-lg{font-size:7px}.text-xl{font-size:9px}.text-xxl{font-size:12px}.center{text-anchor:middle}.right{text-anchor:end}.stroke-xs{stroke-width:.1}.stroke-sm{stroke-width:.2}.stroke-lg{stroke-width:.6}.stroke-xl{stroke-width:1}.stroke-xxl{stroke-width:2}.sa{stroke-dasharray:.4,.8}.help{stroke-width:.2;stroke-dasharray:15,1.5,1,1.5}.dotted{stroke-dasharray:.4,.8}.dashed{stroke-dasharray:1,1.5}.lashed{stroke-dasharray:6,6}.hidden{stroke:none;fill:none}'),
(this.defs +=
'<g id="notch"><circle cy="0" cx="0" r="1.4" class="fill-mark" /><circle cy="0" cx="0" r="2.8" class="stroke-mark stroke-xl" /></g>'),
this.attributes.add("freesewing:plugin-theme", "0.6.0"),
e();
}
}
};
})());