🚧 Moved return statement to bottom to avoid warnings
This commit is contained in:
parent
9934b54566
commit
7758ba81a6
7 changed files with 23 additions and 15 deletions
|
@ -10,7 +10,8 @@ export default {
|
||||||
file: "dist/freesewing.min.js",
|
file: "dist/freesewing.min.js",
|
||||||
format: "iife",
|
format: "iife",
|
||||||
name: "freesewing",
|
name: "freesewing",
|
||||||
banner: `/**\n * Freesewing\n * (c) ${new Date().getFullYear()} Joost De Cock\n * @license MIT\n */`
|
banner: `/**\n * Freesewing\n * (c) ${new Date().getFullYear()} Joost De Cock\n * @license MIT\n */`,
|
||||||
|
sourcemap: true
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
resolve({
|
resolve({
|
||||||
|
@ -20,7 +21,6 @@ export default {
|
||||||
commonjs(),
|
commonjs(),
|
||||||
babel({
|
babel({
|
||||||
exclude: "node_modules/**"
|
exclude: "node_modules/**"
|
||||||
}),
|
})
|
||||||
terser()
|
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,8 +6,6 @@ function attributes(init = false) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return this;
|
|
||||||
|
|
||||||
/** Adds an attribute */
|
/** Adds an attribute */
|
||||||
this.prototype.add = function(name, value) {
|
this.prototype.add = function(name, value) {
|
||||||
if (typeof this.list[name] === "undefined") {
|
if (typeof this.list[name] === "undefined") {
|
||||||
|
@ -47,6 +45,8 @@ function attributes(init = false) {
|
||||||
|
|
||||||
return svg;
|
return svg;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default attributes;
|
export default attributes;
|
||||||
|
|
|
@ -3,8 +3,7 @@ import point from "./point";
|
||||||
import * as hooklib from "hooks";
|
import * as hooklib from "hooks";
|
||||||
|
|
||||||
function part(id) {
|
function part(id) {
|
||||||
attributes = new Attributes();
|
this.attributes = new Attributes();
|
||||||
|
|
||||||
this.points = {};
|
this.points = {};
|
||||||
this.paths = {};
|
this.paths = {};
|
||||||
this.snippets = {};
|
this.snippets = {};
|
||||||
|
@ -13,8 +12,6 @@ function part(id) {
|
||||||
this.points.origin = new point(0, 0);
|
this.points.origin = new point(0, 0);
|
||||||
for (let k in hooklib) this[k] = hooklib[k];
|
for (let k in hooklib) this[k] = hooklib[k];
|
||||||
|
|
||||||
return this;
|
|
||||||
|
|
||||||
this.prototype.macroRunner = function(args) {
|
this.prototype.macroRunner = function(args) {
|
||||||
let self = this;
|
let self = this;
|
||||||
let data = args;
|
let data = args;
|
||||||
|
@ -27,6 +24,8 @@ function part(id) {
|
||||||
|
|
||||||
return method;
|
return method;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default part;
|
export default part;
|
||||||
|
|
|
@ -66,6 +66,8 @@ function path() {
|
||||||
|
|
||||||
return d;
|
return d;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default path;
|
export default path;
|
||||||
|
|
|
@ -53,8 +53,6 @@ export default function pattern(config = false) {
|
||||||
config: this.config
|
config: this.config
|
||||||
};
|
};
|
||||||
|
|
||||||
return this;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws Will throw an error when called
|
* @throws Will throw an error when called
|
||||||
*/
|
*/
|
||||||
|
@ -112,4 +110,6 @@ export default function pattern(config = false) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,6 @@ function point(x, y) {
|
||||||
this.y = this.round(y);
|
this.y = this.round(y);
|
||||||
this.attributes = new attributes();
|
this.attributes = new attributes();
|
||||||
|
|
||||||
return this;
|
|
||||||
|
|
||||||
/** Rounds a value to PRECISION */
|
/** Rounds a value to PRECISION */
|
||||||
this.prototype.round = function(value) {
|
this.prototype.round = function(value) {
|
||||||
return Math.round(value * 1e2) / 1e2;
|
return Math.round(value * 1e2) / 1e2;
|
||||||
|
@ -113,6 +111,8 @@ function point(x, y) {
|
||||||
this.prototype.shiftOutwards = function(that, distance) {
|
this.prototype.shiftOutwards = function(that, distance) {
|
||||||
return this.shiftTowards(that, this.dist(that) + distance);
|
return this.shiftTowards(that, this.dist(that) + distance);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default point;
|
export default point;
|
||||||
|
|
11
src/svg.js
11
src/svg.js
|
@ -2,6 +2,8 @@ import attributes from "./attributes";
|
||||||
import * as hooklib from "hooks";
|
import * as hooklib from "hooks";
|
||||||
import hooks from "./hooks";
|
import hooks from "./hooks";
|
||||||
|
|
||||||
|
import { version } from "../package.json";
|
||||||
|
|
||||||
function svg(pattern) {
|
function svg(pattern) {
|
||||||
this.body = "";
|
this.body = "";
|
||||||
this.style = "";
|
this.style = "";
|
||||||
|
@ -15,12 +17,15 @@ function svg(pattern) {
|
||||||
this.attributes.add("xmlns", "http://www.w3.org/2000/svg");
|
this.attributes.add("xmlns", "http://www.w3.org/2000/svg");
|
||||||
this.attributes.add("xmlns:svg", "http://www.w3.org/2000/svg");
|
this.attributes.add("xmlns:svg", "http://www.w3.org/2000/svg");
|
||||||
this.attributes.add("xmlns:xlink", "http://www.w3.org/1999/xlink");
|
this.attributes.add("xmlns:xlink", "http://www.w3.org/1999/xlink");
|
||||||
|
this.attributes.add(
|
||||||
|
"xmlns:freesewing",
|
||||||
|
"http://freesewing.org/namespaces/freesewing"
|
||||||
|
);
|
||||||
|
this.attributes.add("freesewing", version);
|
||||||
this.hooks = hooks.all;
|
this.hooks = hooks.all;
|
||||||
for (let k in hooklib) this[k] = hooklib[k];
|
for (let k in hooklib) this[k] = hooklib[k];
|
||||||
for (let k in this.hooks) this.hook(k, this[k]);
|
for (let k in this.hooks) this.hook(k, this[k]);
|
||||||
|
|
||||||
return this;
|
|
||||||
|
|
||||||
/** Method to attach preRenderSvg hooks on */
|
/** Method to attach preRenderSvg hooks on */
|
||||||
this.prototype.preRenderSvg = function() {};
|
this.prototype.preRenderSvg = function() {};
|
||||||
|
|
||||||
|
@ -240,6 +245,8 @@ function svg(pattern) {
|
||||||
|
|
||||||
return "" + this.freeId;
|
return "" + this.freeId;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default svg;
|
export default svg;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue