construction: Fixed new snippet call
This commit is contained in:
parent
fccacff330
commit
9742ccfe65
7 changed files with 558 additions and 426 deletions
|
@ -1,3 +0,0 @@
|
||||||
{
|
|
||||||
"presets": ["env"]
|
|
||||||
}
|
|
21
packages/plugin-designer/LICENSE
Normal file
21
packages/plugin-designer/LICENSE
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2018 Joost De Cock
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
21
packages/plugin-designer/dist/module.js
vendored
21
packages/plugin-designer/dist/module.js
vendored
|
@ -70,6 +70,7 @@ var snippets = `
|
||||||
var version = "0.3.0";
|
var version = "0.3.0";
|
||||||
|
|
||||||
var index = {
|
var index = {
|
||||||
|
hooks: {
|
||||||
preRenderSvg: function(next) {
|
preRenderSvg: function(next) {
|
||||||
// Add style, script and snippets
|
// Add style, script and snippets
|
||||||
this.style += style;
|
this.style += style;
|
||||||
|
@ -77,10 +78,6 @@ var index = {
|
||||||
this.defs += snippets;
|
this.defs += snippets;
|
||||||
|
|
||||||
// Add SVG attributes
|
// Add SVG attributes
|
||||||
this.attributes.add(
|
|
||||||
"xmlns:freesewing",
|
|
||||||
"http://freesewing.org/namespaces/freesewing"
|
|
||||||
);
|
|
||||||
this.attributes.add("freesewing:theme-designer", version);
|
this.attributes.add("freesewing:theme-designer", version);
|
||||||
|
|
||||||
/** Decorares points with extra info */
|
/** Decorares points with extra info */
|
||||||
|
@ -93,14 +90,18 @@ var index = {
|
||||||
point.attributes.add("id", svg.getUid());
|
point.attributes.add("id", svg.getUid());
|
||||||
point.attributes.add("data-point", pointId);
|
point.attributes.add("data-point", pointId);
|
||||||
point.attributes.add("data-part", partId);
|
point.attributes.add("data-part", partId);
|
||||||
let type = pointId.substr(0, 1) === "_" ? "point-hidden" : "point";
|
let type =
|
||||||
|
pointId.substr(0, 1) === "_" ? "point-hidden" : "point";
|
||||||
let id = svg.getUid();
|
let id = svg.getUid();
|
||||||
part.snippets[id] = new svg.pattern.snippet(
|
part.snippets[id] = new svg.pattern.snippet(
|
||||||
point,
|
|
||||||
type,
|
type,
|
||||||
|
point,
|
||||||
`Point ${pointId} in part ${partId}`
|
`Point ${pointId} in part ${partId}`
|
||||||
);
|
);
|
||||||
part.snippets[id].attributes.add("onmouseover", "pointHover(evt)");
|
part.snippets[id].attributes.add(
|
||||||
|
"onmouseover",
|
||||||
|
"pointHover(evt)"
|
||||||
|
);
|
||||||
part.snippets[id].attributes.add("id", id);
|
part.snippets[id].attributes.add("id", id);
|
||||||
part.snippets[id].attributes.add("data-point", pointId);
|
part.snippets[id].attributes.add("data-point", pointId);
|
||||||
part.snippets[id].attributes.add("data-part", partId);
|
part.snippets[id].attributes.add("data-part", partId);
|
||||||
|
@ -120,8 +121,8 @@ var index = {
|
||||||
partId
|
partId
|
||||||
) {
|
) {
|
||||||
snippets$$1[id] = new Snippet(
|
snippets$$1[id] = new Snippet(
|
||||||
point,
|
|
||||||
`path-${type}-point`,
|
`path-${type}-point`,
|
||||||
|
point,
|
||||||
`Path ${pathId}: ${type}`
|
`Path ${pathId}: ${type}`
|
||||||
);
|
);
|
||||||
snippets$$1[id].attributes.add("onmouseover", "pointHover(evt)");
|
snippets$$1[id].attributes.add("onmouseover", "pointHover(evt)");
|
||||||
|
@ -160,6 +161,7 @@ var index = {
|
||||||
for (let pathId in part.paths) {
|
for (let pathId in part.paths) {
|
||||||
let path = part.paths[pathId];
|
let path = part.paths[pathId];
|
||||||
if (!path.render) return false;
|
if (!path.render) return false;
|
||||||
|
let current;
|
||||||
for (let op of path.ops) {
|
for (let op of path.ops) {
|
||||||
if (op.type !== "close") {
|
if (op.type !== "close") {
|
||||||
decoratePathPoint(
|
decoratePathPoint(
|
||||||
|
@ -210,7 +212,7 @@ var index = {
|
||||||
partId
|
partId
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
let current = op.to;
|
current = op.to;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -226,6 +228,7 @@ var index = {
|
||||||
);
|
);
|
||||||
next();
|
next();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = index;
|
module.exports = index;
|
||||||
|
|
327
packages/plugin-designer/dist/theme.min.js
vendored
327
packages/plugin-designer/dist/theme.min.js
vendored
|
@ -1,125 +1,232 @@
|
||||||
/**
|
this.freesewing = this.freesewing || {};
|
||||||
* @freesewing/theme-designer | v0.3.0
|
this.freesewing.plugins = this.freesewing.plugins || {};
|
||||||
* The designer theme for freesewing
|
this.freesewing.plugins.designer = (function() {
|
||||||
* (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";
|
"use strict";
|
||||||
return {
|
|
||||||
preRenderSvg: function(t) {
|
var script = `
|
||||||
(this.style +=
|
function pointHover(evt) {
|
||||||
"\npath.curve-control{stroke:#f0ad4e;stroke-width: 0.2;}\npath.debug{stroke:#d9534f;stroke-opacity:0.4;stroke-width:2;}\n.point{fill:none;stroke-width:0.6;stroke:#f0ad4e;}\ntext.tooltip{font-size:3px;}\n"),
|
var point = evt.target;
|
||||||
(this.script +=
|
var id = point.id;
|
||||||
"\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 console.log('Point '+id+' ( '+cx+' , '+cy+' )');\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 setTimeout(function(){\n var point = document.getElementById(evt.target.id);\n point.removeAttribute(\"transform\", '');\n }, 1000);\n}\n"),
|
var cx = point.getAttribute('x');
|
||||||
(this.defs +=
|
var cy = point.getAttribute('y');
|
||||||
'\n<g id="point">\n <circle cy="0" cx="0" r="2" class="stroke-hint stroke-sm" />\n <circle cy="0" cx="0" r="0.8" class="fill-hint" />\n</g>\n<g id="point-hidden">\n <circle cy="0" cx="0" r="1" class="stroke-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="stroke-canvas stroke-sm" />\n</g>\n<g id="path-move-point">\n <circle cx="0" cy="0" r="2" class="stroke-canvas stroke-lg" />\n <circle cx="0" cy="0" r="0.8" class="fill-canvas" />\n</g>\n<g id="path-line-point">\n <circle cx="0" cy="0" r="2" class="stroke-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 cy="0" cx="0" r="2" class="stroke-mark stroke-lg no-fill" />\n <circle cx="0" cy="0" r="0.8" class="fill-mark" />\n</g>\n<g id="point-focus">\n <circle cx="0" cy="0" r="2" class="stroke-mark stroke-lg" />\n <circle cx="0" cy="0" r="0.8" class="fill-fabric" />\n</g>\n<g id="marked-point">\n <circle cx="0" cy="0" r="3.6" class="stroke-hint stroke-sm" />\n <circle cx="0" cy="0" r="2.8" class="stroke-hint stroke-sm" />\n <circle cx="0" cy="0" r="2.0" class="stroke-hint stroke-sm" />\n <circle cx="0" cy="0" r="1.2" class="stroke-hint stroke-sm" />\n <circle cx="0" cy="0" r="0.8" class="stroke-hint stroke-sm" />\n <circle cx="0" cy="0" r="0.4" class="fill-hint" />\n</g>\n'),
|
console.log('Point '+id+' ( '+cx+' , '+cy+' )');
|
||||||
this.attributes.add(
|
var scale = 2;
|
||||||
"xmlns:freesewing",
|
cx = cx-scale*cx;
|
||||||
"http://freesewing.org/namespaces/freesewing"
|
cy = cy-scale*cy;
|
||||||
),
|
point.setAttribute("transform", 'matrix('+scale+', 0, 0, '+scale+', '+cx+', '+cy+')');
|
||||||
this.attributes.add("freesewing:theme-designer", "0.3.0");
|
setTimeout(function(){
|
||||||
var e = function(t, e, n, s, i, r, a) {
|
var point = document.getElementById(evt.target.id);
|
||||||
(n[t] = new e(s, `path-${i}-point`, `Path ${r}: ${i}`)),
|
point.removeAttribute("transform", '');
|
||||||
n[t].attributes.add("onmouseover", "pointHover(evt)"),
|
}, 1000);
|
||||||
n[t].attributes.add("id", t),
|
}
|
||||||
n[t].attributes.add("data-point", s.attributes.get("data-point")),
|
`;
|
||||||
n[t].attributes.add("data-path", r),
|
|
||||||
n[t].attributes.add("data-part", a);
|
var style = `
|
||||||
},
|
path.curve-control{stroke:#f0ad4e;stroke-width: 0.2;}
|
||||||
n = function(t, e, n, s, i, r, a) {
|
path.debug{stroke:#d9534f;stroke-opacity:0.4;stroke-width:2;}
|
||||||
let c = new e().move(s).line(i);
|
.point{fill:none;stroke-width:0.6;stroke:#f0ad4e;}
|
||||||
c.attributes.add("class", "curve-control"),
|
text.tooltip{font-size:3px;}
|
||||||
c.attributes.add("id", t),
|
`;
|
||||||
c.attributes.add("data-path", r),
|
|
||||||
c.attributes.add("data-part", a),
|
var snippets = `
|
||||||
(n[t] = c);
|
<g id="point">
|
||||||
};
|
<circle cy="0" cx="0" r="2" class="stroke-hint stroke-sm" />
|
||||||
!(function(t) {
|
<circle cy="0" cx="0" r="0.8" class="fill-hint" />
|
||||||
for (let e in t.pattern.parts) {
|
</g>
|
||||||
let n = t.pattern.parts[e];
|
<g id="point-hidden">
|
||||||
if (n.render)
|
<circle cy="0" cx="0" r="1" class="stroke-canvas stroke-xs" />
|
||||||
for (let s in n.points) {
|
<path d="M -0.5,-0.5 L 0.5,0.5 M 0.5,-0.5 L -0.5,0.5" class="stroke-canvas stroke-sm" />
|
||||||
let i = n.points[s];
|
</g>
|
||||||
i.attributes.add("id", t.getUid()),
|
<g id="path-move-point">
|
||||||
i.attributes.add("data-point", s),
|
<circle cx="0" cy="0" r="2" class="stroke-canvas stroke-lg" />
|
||||||
i.attributes.add("data-part", e);
|
<circle cx="0" cy="0" r="0.8" class="fill-canvas" />
|
||||||
let r = "_" === s.substr(0, 1) ? "point-hidden" : "point",
|
</g>
|
||||||
a = t.getUid();
|
<g id="path-line-point">
|
||||||
(n.snippets[a] = new t.pattern.snippet(
|
<circle cx="0" cy="0" r="2" class="stroke-note stroke-lg" />
|
||||||
i,
|
<circle cx="0" cy="0" r="0.8" class="fill-note" />
|
||||||
r,
|
</g>
|
||||||
`Point ${s} in part ${e}`
|
<g id="path-curve-point"> <use xlink:href = "#path-line-point"/> </g>
|
||||||
)),
|
<g id="path-handle-point">
|
||||||
n.snippets[a].attributes.add(
|
<circle cy="0" cx="0" r="2" class="stroke-mark stroke-lg no-fill" />
|
||||||
|
<circle cx="0" cy="0" r="0.8" class="fill-mark" />
|
||||||
|
</g>
|
||||||
|
<g id="point-focus">
|
||||||
|
<circle cx="0" cy="0" r="2" class="stroke-mark stroke-lg" />
|
||||||
|
<circle cx="0" cy="0" r="0.8" class="fill-fabric" />
|
||||||
|
</g>
|
||||||
|
<g id="marked-point">
|
||||||
|
<circle cx="0" cy="0" r="3.6" class="stroke-hint stroke-sm" />
|
||||||
|
<circle cx="0" cy="0" r="2.8" class="stroke-hint stroke-sm" />
|
||||||
|
<circle cx="0" cy="0" r="2.0" class="stroke-hint stroke-sm" />
|
||||||
|
<circle cx="0" cy="0" r="1.2" class="stroke-hint stroke-sm" />
|
||||||
|
<circle cx="0" cy="0" r="0.8" class="stroke-hint stroke-sm" />
|
||||||
|
<circle cx="0" cy="0" r="0.4" class="fill-hint" />
|
||||||
|
</g>
|
||||||
|
`;
|
||||||
|
|
||||||
|
var version = "0.3.0";
|
||||||
|
|
||||||
|
var index = {
|
||||||
|
hooks: {
|
||||||
|
preRenderSvg: function(next) {
|
||||||
|
// Add style, script and snippets
|
||||||
|
this.style += style;
|
||||||
|
this.script += script;
|
||||||
|
this.defs += snippets;
|
||||||
|
|
||||||
|
// Add SVG attributes
|
||||||
|
this.attributes.add("freesewing:theme-designer", version);
|
||||||
|
|
||||||
|
/** Decorares points with extra info */
|
||||||
|
var decoratePoints = function(svg) {
|
||||||
|
for (let partId in svg.pattern.parts) {
|
||||||
|
let part = svg.pattern.parts[partId];
|
||||||
|
if (part.render) {
|
||||||
|
for (let pointId in part.points) {
|
||||||
|
let point = part.points[pointId];
|
||||||
|
point.attributes.add("id", svg.getUid());
|
||||||
|
point.attributes.add("data-point", pointId);
|
||||||
|
point.attributes.add("data-part", partId);
|
||||||
|
let type =
|
||||||
|
pointId.substr(0, 1) === "_" ? "point-hidden" : "point";
|
||||||
|
let id = svg.getUid();
|
||||||
|
part.snippets[id] = new svg.pattern.snippet(
|
||||||
|
type,
|
||||||
|
point,
|
||||||
|
`Point ${pointId} in part ${partId}`
|
||||||
|
);
|
||||||
|
part.snippets[id].attributes.add(
|
||||||
"onmouseover",
|
"onmouseover",
|
||||||
"pointHover(evt)"
|
"pointHover(evt)"
|
||||||
),
|
);
|
||||||
n.snippets[a].attributes.add("id", a),
|
part.snippets[id].attributes.add("id", id);
|
||||||
n.snippets[a].attributes.add("data-point", s),
|
part.snippets[id].attributes.add("data-point", pointId);
|
||||||
n.snippets[a].attributes.add("data-part", e);
|
part.snippets[id].attributes.add("data-part", partId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})(this),
|
}
|
||||||
(function(t) {
|
};
|
||||||
for (let s in t.pattern.parts) {
|
|
||||||
let i = t.pattern.parts[s];
|
/** Decorares path points with extra info */
|
||||||
if (i.render)
|
var decoratePathPoint = function(
|
||||||
for (let r in i.paths) {
|
id,
|
||||||
let a = i.paths[r];
|
Snippet,
|
||||||
if (!a.render) return !1;
|
snippets$$1,
|
||||||
for (let c of a.ops) {
|
point,
|
||||||
"close" !== c.type &&
|
type,
|
||||||
e(
|
pathId,
|
||||||
t.getUid(),
|
partId
|
||||||
t.pattern.snippet,
|
) {
|
||||||
i.snippets,
|
snippets$$1[id] = new Snippet(
|
||||||
c.to,
|
`path-${type}-point`,
|
||||||
c.type,
|
point,
|
||||||
r,
|
`Path ${pathId}: ${type}`
|
||||||
s
|
);
|
||||||
),
|
snippets$$1[id].attributes.add("onmouseover", "pointHover(evt)");
|
||||||
"curve" === c.type &&
|
snippets$$1[id].attributes.add("id", id);
|
||||||
(e(
|
snippets$$1[id].attributes.add(
|
||||||
t.getUid(),
|
"data-point",
|
||||||
t.pattern.snippet,
|
point.attributes.get("data-point")
|
||||||
i.snippets,
|
);
|
||||||
c.cp1,
|
snippets$$1[id].attributes.add("data-path", pathId);
|
||||||
|
snippets$$1[id].attributes.add("data-part", partId);
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Draws curve control handles */
|
||||||
|
var decorateCurveHandles = function(
|
||||||
|
id,
|
||||||
|
Path,
|
||||||
|
paths,
|
||||||
|
from,
|
||||||
|
to,
|
||||||
|
pathId,
|
||||||
|
partId
|
||||||
|
) {
|
||||||
|
let path = new Path().move(from).line(to);
|
||||||
|
path.attributes.add("class", "curve-control");
|
||||||
|
path.attributes.add("id", id);
|
||||||
|
path.attributes.add("data-path", pathId);
|
||||||
|
path.attributes.add("data-part", partId);
|
||||||
|
paths[id] = path;
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Decorares paths with extra info */
|
||||||
|
var decoratePaths = function(svg) {
|
||||||
|
for (let partId in svg.pattern.parts) {
|
||||||
|
let part = svg.pattern.parts[partId];
|
||||||
|
if (part.render) {
|
||||||
|
for (let pathId in part.paths) {
|
||||||
|
let path = part.paths[pathId];
|
||||||
|
if (!path.render) return false;
|
||||||
|
let current;
|
||||||
|
for (let op of path.ops) {
|
||||||
|
if (op.type !== "close") {
|
||||||
|
decoratePathPoint(
|
||||||
|
svg.getUid(),
|
||||||
|
svg.pattern.snippet,
|
||||||
|
part.snippets,
|
||||||
|
op.to,
|
||||||
|
op.type,
|
||||||
|
pathId,
|
||||||
|
partId
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (op.type === "curve") {
|
||||||
|
decoratePathPoint(
|
||||||
|
svg.getUid(),
|
||||||
|
svg.pattern.snippet,
|
||||||
|
part.snippets,
|
||||||
|
op.cp1,
|
||||||
"handle",
|
"handle",
|
||||||
r,
|
pathId,
|
||||||
s
|
partId
|
||||||
),
|
);
|
||||||
e(
|
decoratePathPoint(
|
||||||
t.getUid(),
|
svg.getUid(),
|
||||||
t.pattern.snippet,
|
svg.pattern.snippet,
|
||||||
i.snippets,
|
part.snippets,
|
||||||
c.cp2,
|
op.cp2,
|
||||||
"handle",
|
"handle",
|
||||||
r,
|
pathId,
|
||||||
s
|
partId
|
||||||
),
|
);
|
||||||
n(t.getUid(), t.pattern.path, i.paths, a, c.cp1, r, s),
|
decorateCurveHandles(
|
||||||
n(
|
svg.getUid(),
|
||||||
t.getUid(),
|
svg.pattern.path,
|
||||||
t.pattern.path,
|
part.paths,
|
||||||
i.paths,
|
current,
|
||||||
c.to,
|
op.cp1,
|
||||||
c.cp2,
|
pathId,
|
||||||
r,
|
partId
|
||||||
s
|
);
|
||||||
));
|
decorateCurveHandles(
|
||||||
let a = c.to;
|
svg.getUid(),
|
||||||
|
svg.pattern.path,
|
||||||
|
part.paths,
|
||||||
|
op.to,
|
||||||
|
op.cp2,
|
||||||
|
pathId,
|
||||||
|
partId
|
||||||
|
);
|
||||||
|
}
|
||||||
|
current = op.to;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})(this),
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Decorate pattern
|
||||||
|
decoratePoints(this);
|
||||||
|
decoratePaths(this);
|
||||||
console.log(
|
console.log(
|
||||||
"Designer theme plugin: Here's the pattern object:",
|
"Designer theme plugin: Here's the pattern object:",
|
||||||
this.pattern
|
this.pattern
|
||||||
),
|
);
|
||||||
t();
|
next();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
})());
|
|
||||||
|
return index;
|
||||||
|
})();
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"lint-staged": {
|
"lint-staged": {
|
||||||
"*.{js,json}": [
|
"src/*.{js,json}": [
|
||||||
"prettier --write",
|
"prettier --write",
|
||||||
"git add"
|
"git add"
|
||||||
]
|
]
|
||||||
|
|
|
@ -20,15 +20,15 @@ export default {
|
||||||
commonjs(),
|
commonjs(),
|
||||||
babel({
|
babel({
|
||||||
exclude: "node_modules/**"
|
exclude: "node_modules/**"
|
||||||
}),
|
|
||||||
terser({
|
|
||||||
output: {
|
|
||||||
preamble: `/**\n * ${meta.name} | v${meta.version}\n * ${
|
|
||||||
meta.description
|
|
||||||
}\n * (c) ${new Date().getFullYear()} ${meta.author}\n * @license ${
|
|
||||||
meta.license
|
|
||||||
}\n */`
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
//terser({
|
||||||
|
// output: {
|
||||||
|
// preamble: `/**\n * ${meta.name} | v${meta.version}\n * ${
|
||||||
|
// meta.description
|
||||||
|
// }\n * (c) ${new Date().getFullYear()} ${meta.author}\n * @license ${
|
||||||
|
// meta.license
|
||||||
|
// }\n */`
|
||||||
|
// }
|
||||||
|
//})
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
|
@ -4,6 +4,7 @@ import snippets from "./lib/snippets";
|
||||||
import { version } from "../package.json";
|
import { version } from "../package.json";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
hooks: {
|
||||||
preRenderSvg: function(next) {
|
preRenderSvg: function(next) {
|
||||||
// Add style, script and snippets
|
// Add style, script and snippets
|
||||||
this.style += style;
|
this.style += style;
|
||||||
|
@ -11,10 +12,6 @@ export default {
|
||||||
this.defs += snippets;
|
this.defs += snippets;
|
||||||
|
|
||||||
// Add SVG attributes
|
// Add SVG attributes
|
||||||
this.attributes.add(
|
|
||||||
"xmlns:freesewing",
|
|
||||||
"http://freesewing.org/namespaces/freesewing"
|
|
||||||
);
|
|
||||||
this.attributes.add("freesewing:theme-designer", version);
|
this.attributes.add("freesewing:theme-designer", version);
|
||||||
|
|
||||||
/** Decorares points with extra info */
|
/** Decorares points with extra info */
|
||||||
|
@ -27,14 +24,18 @@ export default {
|
||||||
point.attributes.add("id", svg.getUid());
|
point.attributes.add("id", svg.getUid());
|
||||||
point.attributes.add("data-point", pointId);
|
point.attributes.add("data-point", pointId);
|
||||||
point.attributes.add("data-part", partId);
|
point.attributes.add("data-part", partId);
|
||||||
let type = pointId.substr(0, 1) === "_" ? "point-hidden" : "point";
|
let type =
|
||||||
|
pointId.substr(0, 1) === "_" ? "point-hidden" : "point";
|
||||||
let id = svg.getUid();
|
let id = svg.getUid();
|
||||||
part.snippets[id] = new svg.pattern.snippet(
|
part.snippets[id] = new svg.pattern.snippet(
|
||||||
point,
|
|
||||||
type,
|
type,
|
||||||
|
point,
|
||||||
`Point ${pointId} in part ${partId}`
|
`Point ${pointId} in part ${partId}`
|
||||||
);
|
);
|
||||||
part.snippets[id].attributes.add("onmouseover", "pointHover(evt)");
|
part.snippets[id].attributes.add(
|
||||||
|
"onmouseover",
|
||||||
|
"pointHover(evt)"
|
||||||
|
);
|
||||||
part.snippets[id].attributes.add("id", id);
|
part.snippets[id].attributes.add("id", id);
|
||||||
part.snippets[id].attributes.add("data-point", pointId);
|
part.snippets[id].attributes.add("data-point", pointId);
|
||||||
part.snippets[id].attributes.add("data-part", partId);
|
part.snippets[id].attributes.add("data-part", partId);
|
||||||
|
@ -54,8 +55,8 @@ export default {
|
||||||
partId
|
partId
|
||||||
) {
|
) {
|
||||||
snippets[id] = new Snippet(
|
snippets[id] = new Snippet(
|
||||||
point,
|
|
||||||
`path-${type}-point`,
|
`path-${type}-point`,
|
||||||
|
point,
|
||||||
`Path ${pathId}: ${type}`
|
`Path ${pathId}: ${type}`
|
||||||
);
|
);
|
||||||
snippets[id].attributes.add("onmouseover", "pointHover(evt)");
|
snippets[id].attributes.add("onmouseover", "pointHover(evt)");
|
||||||
|
@ -95,6 +96,7 @@ export default {
|
||||||
let path = part.paths[pathId];
|
let path = part.paths[pathId];
|
||||||
if (!path.render) return false;
|
if (!path.render) return false;
|
||||||
let id;
|
let id;
|
||||||
|
let current;
|
||||||
for (let op of path.ops) {
|
for (let op of path.ops) {
|
||||||
if (op.type !== "close") {
|
if (op.type !== "close") {
|
||||||
decoratePathPoint(
|
decoratePathPoint(
|
||||||
|
@ -145,6 +147,7 @@ export default {
|
||||||
partId
|
partId
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
current = op.to;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -160,4 +163,5 @@ export default {
|
||||||
);
|
);
|
||||||
next();
|
next();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue