svgedit/dist/extensions/ext-closepath.js

2584 lines
82 KiB
JavaScript
Raw Normal View History

- Breaking change: Extension now formatted as export (and `this` is set to editor, including for `callback`) - Breaking change: Locale now formatted as export - Breaking change: Moved out remaining modular i18n (imagelib) to own folder - Breaking change: Drop `executeAfterLoads` (and getJSPDF/getCanvg) - Breaking change: `RGBColor` must accept `new` - Breaking change: canvg - `stackBlurCanvasRGBA` must be set now by function (`setStackBlurCanvasRGBA`) rather than global; `canvg` now a named export - Breaking change: Avoid passing `canvg`/`buildCanvgCallback` to extensions (have them import) - Fix: i18nize imaglib more deeply - Fix: Positioning of Document Properties dialog (Fixes #246) - Fix (regression): PDF Export (Fixes #249) - Fix (regression): Add polyfill for `ChildNode`/`ParentNode` (and use further) - Fix (regression): Apply Babel universally to dependencies - Fix (regression): Ordering of `uaPrefix` function in `svgEditor.js` - Fix (regression): Embedded API - Fix (embedded editor): Fix backspace key in Firefox so it doesn't navigate out of frame - Fix: Alert if no exportWindow for PDF (e.g., if blocked) - Refactoring( RGBColor) `RGBColor` as class, without rebuilding constants, optimize string replacement, move methods to prototype, use templates and object literals, use `Object.keys` - Refactoring (canvg) Use classes more internally, use shorthand objects; array extras, return to lazy-loading - Refactoring: Use Promises in place of `$.getScript`; always return Promises in case deciding to await resolving - Refactoring: Avoid importing `RGBColor` into `svgutils.js` (jsPDF imports it itself) - Refactoring: Arrow functions, destructuring, shorter property references - Refactoring: Fix `lang` and `dir` for locales (though not in use currently anyways) - Refactoring: Provide path config for canvg, jspdf
2018-06-02 01:14:38 +00:00
var svgEditorExtension_closepath = (function () {
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`); also expect one directory higher; incorporates #207 (@iuyiuy) - Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons) - Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for better namespacing); incorporates #207 (@iuyiuy) - Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine) - Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed - Fix: Update Atom feed reference in HTML - Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes - Enhancement: Move config-sample.js out of `editor` directory - Enhancement: For `callback`-style extensions, also provide config object; add following to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml - Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel; make Node build routine for converting modular source to non-modular, use `loadStylesheets` for modular stylehsheet defining (but parallel loading); - Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default). - Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines - Refactoring: Avoid embedded API adding inline JavaScript listener - Refactoring: Move layers and context code to `draw.js` - Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js` - Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing) - Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency - Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules - Refactoring: Further avoidance of quotes on properties (as possible) - Refactoring: Use `class` in place of functions where intended as classes - Refactoring: Consistency and granularity in extensions imports - Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions - Testing: Add node-static for automating (and accessing out-of-directory contents) - Testing: Avoid HTML attributes for styling - Testing: Add npm `test` script - Testing: Comment out unused jQuery SVG test - Testing: Add test1 and svgutils_performance_test to all tests page - Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class - npm: Update devDeps - npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
'use strict';
2020-07-26 18:11:18 +00:00
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
try {
var info = gen[key](arg);
var value = info.value;
} catch (error) {
reject(error);
return;
}
if (info.done) {
resolve(value);
} else {
Promise.resolve(value).then(_next, _throw);
}
}
function _asyncToGenerator(fn) {
return function () {
var self = this,
args = arguments;
return new Promise(function (resolve, reject) {
var gen = fn.apply(self, args);
function _next(value) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
}
function _throw(err) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
}
_next(undefined);
});
};
}
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
function _defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
if (staticProps) _defineProperties(Constructor, staticProps);
return Constructor;
}
function _inherits(subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function");
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
writable: true,
configurable: true
}
});
if (superClass) _setPrototypeOf(subClass, superClass);
}
function _getPrototypeOf(o) {
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
return o.__proto__ || Object.getPrototypeOf(o);
};
return _getPrototypeOf(o);
}
function _setPrototypeOf(o, p) {
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
o.__proto__ = p;
return o;
};
return _setPrototypeOf(o, p);
}
function _isNativeReflectConstruct() {
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
if (Reflect.construct.sham) return false;
if (typeof Proxy === "function") return true;
try {
Date.prototype.toString.call(Reflect.construct(Date, [], function () {}));
return true;
} catch (e) {
return false;
}
}
function _assertThisInitialized(self) {
if (self === void 0) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return self;
}
function _possibleConstructorReturn(self, call) {
if (call && (typeof call === "object" || typeof call === "function")) {
return call;
}
return _assertThisInitialized(self);
}
function _createSuper(Derived) {
var hasNativeReflectConstruct = _isNativeReflectConstruct();
return function _createSuperInternal() {
var Super = _getPrototypeOf(Derived),
result;
if (hasNativeReflectConstruct) {
var NewTarget = _getPrototypeOf(this).constructor;
result = Reflect.construct(Super, arguments, NewTarget);
} else {
result = Super.apply(this, arguments);
}
return _possibleConstructorReturn(this, result);
};
}
/* eslint-disable import/unambiguous, max-len */
/* globals SVGPathSeg, SVGPathSegMovetoRel, SVGPathSegMovetoAbs,
SVGPathSegMovetoRel, SVGPathSegLinetoRel, SVGPathSegLinetoAbs,
SVGPathSegLinetoHorizontalRel, SVGPathSegLinetoHorizontalAbs,
SVGPathSegLinetoVerticalRel, SVGPathSegLinetoVerticalAbs,
SVGPathSegClosePath, SVGPathSegCurvetoCubicRel,
SVGPathSegCurvetoCubicAbs, SVGPathSegCurvetoCubicSmoothRel,
SVGPathSegCurvetoCubicSmoothAbs, SVGPathSegCurvetoQuadraticRel,
SVGPathSegCurvetoQuadraticAbs, SVGPathSegCurvetoQuadraticSmoothRel,
SVGPathSegCurvetoQuadraticSmoothAbs, SVGPathSegArcRel, SVGPathSegArcAbs */
/**
* SVGPathSeg API polyfill
* https://github.com/progers/pathseg
*
* This is a drop-in replacement for the `SVGPathSeg` and `SVGPathSegList` APIs
* that were removed from SVG2 ({@link https://lists.w3.org/Archives/Public/www-svg/2015Jun/0044.html}),
* including the latest spec changes which were implemented in Firefox 43 and
* Chrome 46.
*/
/* eslint-disable no-shadow, class-methods-use-this, jsdoc/require-jsdoc */
// Linting: We avoid `no-shadow` as ESLint thinks these are still available globals
// Linting: We avoid `class-methods-use-this` as this is a polyfill that must
// follow the conventions
2020-07-26 18:11:18 +00:00
(function () {
if (!('SVGPathSeg' in window)) {
// Spec: https://www.w3.org/TR/SVG11/single-page.html#paths-InterfaceSVGPathSeg
2020-07-26 18:11:18 +00:00
var _SVGPathSeg = /*#__PURE__*/function () {
function _SVGPathSeg(type, typeAsLetter, owningPathSegList) {
_classCallCheck(this, _SVGPathSeg);
this.pathSegType = type;
this.pathSegTypeAsLetter = typeAsLetter;
this._owningPathSegList = owningPathSegList;
} // Notify owning PathSegList on any changes so they can be synchronized back to the path element.
2020-07-26 18:11:18 +00:00
_createClass(_SVGPathSeg, [{
key: "_segmentChanged",
value: function _segmentChanged() {
if (this._owningPathSegList) {
this._owningPathSegList.segmentChanged(this);
}
}
2020-07-26 18:11:18 +00:00
}]);
return _SVGPathSeg;
}();
_SVGPathSeg.prototype.classname = 'SVGPathSeg';
_SVGPathSeg.PATHSEG_UNKNOWN = 0;
_SVGPathSeg.PATHSEG_CLOSEPATH = 1;
_SVGPathSeg.PATHSEG_MOVETO_ABS = 2;
_SVGPathSeg.PATHSEG_MOVETO_REL = 3;
_SVGPathSeg.PATHSEG_LINETO_ABS = 4;
_SVGPathSeg.PATHSEG_LINETO_REL = 5;
_SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS = 6;
_SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL = 7;
_SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS = 8;
_SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL = 9;
_SVGPathSeg.PATHSEG_ARC_ABS = 10;
_SVGPathSeg.PATHSEG_ARC_REL = 11;
_SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS = 12;
_SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL = 13;
_SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS = 14;
_SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL = 15;
_SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS = 16;
_SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL = 17;
_SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS = 18;
_SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL = 19;
var _SVGPathSegClosePath = /*#__PURE__*/function (_SVGPathSeg2) {
_inherits(_SVGPathSegClosePath, _SVGPathSeg2);
var _super = _createSuper(_SVGPathSegClosePath);
function _SVGPathSegClosePath(owningPathSegList) {
_classCallCheck(this, _SVGPathSegClosePath);
return _super.call(this, _SVGPathSeg.PATHSEG_CLOSEPATH, 'z', owningPathSegList);
}
_createClass(_SVGPathSegClosePath, [{
key: "toString",
value: function toString() {
return '[object SVGPathSegClosePath]';
}
}, {
key: "_asPathString",
value: function _asPathString() {
return this.pathSegTypeAsLetter;
}
}, {
key: "clone",
value: function clone() {
return new _SVGPathSegClosePath(undefined);
}
}]);
2020-07-26 18:11:18 +00:00
return _SVGPathSegClosePath;
}(_SVGPathSeg);
2020-07-26 18:11:18 +00:00
var _SVGPathSegMovetoAbs = /*#__PURE__*/function (_SVGPathSeg3) {
_inherits(_SVGPathSegMovetoAbs, _SVGPathSeg3);
2020-07-26 18:11:18 +00:00
var _super2 = _createSuper(_SVGPathSegMovetoAbs);
2020-07-26 18:11:18 +00:00
function _SVGPathSegMovetoAbs(owningPathSegList, x, y) {
var _this;
2020-07-26 18:11:18 +00:00
_classCallCheck(this, _SVGPathSegMovetoAbs);
2020-07-26 18:11:18 +00:00
_this = _super2.call(this, _SVGPathSeg.PATHSEG_MOVETO_ABS, 'M', owningPathSegList);
_this._x = x;
_this._y = y;
return _this;
}
2020-07-26 18:11:18 +00:00
_createClass(_SVGPathSegMovetoAbs, [{
key: "toString",
value: function toString() {
return '[object SVGPathSegMovetoAbs]';
}
}, {
key: "_asPathString",
value: function _asPathString() {
return this.pathSegTypeAsLetter + ' ' + this._x + ' ' + this._y;
}
}, {
key: "clone",
value: function clone() {
return new _SVGPathSegMovetoAbs(undefined, this._x, this._y);
}
}]);
2020-07-26 18:11:18 +00:00
return _SVGPathSegMovetoAbs;
}(_SVGPathSeg);
2020-07-26 18:11:18 +00:00
Object.defineProperties(_SVGPathSegMovetoAbs.prototype, {
x: {
2020-07-26 18:11:18 +00:00
get: function get() {
return this._x;
},
2020-07-26 18:11:18 +00:00
set: function set(x) {
this._x = x;
this._segmentChanged();
},
enumerable: true
},
y: {
2020-07-26 18:11:18 +00:00
get: function get() {
return this._y;
},
2020-07-26 18:11:18 +00:00
set: function set(y) {
this._y = y;
this._segmentChanged();
},
enumerable: true
}
});
2020-07-26 18:11:18 +00:00
var _SVGPathSegMovetoRel = /*#__PURE__*/function (_SVGPathSeg4) {
_inherits(_SVGPathSegMovetoRel, _SVGPathSeg4);
2020-07-26 18:11:18 +00:00
var _super3 = _createSuper(_SVGPathSegMovetoRel);
2020-07-26 18:11:18 +00:00
function _SVGPathSegMovetoRel(owningPathSegList, x, y) {
var _this2;
_classCallCheck(this, _SVGPathSegMovetoRel);
2020-07-26 18:11:18 +00:00
_this2 = _super3.call(this, _SVGPathSeg.PATHSEG_MOVETO_REL, 'm', owningPathSegList);
_this2._x = x;
_this2._y = y;
return _this2;
}
2020-07-26 18:11:18 +00:00
_createClass(_SVGPathSegMovetoRel, [{
key: "toString",
value: function toString() {
return '[object SVGPathSegMovetoRel]';
}
}, {
key: "_asPathString",
value: function _asPathString() {
return this.pathSegTypeAsLetter + ' ' + this._x + ' ' + this._y;
}
}, {
key: "clone",
value: function clone() {
return new _SVGPathSegMovetoRel(undefined, this._x, this._y);
}
}]);
2020-07-26 18:11:18 +00:00
return _SVGPathSegMovetoRel;
}(_SVGPathSeg);
Object.defineProperties(_SVGPathSegMovetoRel.prototype, {
x: {
2020-07-26 18:11:18 +00:00
get: function get() {
return this._x;
},
2020-07-26 18:11:18 +00:00
set: function set(x) {
this._x = x;
this._segmentChanged();
},
enumerable: true
},
y: {
2020-07-26 18:11:18 +00:00
get: function get() {
return this._y;
},
2020-07-26 18:11:18 +00:00
set: function set(y) {
this._y = y;
this._segmentChanged();
},
enumerable: true
}
});
2020-07-26 18:11:18 +00:00
var _SVGPathSegLinetoAbs = /*#__PURE__*/function (_SVGPathSeg5) {
_inherits(_SVGPathSegLinetoAbs, _SVGPathSeg5);
2020-07-26 18:11:18 +00:00
var _super4 = _createSuper(_SVGPathSegLinetoAbs);
2020-07-26 18:11:18 +00:00
function _SVGPathSegLinetoAbs(owningPathSegList, x, y) {
var _this3;
2020-07-26 18:11:18 +00:00
_classCallCheck(this, _SVGPathSegLinetoAbs);
_this3 = _super4.call(this, _SVGPathSeg.PATHSEG_LINETO_ABS, 'L', owningPathSegList);
_this3._x = x;
_this3._y = y;
return _this3;
}
2020-07-26 18:11:18 +00:00
_createClass(_SVGPathSegLinetoAbs, [{
key: "toString",
value: function toString() {
return '[object SVGPathSegLinetoAbs]';
}
}, {
key: "_asPathString",
value: function _asPathString() {
return this.pathSegTypeAsLetter + ' ' + this._x + ' ' + this._y;
}
}, {
key: "clone",
value: function clone() {
return new _SVGPathSegLinetoAbs(undefined, this._x, this._y);
}
}]);
return _SVGPathSegLinetoAbs;
}(_SVGPathSeg);
2020-07-26 18:11:18 +00:00
Object.defineProperties(_SVGPathSegLinetoAbs.prototype, {
x: {
2020-07-26 18:11:18 +00:00
get: function get() {
return this._x;
},
2020-07-26 18:11:18 +00:00
set: function set(x) {
this._x = x;
this._segmentChanged();
},
enumerable: true
},
y: {
2020-07-26 18:11:18 +00:00
get: function get() {
return this._y;
},
2020-07-26 18:11:18 +00:00
set: function set(y) {
this._y = y;
this._segmentChanged();
},
enumerable: true
}
});
2020-07-26 18:11:18 +00:00
var _SVGPathSegLinetoRel = /*#__PURE__*/function (_SVGPathSeg6) {
_inherits(_SVGPathSegLinetoRel, _SVGPathSeg6);
2020-07-26 18:11:18 +00:00
var _super5 = _createSuper(_SVGPathSegLinetoRel);
2020-07-26 18:11:18 +00:00
function _SVGPathSegLinetoRel(owningPathSegList, x, y) {
var _this4;
_classCallCheck(this, _SVGPathSegLinetoRel);
2020-07-26 18:11:18 +00:00
_this4 = _super5.call(this, _SVGPathSeg.PATHSEG_LINETO_REL, 'l', owningPathSegList);
_this4._x = x;
_this4._y = y;
return _this4;
}
2020-07-26 18:11:18 +00:00
_createClass(_SVGPathSegLinetoRel, [{
key: "toString",
value: function toString() {
return '[object SVGPathSegLinetoRel]';
}
}, {
key: "_asPathString",
value: function _asPathString() {
return this.pathSegTypeAsLetter + ' ' + this._x + ' ' + this._y;
}
}, {
key: "clone",
value: function clone() {
return new _SVGPathSegLinetoRel(undefined, this._x, this._y);
}
}]);
2020-07-26 18:11:18 +00:00
return _SVGPathSegLinetoRel;
}(_SVGPathSeg);
Object.defineProperties(_SVGPathSegLinetoRel.prototype, {
x: {
2020-07-26 18:11:18 +00:00
get: function get() {
return this._x;
},
2020-07-26 18:11:18 +00:00
set: function set(x) {
this._x = x;
this._segmentChanged();
},
enumerable: true
},
y: {
2020-07-26 18:11:18 +00:00
get: function get() {
return this._y;
},
2020-07-26 18:11:18 +00:00
set: function set(y) {
this._y = y;
this._segmentChanged();
},
enumerable: true
}
});
2020-07-26 18:11:18 +00:00
var _SVGPathSegCurvetoCubicAbs = /*#__PURE__*/function (_SVGPathSeg7) {
_inherits(_SVGPathSegCurvetoCubicAbs, _SVGPathSeg7);
2020-07-26 18:11:18 +00:00
var _super6 = _createSuper(_SVGPathSegCurvetoCubicAbs);
2020-07-26 18:11:18 +00:00
function _SVGPathSegCurvetoCubicAbs(owningPathSegList, x, y, x1, y1, x2, y2) {
var _this5;
2020-07-26 18:11:18 +00:00
_classCallCheck(this, _SVGPathSegCurvetoCubicAbs);
_this5 = _super6.call(this, _SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS, 'C', owningPathSegList);
_this5._x = x;
_this5._y = y;
_this5._x1 = x1;
_this5._y1 = y1;
_this5._x2 = x2;
_this5._y2 = y2;
return _this5;
}
2020-07-26 18:11:18 +00:00
_createClass(_SVGPathSegCurvetoCubicAbs, [{
key: "toString",
value: function toString() {
return '[object SVGPathSegCurvetoCubicAbs]';
}
}, {
key: "_asPathString",
value: function _asPathString() {
return this.pathSegTypeAsLetter + ' ' + this._x1 + ' ' + this._y1 + ' ' + this._x2 + ' ' + this._y2 + ' ' + this._x + ' ' + this._y;
}
}, {
key: "clone",
value: function clone() {
return new _SVGPathSegCurvetoCubicAbs(undefined, this._x, this._y, this._x1, this._y1, this._x2, this._y2);
}
}]);
return _SVGPathSegCurvetoCubicAbs;
}(_SVGPathSeg);
2020-07-26 18:11:18 +00:00
Object.defineProperties(_SVGPathSegCurvetoCubicAbs.prototype, {
x: {
2020-07-26 18:11:18 +00:00
get: function get() {
return this._x;
},
2020-07-26 18:11:18 +00:00
set: function set(x) {
this._x = x;
this._segmentChanged();
},
enumerable: true
},
y: {
2020-07-26 18:11:18 +00:00
get: function get() {
return this._y;
},
2020-07-26 18:11:18 +00:00
set: function set(y) {
this._y = y;
this._segmentChanged();
},
enumerable: true
},
x1: {
2020-07-26 18:11:18 +00:00
get: function get() {
return this._x1;
},
2020-07-26 18:11:18 +00:00
set: function set(x1) {
this._x1 = x1;
this._segmentChanged();
},
enumerable: true
},
y1: {
2020-07-26 18:11:18 +00:00
get: function get() {
return this._y1;
},
2020-07-26 18:11:18 +00:00
set: function set(y1) {
this._y1 = y1;
this._segmentChanged();
},
enumerable: true
},
x2: {
2020-07-26 18:11:18 +00:00
get: function get() {
return this._x2;
},
2020-07-26 18:11:18 +00:00
set: function set(x2) {
this._x2 = x2;
this._segmentChanged();
},
enumerable: true
},
y2: {
2020-07-26 18:11:18 +00:00
get: function get() {
return this._y2;
},
2020-07-26 18:11:18 +00:00
set: function set(y2) {
this._y2 = y2;
this._segmentChanged();
},
enumerable: true
}
});
2020-07-26 18:11:18 +00:00
var _SVGPathSegCurvetoCubicRel = /*#__PURE__*/function (_SVGPathSeg8) {
_inherits(_SVGPathSegCurvetoCubicRel, _SVGPathSeg8);
2020-07-26 18:11:18 +00:00
var _super7 = _createSuper(_SVGPathSegCurvetoCubicRel);
2020-07-26 18:11:18 +00:00
function _SVGPathSegCurvetoCubicRel(owningPathSegList, x, y, x1, y1, x2, y2) {
var _this6;
_classCallCheck(this, _SVGPathSegCurvetoCubicRel);
2020-07-26 18:11:18 +00:00
_this6 = _super7.call(this, _SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL, 'c', owningPathSegList);
_this6._x = x;
_this6._y = y;
_this6._x1 = x1;
_this6._y1 = y1;
_this6._x2 = x2;
_this6._y2 = y2;
return _this6;
}
2020-07-26 18:11:18 +00:00
_createClass(_SVGPathSegCurvetoCubicRel, [{
key: "toString",
value: function toString() {
return '[object SVGPathSegCurvetoCubicRel]';
}
}, {
key: "_asPathString",
value: function _asPathString() {
return this.pathSegTypeAsLetter + ' ' + this._x1 + ' ' + this._y1 + ' ' + this._x2 + ' ' + this._y2 + ' ' + this._x + ' ' + this._y;
}
}, {
key: "clone",
value: function clone() {
return new _SVGPathSegCurvetoCubicRel(undefined, this._x, this._y, this._x1, this._y1, this._x2, this._y2);
}
}]);
2020-07-26 18:11:18 +00:00
return _SVGPathSegCurvetoCubicRel;
}(_SVGPathSeg);
Object.defineProperties(_SVGPathSegCurvetoCubicRel.prototype, {
x: {
2020-07-26 18:11:18 +00:00
get: function get() {
return this._x;
},
2020-07-26 18:11:18 +00:00
set: function set(x) {
this._x = x;
this._segmentChanged();
},
enumerable: true
},
y: {
2020-07-26 18:11:18 +00:00
get: function get() {
return this._y;
},
2020-07-26 18:11:18 +00:00
set: function set(y) {
this._y = y;
this._segmentChanged();
},
enumerable: true
},
x1: {
2020-07-26 18:11:18 +00:00
get: function get() {
return this._x1;
},
2020-07-26 18:11:18 +00:00
set: function set(x1) {
this._x1 = x1;
this._segmentChanged();
},
enumerable: true
},
y1: {
2020-07-26 18:11:18 +00:00
get: function get() {
return this._y1;
},
2020-07-26 18:11:18 +00:00
set: function set(y1) {
this._y1 = y1;
this._segmentChanged();
},
enumerable: true
},
x2: {
2020-07-26 18:11:18 +00:00
get: function get() {
return this._x2;
},
2020-07-26 18:11:18 +00:00
set: function set(x2) {
this._x2 = x2;
this._segmentChanged();
},
enumerable: true
},
y2: {
2020-07-26 18:11:18 +00:00
get: function get() {
return this._y2;
},
2020-07-26 18:11:18 +00:00
set: function set(y2) {
this._y2 = y2;
this._segmentChanged();
},
enumerable: true
}
});
2020-07-26 18:11:18 +00:00
var _SVGPathSegCurvetoQuadraticAbs = /*#__PURE__*/function (_SVGPathSeg9) {
_inherits(_SVGPathSegCurvetoQuadraticAbs, _SVGPathSeg9);
2020-07-26 18:11:18 +00:00
var _super8 = _createSuper(_SVGPathSegCurvetoQuadraticAbs);
2020-07-26 18:11:18 +00:00
function _SVGPathSegCurvetoQuadraticAbs(owningPathSegList, x, y, x1, y1) {
var _this7;
2020-07-26 18:11:18 +00:00
_classCallCheck(this, _SVGPathSegCurvetoQuadraticAbs);
_this7 = _super8.call(this, _SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS, 'Q', owningPathSegList);
_this7._x = x;
_this7._y = y;
_this7._x1 = x1;
_this7._y1 = y1;
return _this7;
}
2020-07-26 18:11:18 +00:00
_createClass(_SVGPathSegCurvetoQuadraticAbs, [{
key: "toString",
value: function toString() {
return '[object SVGPathSegCurvetoQuadraticAbs]';
}
}, {
key: "_asPathString",
value: function _asPathString() {
return this.pathSegTypeAsLetter + ' ' + this._x1 + ' ' + this._y1 + ' ' + this._x + ' ' + this._y;
}
}, {
key: "clone",
value: function clone() {
return new _SVGPathSegCurvetoQuadraticAbs(undefined, this._x, this._y, this._x1, this._y1);
}
}]);
return _SVGPathSegCurvetoQuadraticAbs;
}(_SVGPathSeg);
2020-07-26 18:11:18 +00:00
Object.defineProperties(_SVGPathSegCurvetoQuadraticAbs.prototype, {
x: {
2020-07-26 18:11:18 +00:00
get: function get() {
return this._x;
},
2020-07-26 18:11:18 +00:00
set: function set(x) {
this._x = x;
this._segmentChanged();
},
enumerable: true
},
y: {
2020-07-26 18:11:18 +00:00
get: function get() {
return this._y;
},
2020-07-26 18:11:18 +00:00
set: function set(y) {
this._y = y;
this._segmentChanged();
},
enumerable: true
},
x1: {
2020-07-26 18:11:18 +00:00
get: function get() {
return this._x1;
},
2020-07-26 18:11:18 +00:00
set: function set(x1) {
this._x1 = x1;
this._segmentChanged();
},
enumerable: true
},
y1: {
2020-07-26 18:11:18 +00:00
get: function get() {
return this._y1;
},
2020-07-26 18:11:18 +00:00
set: function set(y1) {
this._y1 = y1;
this._segmentChanged();
},
enumerable: true
}
});
2020-07-26 18:11:18 +00:00
var _SVGPathSegCurvetoQuadraticRel = /*#__PURE__*/function (_SVGPathSeg10) {
_inherits(_SVGPathSegCurvetoQuadraticRel, _SVGPathSeg10);
2020-07-26 18:11:18 +00:00
var _super9 = _createSuper(_SVGPathSegCurvetoQuadraticRel);
2020-07-26 18:11:18 +00:00
function _SVGPathSegCurvetoQuadraticRel(owningPathSegList, x, y, x1, y1) {
var _this8;
_classCallCheck(this, _SVGPathSegCurvetoQuadraticRel);
2020-07-26 18:11:18 +00:00
_this8 = _super9.call(this, _SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL, 'q', owningPathSegList);
_this8._x = x;
_this8._y = y;
_this8._x1 = x1;
_this8._y1 = y1;
return _this8;
}
2020-07-26 18:11:18 +00:00
_createClass(_SVGPathSegCurvetoQuadraticRel, [{
key: "toString",
value: function toString() {
return '[object SVGPathSegCurvetoQuadraticRel]';
}
}, {
key: "_asPathString",
value: function _asPathString() {
return this.pathSegTypeAsLetter + ' ' + this._x1 + ' ' + this._y1 + ' ' + this._x + ' ' + this._y;
}
}, {
key: "clone",
value: function clone() {
return new _SVGPathSegCurvetoQuadraticRel(undefined, this._x, this._y, this._x1, this._y1);
}
}]);
2020-07-26 18:11:18 +00:00
return _SVGPathSegCurvetoQuadraticRel;
}(_SVGPathSeg);
Object.defineProperties(_SVGPathSegCurvetoQuadraticRel.prototype, {
x: {
2020-07-26 18:11:18 +00:00
get: function get() {
return this._x;
},
2020-07-26 18:11:18 +00:00
set: function set(x) {
this._x = x;
this._segmentChanged();
},
enumerable: true
},
y: {
2020-07-26 18:11:18 +00:00
get: function get() {
return this._y;
},
2020-07-26 18:11:18 +00:00
set: function set(y) {
this._y = y;
this._segmentChanged();
},
enumerable: true
},
x1: {
2020-07-26 18:11:18 +00:00
get: function get() {
return this._x1;
},
2020-07-26 18:11:18 +00:00
set: function set(x1) {
this._x1 = x1;
this._segmentChanged();
},
enumerable: true
},
y1: {
2020-07-26 18:11:18 +00:00
get: function get() {
return this._y1;
},
2020-07-26 18:11:18 +00:00
set: function set(y1) {
this._y1 = y1;
this._segmentChanged();
},
enumerable: true
}
});
2020-07-26 18:11:18 +00:00
var _SVGPathSegArcAbs = /*#__PURE__*/function (_SVGPathSeg11) {
_inherits(_SVGPathSegArcAbs, _SVGPathSeg11);
2020-07-26 18:11:18 +00:00
var _super10 = _createSuper(_SVGPathSegArcAbs);
2020-07-26 18:11:18 +00:00
function _SVGPathSegArcAbs(owningPathSegList, x, y, r1, r2, angle, largeArcFlag, sweepFlag) {
var _this9;
2020-07-26 18:11:18 +00:00
_classCallCheck(this, _SVGPathSegArcAbs);
_this9 = _super10.call(this, _SVGPathSeg.PATHSEG_ARC_ABS, 'A', owningPathSegList);
_this9._x = x;
_this9._y = y;
_this9._r1 = r1;
_this9._r2 = r2;
_this9._angle = angle;
_this9._largeArcFlag = largeArcFlag;
_this9._sweepFlag = sweepFlag;
return _this9;
}
2020-07-26 18:11:18 +00:00
_createClass(_SVGPathSegArcAbs, [{
key: "toString",
value: function toString() {
return '[object SVGPathSegArcAbs]';
}
}, {
key: "_asPathString",
value: function _asPathString() {
return this.pathSegTypeAsLetter + ' ' + this._r1 + ' ' + this._r2 + ' ' + this._angle + ' ' + (this._largeArcFlag ? '1' : '0') + ' ' + (this._sweepFlag ? '1' : '0') + ' ' + this._x + ' ' + this._y;
}
}, {
key: "clone",
value: function clone() {
return new _SVGPathSegArcAbs(undefined, this._x, this._y, this._r1, this._r2, this._angle, this._largeArcFlag, this._sweepFlag);
}
}]);
return _SVGPathSegArcAbs;
}(_SVGPathSeg);
2020-07-26 18:11:18 +00:00
Object.defineProperties(_SVGPathSegArcAbs.prototype, {
x: {
2020-07-26 18:11:18 +00:00
get: function get() {
return this._x;
},
2020-07-26 18:11:18 +00:00
set: function set(x) {
this._x = x;
this._segmentChanged();
},
enumerable: true
},
y: {
2020-07-26 18:11:18 +00:00
get: function get() {
return this._y;
},
2020-07-26 18:11:18 +00:00
set: function set(y) {
this._y = y;
this._segmentChanged();
},
enumerable: true
},
r1: {
2020-07-26 18:11:18 +00:00
get: function get() {
return this._r1;
},
2020-07-26 18:11:18 +00:00
set: function set(r1) {
this._r1 = r1;
this._segmentChanged();
},
enumerable: true
},
r2: {
2020-07-26 18:11:18 +00:00
get: function get() {
return this._r2;
},
2020-07-26 18:11:18 +00:00
set: function set(r2) {
this._r2 = r2;
this._segmentChanged();
},
enumerable: true
},
angle: {
2020-07-26 18:11:18 +00:00
get: function get() {
return this._angle;
},
2020-07-26 18:11:18 +00:00
set: function set(angle) {
this._angle = angle;
this._segmentChanged();
},
enumerable: true
},
largeArcFlag: {
2020-07-26 18:11:18 +00:00
get: function get() {
return this._largeArcFlag;
},
2020-07-26 18:11:18 +00:00
set: function set(largeArcFlag) {
this._largeArcFlag = largeArcFlag;
this._segmentChanged();
},
enumerable: true
},
sweepFlag: {
2020-07-26 18:11:18 +00:00
get: function get() {
return this._sweepFlag;
},
2020-07-26 18:11:18 +00:00
set: function set(sweepFlag) {
this._sweepFlag = sweepFlag;
this._segmentChanged();
},
enumerable: true
}
});
2020-07-26 18:11:18 +00:00
var _SVGPathSegArcRel = /*#__PURE__*/function (_SVGPathSeg12) {
_inherits(_SVGPathSegArcRel, _SVGPathSeg12);
2020-07-26 18:11:18 +00:00
var _super11 = _createSuper(_SVGPathSegArcRel);
2020-07-26 18:11:18 +00:00
function _SVGPathSegArcRel(owningPathSegList, x, y, r1, r2, angle, largeArcFlag, sweepFlag) {
var _this10;
_classCallCheck(this, _SVGPathSegArcRel);
2020-07-26 18:11:18 +00:00
_this10 = _super11.call(this, _SVGPathSeg.PATHSEG_ARC_REL, 'a', owningPathSegList);
_this10._x = x;
_this10._y = y;
_this10._r1 = r1;
_this10._r2 = r2;
_this10._angle = angle;
_this10._largeArcFlag = largeArcFlag;
_this10._sweepFlag = sweepFlag;
return _this10;
}
2020-07-26 18:11:18 +00:00
_createClass(_SVGPathSegArcRel, [{
key: "toString",
value: function toString() {
return '[object SVGPathSegArcRel]';
}
}, {
key: "_asPathString",
value: function _asPathString() {
return this.pathSegTypeAsLetter + ' ' + this._r1 + ' ' + this._r2 + ' ' + this._angle + ' ' + (this._largeArcFlag ? '1' : '0') + ' ' + (this._sweepFlag ? '1' : '0') + ' ' + this._x + ' ' + this._y;
}
}, {
key: "clone",
value: function clone() {
return new _SVGPathSegArcRel(undefined, this._x, this._y, this._r1, this._r2, this._angle, this._largeArcFlag, this._sweepFlag);
}
}]);
2020-07-26 18:11:18 +00:00
return _SVGPathSegArcRel;
}(_SVGPathSeg);
Object.defineProperties(_SVGPathSegArcRel.prototype, {
x: {
2020-07-26 18:11:18 +00:00
get: function get() {
return this._x;
},
2020-07-26 18:11:18 +00:00
set: function set(x) {
this._x = x;
this._segmentChanged();
},
enumerable: true
},
y: {
2020-07-26 18:11:18 +00:00
get: function get() {
return this._y;
},
2020-07-26 18:11:18 +00:00
set: function set(y) {
this._y = y;
this._segmentChanged();
},
enumerable: true
},
r1: {
2020-07-26 18:11:18 +00:00
get: function get() {
return this._r1;
},
2020-07-26 18:11:18 +00:00
set: function set(r1) {
this._r1 = r1;
this._segmentChanged();
},
enumerable: true
},
r2: {
2020-07-26 18:11:18 +00:00
get: function get() {
return this._r2;
},
2020-07-26 18:11:18 +00:00
set: function set(r2) {
this._r2 = r2;
this._segmentChanged();
},
enumerable: true
},
angle: {
2020-07-26 18:11:18 +00:00
get: function get() {
return this._angle;
},
2020-07-26 18:11:18 +00:00
set: function set(angle) {
this._angle = angle;
this._segmentChanged();
},
enumerable: true
},
largeArcFlag: {
2020-07-26 18:11:18 +00:00
get: function get() {
return this._largeArcFlag;
},
2020-07-26 18:11:18 +00:00
set: function set(largeArcFlag) {
this._largeArcFlag = largeArcFlag;
this._segmentChanged();
},
enumerable: true
},
sweepFlag: {
2020-07-26 18:11:18 +00:00
get: function get() {
return this._sweepFlag;
},
2020-07-26 18:11:18 +00:00
set: function set(sweepFlag) {
this._sweepFlag = sweepFlag;
this._segmentChanged();
},
enumerable: true
}
});
2020-07-26 18:11:18 +00:00
var _SVGPathSegLinetoHorizontalAbs = /*#__PURE__*/function (_SVGPathSeg13) {
_inherits(_SVGPathSegLinetoHorizontalAbs, _SVGPathSeg13);
2020-07-26 18:11:18 +00:00
var _super12 = _createSuper(_SVGPathSegLinetoHorizontalAbs);
2020-07-26 18:11:18 +00:00
function _SVGPathSegLinetoHorizontalAbs(owningPathSegList, x) {
var _this11;
_classCallCheck(this, _SVGPathSegLinetoHorizontalAbs);
2020-07-26 18:11:18 +00:00
_this11 = _super12.call(this, _SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS, 'H', owningPathSegList);
_this11._x = x;
return _this11;
}
2020-07-26 18:11:18 +00:00
_createClass(_SVGPathSegLinetoHorizontalAbs, [{
key: "toString",
value: function toString() {
return '[object SVGPathSegLinetoHorizontalAbs]';
}
}, {
key: "_asPathString",
value: function _asPathString() {
return this.pathSegTypeAsLetter + ' ' + this._x;
}
}, {
key: "clone",
value: function clone() {
return new _SVGPathSegLinetoHorizontalAbs(undefined, this._x);
}
}]);
2020-07-26 18:11:18 +00:00
return _SVGPathSegLinetoHorizontalAbs;
}(_SVGPathSeg);
Object.defineProperty(_SVGPathSegLinetoHorizontalAbs.prototype, 'x', {
get: function get() {
return this._x;
},
2020-07-26 18:11:18 +00:00
set: function set(x) {
this._x = x;
this._segmentChanged();
},
enumerable: true
});
2020-07-26 18:11:18 +00:00
var _SVGPathSegLinetoHorizontalRel = /*#__PURE__*/function (_SVGPathSeg14) {
_inherits(_SVGPathSegLinetoHorizontalRel, _SVGPathSeg14);
2020-07-26 18:11:18 +00:00
var _super13 = _createSuper(_SVGPathSegLinetoHorizontalRel);
2020-07-26 18:11:18 +00:00
function _SVGPathSegLinetoHorizontalRel(owningPathSegList, x) {
var _this12;
_classCallCheck(this, _SVGPathSegLinetoHorizontalRel);
2020-07-26 18:11:18 +00:00
_this12 = _super13.call(this, _SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL, 'h', owningPathSegList);
_this12._x = x;
return _this12;
}
2020-07-26 18:11:18 +00:00
_createClass(_SVGPathSegLinetoHorizontalRel, [{
key: "toString",
value: function toString() {
return '[object SVGPathSegLinetoHorizontalRel]';
}
}, {
key: "_asPathString",
value: function _asPathString() {
return this.pathSegTypeAsLetter + ' ' + this._x;
}
}, {
key: "clone",
value: function clone() {
return new _SVGPathSegLinetoHorizontalRel(undefined, this._x);
}
}]);
return _SVGPathSegLinetoHorizontalRel;
}(_SVGPathSeg);
2020-07-26 18:11:18 +00:00
Object.defineProperty(_SVGPathSegLinetoHorizontalRel.prototype, 'x', {
get: function get() {
return this._x;
},
2020-07-26 18:11:18 +00:00
set: function set(x) {
this._x = x;
this._segmentChanged();
},
enumerable: true
});
2020-07-26 18:11:18 +00:00
var _SVGPathSegLinetoVerticalAbs = /*#__PURE__*/function (_SVGPathSeg15) {
_inherits(_SVGPathSegLinetoVerticalAbs, _SVGPathSeg15);
2020-07-26 18:11:18 +00:00
var _super14 = _createSuper(_SVGPathSegLinetoVerticalAbs);
2020-07-26 18:11:18 +00:00
function _SVGPathSegLinetoVerticalAbs(owningPathSegList, y) {
var _this13;
_classCallCheck(this, _SVGPathSegLinetoVerticalAbs);
2020-07-26 18:11:18 +00:00
_this13 = _super14.call(this, _SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS, 'V', owningPathSegList);
_this13._y = y;
return _this13;
}
2020-07-26 18:11:18 +00:00
_createClass(_SVGPathSegLinetoVerticalAbs, [{
key: "toString",
value: function toString() {
return '[object SVGPathSegLinetoVerticalAbs]';
}
}, {
key: "_asPathString",
value: function _asPathString() {
return this.pathSegTypeAsLetter + ' ' + this._y;
}
}, {
key: "clone",
value: function clone() {
return new _SVGPathSegLinetoVerticalAbs(undefined, this._y);
}
}]);
2020-07-26 18:11:18 +00:00
return _SVGPathSegLinetoVerticalAbs;
}(_SVGPathSeg);
Object.defineProperty(_SVGPathSegLinetoVerticalAbs.prototype, 'y', {
get: function get() {
return this._y;
},
2020-07-26 18:11:18 +00:00
set: function set(y) {
this._y = y;
this._segmentChanged();
},
enumerable: true
});
2020-07-26 18:11:18 +00:00
var _SVGPathSegLinetoVerticalRel = /*#__PURE__*/function (_SVGPathSeg16) {
_inherits(_SVGPathSegLinetoVerticalRel, _SVGPathSeg16);
2020-07-26 18:11:18 +00:00
var _super15 = _createSuper(_SVGPathSegLinetoVerticalRel);
2020-07-26 18:11:18 +00:00
function _SVGPathSegLinetoVerticalRel(owningPathSegList, y) {
var _this14;
2020-07-26 18:11:18 +00:00
_classCallCheck(this, _SVGPathSegLinetoVerticalRel);
_this14 = _super15.call(this, _SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL, 'v', owningPathSegList);
_this14._y = y;
return _this14;
}
2020-07-26 18:11:18 +00:00
_createClass(_SVGPathSegLinetoVerticalRel, [{
key: "toString",
value: function toString() {
return '[object SVGPathSegLinetoVerticalRel]';
}
}, {
key: "_asPathString",
value: function _asPathString() {
return this.pathSegTypeAsLetter + ' ' + this._y;
}
}, {
key: "clone",
value: function clone() {
return new _SVGPathSegLinetoVerticalRel(undefined, this._y);
}
}]);
return _SVGPathSegLinetoVerticalRel;
}(_SVGPathSeg);
2020-07-26 18:11:18 +00:00
Object.defineProperty(_SVGPathSegLinetoVerticalRel.prototype, 'y', {
get: function get() {
return this._y;
},
2020-07-26 18:11:18 +00:00
set: function set(y) {
this._y = y;
this._segmentChanged();
},
enumerable: true
});
2020-07-26 18:11:18 +00:00
var _SVGPathSegCurvetoCubicSmoothAbs = /*#__PURE__*/function (_SVGPathSeg17) {
_inherits(_SVGPathSegCurvetoCubicSmoothAbs, _SVGPathSeg17);
2020-07-26 18:11:18 +00:00
var _super16 = _createSuper(_SVGPathSegCurvetoCubicSmoothAbs);
2020-07-26 18:11:18 +00:00
function _SVGPathSegCurvetoCubicSmoothAbs(owningPathSegList, x, y, x2, y2) {
var _this15;
_classCallCheck(this, _SVGPathSegCurvetoCubicSmoothAbs);
2020-07-26 18:11:18 +00:00
_this15 = _super16.call(this, _SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS, 'S', owningPathSegList);
_this15._x = x;
_this15._y = y;
_this15._x2 = x2;
_this15._y2 = y2;
return _this15;
}
2020-07-26 18:11:18 +00:00
_createClass(_SVGPathSegCurvetoCubicSmoothAbs, [{
key: "toString",
value: function toString() {
return '[object SVGPathSegCurvetoCubicSmoothAbs]';
}
}, {
key: "_asPathString",
value: function _asPathString() {
return this.pathSegTypeAsLetter + ' ' + this._x2 + ' ' + this._y2 + ' ' + this._x + ' ' + this._y;
}
}, {
key: "clone",
value: function clone() {
return new _SVGPathSegCurvetoCubicSmoothAbs(undefined, this._x, this._y, this._x2, this._y2);
}
}]);
return _SVGPathSegCurvetoCubicSmoothAbs;
}(_SVGPathSeg);
2020-07-26 18:11:18 +00:00
Object.defineProperties(_SVGPathSegCurvetoCubicSmoothAbs.prototype, {
x: {
2020-07-26 18:11:18 +00:00
get: function get() {
return this._x;
},
2020-07-26 18:11:18 +00:00
set: function set(x) {
this._x = x;
this._segmentChanged();
},
enumerable: true
},
y: {
2020-07-26 18:11:18 +00:00
get: function get() {
return this._y;
},
2020-07-26 18:11:18 +00:00
set: function set(y) {
this._y = y;
this._segmentChanged();
},
enumerable: true
},
x2: {
2020-07-26 18:11:18 +00:00
get: function get() {
return this._x2;
},
2020-07-26 18:11:18 +00:00
set: function set(x2) {
this._x2 = x2;
this._segmentChanged();
},
enumerable: true
},
y2: {
2020-07-26 18:11:18 +00:00
get: function get() {
return this._y2;
},
2020-07-26 18:11:18 +00:00
set: function set(y2) {
this._y2 = y2;
this._segmentChanged();
},
enumerable: true
}
});
2020-07-26 18:11:18 +00:00
var _SVGPathSegCurvetoCubicSmoothRel = /*#__PURE__*/function (_SVGPathSeg18) {
_inherits(_SVGPathSegCurvetoCubicSmoothRel, _SVGPathSeg18);
2020-07-26 18:11:18 +00:00
var _super17 = _createSuper(_SVGPathSegCurvetoCubicSmoothRel);
2020-07-26 18:11:18 +00:00
function _SVGPathSegCurvetoCubicSmoothRel(owningPathSegList, x, y, x2, y2) {
var _this16;
_classCallCheck(this, _SVGPathSegCurvetoCubicSmoothRel);
2020-07-26 18:11:18 +00:00
_this16 = _super17.call(this, _SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL, 's', owningPathSegList);
_this16._x = x;
_this16._y = y;
_this16._x2 = x2;
_this16._y2 = y2;
return _this16;
}
2020-07-26 18:11:18 +00:00
_createClass(_SVGPathSegCurvetoCubicSmoothRel, [{
key: "toString",
value: function toString() {
return '[object SVGPathSegCurvetoCubicSmoothRel]';
}
}, {
key: "_asPathString",
value: function _asPathString() {
return this.pathSegTypeAsLetter + ' ' + this._x2 + ' ' + this._y2 + ' ' + this._x + ' ' + this._y;
}
}, {
key: "clone",
value: function clone() {
return new _SVGPathSegCurvetoCubicSmoothRel(undefined, this._x, this._y, this._x2, this._y2);
}
}]);
2020-07-26 18:11:18 +00:00
return _SVGPathSegCurvetoCubicSmoothRel;
}(_SVGPathSeg);
Object.defineProperties(_SVGPathSegCurvetoCubicSmoothRel.prototype, {
x: {
2020-07-26 18:11:18 +00:00
get: function get() {
return this._x;
},
2020-07-26 18:11:18 +00:00
set: function set(x) {
this._x = x;
this._segmentChanged();
},
enumerable: true
},
y: {
2020-07-26 18:11:18 +00:00
get: function get() {
return this._y;
},
2020-07-26 18:11:18 +00:00
set: function set(y) {
this._y = y;
this._segmentChanged();
},
enumerable: true
},
x2: {
2020-07-26 18:11:18 +00:00
get: function get() {
return this._x2;
},
2020-07-26 18:11:18 +00:00
set: function set(x2) {
this._x2 = x2;
this._segmentChanged();
},
enumerable: true
},
y2: {
2020-07-26 18:11:18 +00:00
get: function get() {
return this._y2;
},
2020-07-26 18:11:18 +00:00
set: function set(y2) {
this._y2 = y2;
this._segmentChanged();
},
enumerable: true
}
});
2020-07-26 18:11:18 +00:00
var _SVGPathSegCurvetoQuadraticSmoothAbs = /*#__PURE__*/function (_SVGPathSeg19) {
_inherits(_SVGPathSegCurvetoQuadraticSmoothAbs, _SVGPathSeg19);
2020-07-26 18:11:18 +00:00
var _super18 = _createSuper(_SVGPathSegCurvetoQuadraticSmoothAbs);
2020-07-26 18:11:18 +00:00
function _SVGPathSegCurvetoQuadraticSmoothAbs(owningPathSegList, x, y) {
var _this17;
_classCallCheck(this, _SVGPathSegCurvetoQuadraticSmoothAbs);
2020-07-26 18:11:18 +00:00
_this17 = _super18.call(this, _SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS, 'T', owningPathSegList);
_this17._x = x;
_this17._y = y;
return _this17;
}
2020-07-26 18:11:18 +00:00
_createClass(_SVGPathSegCurvetoQuadraticSmoothAbs, [{
key: "toString",
value: function toString() {
return '[object SVGPathSegCurvetoQuadraticSmoothAbs]';
}
}, {
key: "_asPathString",
value: function _asPathString() {
return this.pathSegTypeAsLetter + ' ' + this._x + ' ' + this._y;
}
}, {
key: "clone",
value: function clone() {
return new _SVGPathSegCurvetoQuadraticSmoothAbs(undefined, this._x, this._y);
}
}]);
2020-07-26 18:11:18 +00:00
return _SVGPathSegCurvetoQuadraticSmoothAbs;
}(_SVGPathSeg);
Object.defineProperties(_SVGPathSegCurvetoQuadraticSmoothAbs.prototype, {
x: {
2020-07-26 18:11:18 +00:00
get: function get() {
return this._x;
},
2020-07-26 18:11:18 +00:00
set: function set(x) {
this._x = x;
this._segmentChanged();
},
enumerable: true
},
y: {
2020-07-26 18:11:18 +00:00
get: function get() {
return this._y;
},
2020-07-26 18:11:18 +00:00
set: function set(y) {
this._y = y;
this._segmentChanged();
},
enumerable: true
}
});
2020-07-26 18:11:18 +00:00
var _SVGPathSegCurvetoQuadraticSmoothRel = /*#__PURE__*/function (_SVGPathSeg20) {
_inherits(_SVGPathSegCurvetoQuadraticSmoothRel, _SVGPathSeg20);
2020-07-26 18:11:18 +00:00
var _super19 = _createSuper(_SVGPathSegCurvetoQuadraticSmoothRel);
2020-07-26 18:11:18 +00:00
function _SVGPathSegCurvetoQuadraticSmoothRel(owningPathSegList, x, y) {
var _this18;
_classCallCheck(this, _SVGPathSegCurvetoQuadraticSmoothRel);
2020-07-26 18:11:18 +00:00
_this18 = _super19.call(this, _SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL, 't', owningPathSegList);
_this18._x = x;
_this18._y = y;
return _this18;
}
2020-07-26 18:11:18 +00:00
_createClass(_SVGPathSegCurvetoQuadraticSmoothRel, [{
key: "toString",
value: function toString() {
return '[object SVGPathSegCurvetoQuadraticSmoothRel]';
}
}, {
key: "_asPathString",
value: function _asPathString() {
return this.pathSegTypeAsLetter + ' ' + this._x + ' ' + this._y;
}
}, {
key: "clone",
value: function clone() {
return new _SVGPathSegCurvetoQuadraticSmoothRel(undefined, this._x, this._y);
}
}]);
return _SVGPathSegCurvetoQuadraticSmoothRel;
}(_SVGPathSeg);
2020-07-26 18:11:18 +00:00
Object.defineProperties(_SVGPathSegCurvetoQuadraticSmoothRel.prototype, {
x: {
2020-07-26 18:11:18 +00:00
get: function get() {
return this._x;
},
2020-07-26 18:11:18 +00:00
set: function set(x) {
this._x = x;
this._segmentChanged();
},
enumerable: true
},
y: {
2020-07-26 18:11:18 +00:00
get: function get() {
return this._y;
},
2020-07-26 18:11:18 +00:00
set: function set(y) {
this._y = y;
this._segmentChanged();
},
enumerable: true
}
}); // Add createSVGPathSeg* functions to SVGPathElement.
// Spec: https://www.w3.org/TR/SVG11/single-page.html#paths-InterfaceSVGPathElement.
SVGPathElement.prototype.createSVGPathSegClosePath = function () {
2020-07-26 18:11:18 +00:00
return new _SVGPathSegClosePath(undefined);
};
SVGPathElement.prototype.createSVGPathSegMovetoAbs = function (x, y) {
2020-07-26 18:11:18 +00:00
return new _SVGPathSegMovetoAbs(undefined, x, y);
};
SVGPathElement.prototype.createSVGPathSegMovetoRel = function (x, y) {
2020-07-26 18:11:18 +00:00
return new _SVGPathSegMovetoRel(undefined, x, y);
};
SVGPathElement.prototype.createSVGPathSegLinetoAbs = function (x, y) {
2020-07-26 18:11:18 +00:00
return new _SVGPathSegLinetoAbs(undefined, x, y);
};
SVGPathElement.prototype.createSVGPathSegLinetoRel = function (x, y) {
2020-07-26 18:11:18 +00:00
return new _SVGPathSegLinetoRel(undefined, x, y);
};
SVGPathElement.prototype.createSVGPathSegCurvetoCubicAbs = function (x, y, x1, y1, x2, y2) {
2020-07-26 18:11:18 +00:00
return new _SVGPathSegCurvetoCubicAbs(undefined, x, y, x1, y1, x2, y2);
};
SVGPathElement.prototype.createSVGPathSegCurvetoCubicRel = function (x, y, x1, y1, x2, y2) {
2020-07-26 18:11:18 +00:00
return new _SVGPathSegCurvetoCubicRel(undefined, x, y, x1, y1, x2, y2);
};
SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticAbs = function (x, y, x1, y1) {
2020-07-26 18:11:18 +00:00
return new _SVGPathSegCurvetoQuadraticAbs(undefined, x, y, x1, y1);
};
SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticRel = function (x, y, x1, y1) {
2020-07-26 18:11:18 +00:00
return new _SVGPathSegCurvetoQuadraticRel(undefined, x, y, x1, y1);
};
SVGPathElement.prototype.createSVGPathSegArcAbs = function (x, y, r1, r2, angle, largeArcFlag, sweepFlag) {
2020-07-26 18:11:18 +00:00
return new _SVGPathSegArcAbs(undefined, x, y, r1, r2, angle, largeArcFlag, sweepFlag);
};
SVGPathElement.prototype.createSVGPathSegArcRel = function (x, y, r1, r2, angle, largeArcFlag, sweepFlag) {
2020-07-26 18:11:18 +00:00
return new _SVGPathSegArcRel(undefined, x, y, r1, r2, angle, largeArcFlag, sweepFlag);
};
SVGPathElement.prototype.createSVGPathSegLinetoHorizontalAbs = function (x) {
2020-07-26 18:11:18 +00:00
return new _SVGPathSegLinetoHorizontalAbs(undefined, x);
};
SVGPathElement.prototype.createSVGPathSegLinetoHorizontalRel = function (x) {
2020-07-26 18:11:18 +00:00
return new _SVGPathSegLinetoHorizontalRel(undefined, x);
};
SVGPathElement.prototype.createSVGPathSegLinetoVerticalAbs = function (y) {
2020-07-26 18:11:18 +00:00
return new _SVGPathSegLinetoVerticalAbs(undefined, y);
};
SVGPathElement.prototype.createSVGPathSegLinetoVerticalRel = function (y) {
2020-07-26 18:11:18 +00:00
return new _SVGPathSegLinetoVerticalRel(undefined, y);
};
SVGPathElement.prototype.createSVGPathSegCurvetoCubicSmoothAbs = function (x, y, x2, y2) {
2020-07-26 18:11:18 +00:00
return new _SVGPathSegCurvetoCubicSmoothAbs(undefined, x, y, x2, y2);
};
SVGPathElement.prototype.createSVGPathSegCurvetoCubicSmoothRel = function (x, y, x2, y2) {
2020-07-26 18:11:18 +00:00
return new _SVGPathSegCurvetoCubicSmoothRel(undefined, x, y, x2, y2);
};
SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticSmoothAbs = function (x, y) {
2020-07-26 18:11:18 +00:00
return new _SVGPathSegCurvetoQuadraticSmoothAbs(undefined, x, y);
};
SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticSmoothRel = function (x, y) {
2020-07-26 18:11:18 +00:00
return new _SVGPathSegCurvetoQuadraticSmoothRel(undefined, x, y);
};
if (!('getPathSegAtLength' in SVGPathElement.prototype)) {
// Add getPathSegAtLength to SVGPathElement.
// Spec: https://www.w3.org/TR/SVG11/single-page.html#paths-__svg__SVGPathElement__getPathSegAtLength
// This polyfill requires SVGPathElement.getTotalLength to implement the distance-along-a-path algorithm.
SVGPathElement.prototype.getPathSegAtLength = function (distance) {
if (distance === undefined || !isFinite(distance)) {
throw new Error('Invalid arguments.');
}
2020-07-26 18:11:18 +00:00
var measurementElement = document.createElementNS('http://www.w3.org/2000/svg', 'path');
measurementElement.setAttribute('d', this.getAttribute('d'));
2020-07-26 18:11:18 +00:00
var lastPathSegment = measurementElement.pathSegList.numberOfItems - 1; // If the path is empty, return 0.
if (lastPathSegment <= 0) {
return 0;
}
do {
measurementElement.pathSegList.removeItem(lastPathSegment);
if (distance > measurementElement.getTotalLength()) {
break;
}
lastPathSegment--;
} while (lastPathSegment > 0);
return lastPathSegment;
};
}
2020-07-26 18:11:18 +00:00
window.SVGPathSeg = _SVGPathSeg;
window.SVGPathSegClosePath = _SVGPathSegClosePath;
window.SVGPathSegMovetoAbs = _SVGPathSegMovetoAbs;
window.SVGPathSegMovetoRel = _SVGPathSegMovetoRel;
window.SVGPathSegLinetoAbs = _SVGPathSegLinetoAbs;
window.SVGPathSegLinetoRel = _SVGPathSegLinetoRel;
window.SVGPathSegCurvetoCubicAbs = _SVGPathSegCurvetoCubicAbs;
window.SVGPathSegCurvetoCubicRel = _SVGPathSegCurvetoCubicRel;
window.SVGPathSegCurvetoQuadraticAbs = _SVGPathSegCurvetoQuadraticAbs;
window.SVGPathSegCurvetoQuadraticRel = _SVGPathSegCurvetoQuadraticRel;
window.SVGPathSegArcAbs = _SVGPathSegArcAbs;
window.SVGPathSegArcRel = _SVGPathSegArcRel;
window.SVGPathSegLinetoHorizontalAbs = _SVGPathSegLinetoHorizontalAbs;
window.SVGPathSegLinetoHorizontalRel = _SVGPathSegLinetoHorizontalRel;
window.SVGPathSegLinetoVerticalAbs = _SVGPathSegLinetoVerticalAbs;
window.SVGPathSegLinetoVerticalRel = _SVGPathSegLinetoVerticalRel;
window.SVGPathSegCurvetoCubicSmoothAbs = _SVGPathSegCurvetoCubicSmoothAbs;
window.SVGPathSegCurvetoCubicSmoothRel = _SVGPathSegCurvetoCubicSmoothRel;
window.SVGPathSegCurvetoQuadraticSmoothAbs = _SVGPathSegCurvetoQuadraticSmoothAbs;
window.SVGPathSegCurvetoQuadraticSmoothRel = _SVGPathSegCurvetoQuadraticSmoothRel;
} // Checking for SVGPathSegList in window checks for the case of an implementation without the
// SVGPathSegList API.
// The second check for appendItem is specific to Firefox 59+ which removed only parts of the
// SVGPathSegList API (e.g., appendItem). In this case we need to re-implement the entire API
// so the polyfill data (i.e., _list) is used throughout.
if (!('SVGPathSegList' in window) || !('appendItem' in window.SVGPathSegList.prototype)) {
// Spec: https://www.w3.org/TR/SVG11/single-page.html#paths-InterfaceSVGPathSegList
2020-07-26 18:11:18 +00:00
var SVGPathSegList = /*#__PURE__*/function () {
function SVGPathSegList(pathElement) {
_classCallCheck(this, SVGPathSegList);
this._pathElement = pathElement;
this._list = this._parsePath(this._pathElement.getAttribute('d')); // Use a MutationObserver to catch changes to the path's "d" attribute.
this._mutationObserverConfig = {
attributes: true,
attributeFilter: ['d']
};
this._pathElementMutationObserver = new MutationObserver(this._updateListFromPathMutations.bind(this));
this._pathElementMutationObserver.observe(this._pathElement, this._mutationObserverConfig);
} // Process any pending mutations to the path element and update the list as needed.
// This should be the first call of all public functions and is needed because
// MutationObservers are not synchronous so we can have pending asynchronous mutations.
2020-07-26 18:11:18 +00:00
_createClass(SVGPathSegList, [{
key: "_checkPathSynchronizedToList",
value: function _checkPathSynchronizedToList() {
this._updateListFromPathMutations(this._pathElementMutationObserver.takeRecords());
}
2020-07-26 18:11:18 +00:00
}, {
key: "_updateListFromPathMutations",
value: function _updateListFromPathMutations(mutationRecords) {
if (!this._pathElement) {
return;
}
2020-07-26 18:11:18 +00:00
var hasPathMutations = false;
mutationRecords.forEach(function (record) {
if (record.attributeName === 'd') {
hasPathMutations = true;
}
});
2020-07-26 18:11:18 +00:00
if (hasPathMutations) {
this._list = this._parsePath(this._pathElement.getAttribute('d'));
}
} // Serialize the list and update the path's 'd' attribute.
2020-07-26 18:11:18 +00:00
}, {
key: "_writeListToPath",
value: function _writeListToPath() {
this._pathElementMutationObserver.disconnect();
2020-07-26 18:11:18 +00:00
this._pathElement.setAttribute('d', SVGPathSegList._pathSegArrayAsString(this._list));
2020-07-26 18:11:18 +00:00
this._pathElementMutationObserver.observe(this._pathElement, this._mutationObserverConfig);
} // When a path segment changes the list needs to be synchronized back to the path element.
2020-07-26 18:11:18 +00:00
}, {
key: "segmentChanged",
value: function segmentChanged(pathSeg) {
this._writeListToPath();
}
2020-07-26 18:11:18 +00:00
}, {
key: "clear",
value: function clear() {
this._checkPathSynchronizedToList();
2020-07-26 18:11:18 +00:00
this._list.forEach(function (pathSeg) {
pathSeg._owningPathSegList = null;
});
2020-07-26 18:11:18 +00:00
this._list = [];
2020-07-26 18:11:18 +00:00
this._writeListToPath();
}
}, {
key: "initialize",
value: function initialize(newItem) {
this._checkPathSynchronizedToList();
2020-07-26 18:11:18 +00:00
this._list = [newItem];
newItem._owningPathSegList = this;
2020-07-26 18:11:18 +00:00
this._writeListToPath();
2020-07-26 18:11:18 +00:00
return newItem;
}
2020-07-26 18:11:18 +00:00
}, {
key: "_checkValidIndex",
value: function _checkValidIndex(index) {
if (isNaN(index) || index < 0 || index >= this.numberOfItems) {
throw new Error('INDEX_SIZE_ERR');
}
}
2020-07-26 18:11:18 +00:00
}, {
key: "getItem",
value: function getItem(index) {
this._checkPathSynchronizedToList();
2020-07-26 18:11:18 +00:00
this._checkValidIndex(index);
2020-07-26 18:11:18 +00:00
return this._list[index];
}
2020-07-26 18:11:18 +00:00
}, {
key: "insertItemBefore",
value: function insertItemBefore(newItem, index) {
this._checkPathSynchronizedToList(); // Spec: If the index is greater than or equal to numberOfItems, then the new item is appended to the end of the list.
2020-07-26 18:11:18 +00:00
if (index > this.numberOfItems) {
index = this.numberOfItems;
}
2020-07-26 18:11:18 +00:00
if (newItem._owningPathSegList) {
// SVG2 spec says to make a copy.
newItem = newItem.clone();
}
2020-07-26 18:11:18 +00:00
this._list.splice(index, 0, newItem);
2020-07-26 18:11:18 +00:00
newItem._owningPathSegList = this;
2020-07-26 18:11:18 +00:00
this._writeListToPath();
2020-07-26 18:11:18 +00:00
return newItem;
}
}, {
key: "replaceItem",
value: function replaceItem(newItem, index) {
this._checkPathSynchronizedToList();
if (newItem._owningPathSegList) {
// SVG2 spec says to make a copy.
newItem = newItem.clone();
}
2020-07-26 18:11:18 +00:00
this._checkValidIndex(index);
2020-07-26 18:11:18 +00:00
this._list[index] = newItem;
newItem._owningPathSegList = this;
2020-07-26 18:11:18 +00:00
this._writeListToPath();
2020-07-26 18:11:18 +00:00
return newItem;
}
2020-07-26 18:11:18 +00:00
}, {
key: "removeItem",
value: function removeItem(index) {
this._checkPathSynchronizedToList();
2020-07-26 18:11:18 +00:00
this._checkValidIndex(index);
2020-07-26 18:11:18 +00:00
var item = this._list[index];
2020-07-26 18:11:18 +00:00
this._list.splice(index, 1);
2020-07-26 18:11:18 +00:00
this._writeListToPath();
2020-07-26 18:11:18 +00:00
return item;
}
2020-07-26 18:11:18 +00:00
}, {
key: "appendItem",
value: function appendItem(newItem) {
this._checkPathSynchronizedToList();
if (newItem._owningPathSegList) {
// SVG2 spec says to make a copy.
newItem = newItem.clone();
}
2020-07-26 18:11:18 +00:00
this._list.push(newItem);
2020-07-26 18:11:18 +00:00
newItem._owningPathSegList = this; // TODO: Optimize this to just append to the existing attribute.
2020-07-26 18:11:18 +00:00
this._writeListToPath();
2020-07-26 18:11:18 +00:00
return newItem;
} // This closely follows SVGPathParser::parsePath from Source/core/svg/SVGPathParser.cpp.
2020-07-26 18:11:18 +00:00
}, {
key: "_parsePath",
value: function _parsePath(string) {
if (!string || !string.length) {
return [];
}
2020-07-26 18:11:18 +00:00
var owningPathSegList = this;
2020-07-26 18:11:18 +00:00
var Builder = /*#__PURE__*/function () {
function Builder() {
_classCallCheck(this, Builder);
2020-07-26 18:11:18 +00:00
this.pathSegList = [];
}
2020-07-26 18:11:18 +00:00
_createClass(Builder, [{
key: "appendSegment",
value: function appendSegment(pathSeg) {
this.pathSegList.push(pathSeg);
}
2020-07-26 18:11:18 +00:00
}]);
2020-07-26 18:11:18 +00:00
return Builder;
}();
2020-07-26 18:11:18 +00:00
var Source = /*#__PURE__*/function () {
function Source(string) {
_classCallCheck(this, Source);
2020-07-26 18:11:18 +00:00
this._string = string;
this._currentIndex = 0;
this._endIndex = this._string.length;
this._previousCommand = SVGPathSeg.PATHSEG_UNKNOWN;
2020-07-26 18:11:18 +00:00
this._skipOptionalSpaces();
}
2020-07-26 18:11:18 +00:00
_createClass(Source, [{
key: "_isCurrentSpace",
value: function _isCurrentSpace() {
var character = this._string[this._currentIndex];
return character <= ' ' && (character === ' ' || character === '\n' || character === '\t' || character === '\r' || character === '\f');
}
2020-07-26 18:11:18 +00:00
}, {
key: "_skipOptionalSpaces",
value: function _skipOptionalSpaces() {
while (this._currentIndex < this._endIndex && this._isCurrentSpace()) {
this._currentIndex++;
}
2020-07-26 18:11:18 +00:00
return this._currentIndex < this._endIndex;
}
2020-07-26 18:11:18 +00:00
}, {
key: "_skipOptionalSpacesOrDelimiter",
value: function _skipOptionalSpacesOrDelimiter() {
if (this._currentIndex < this._endIndex && !this._isCurrentSpace() && this._string.charAt(this._currentIndex) !== ',') {
return false;
}
2020-07-26 18:11:18 +00:00
if (this._skipOptionalSpaces()) {
if (this._currentIndex < this._endIndex && this._string.charAt(this._currentIndex) === ',') {
this._currentIndex++;
2020-07-26 18:11:18 +00:00
this._skipOptionalSpaces();
}
}
2020-07-26 18:11:18 +00:00
return this._currentIndex < this._endIndex;
}
}, {
key: "hasMoreData",
value: function hasMoreData() {
return this._currentIndex < this._endIndex;
}
}, {
key: "peekSegmentType",
value: function peekSegmentType() {
var lookahead = this._string[this._currentIndex];
return this._pathSegTypeFromChar(lookahead);
}
}, {
key: "_pathSegTypeFromChar",
value: function _pathSegTypeFromChar(lookahead) {
switch (lookahead) {
case 'Z':
case 'z':
return SVGPathSeg.PATHSEG_CLOSEPATH;
2020-07-26 18:11:18 +00:00
case 'M':
return SVGPathSeg.PATHSEG_MOVETO_ABS;
2020-07-26 18:11:18 +00:00
case 'm':
return SVGPathSeg.PATHSEG_MOVETO_REL;
2020-07-26 18:11:18 +00:00
case 'L':
return SVGPathSeg.PATHSEG_LINETO_ABS;
2020-07-26 18:11:18 +00:00
case 'l':
return SVGPathSeg.PATHSEG_LINETO_REL;
2020-07-26 18:11:18 +00:00
case 'C':
return SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS;
2020-07-26 18:11:18 +00:00
case 'c':
return SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL;
2020-07-26 18:11:18 +00:00
case 'Q':
return SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS;
2020-07-26 18:11:18 +00:00
case 'q':
return SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL;
2020-07-26 18:11:18 +00:00
case 'A':
return SVGPathSeg.PATHSEG_ARC_ABS;
2020-07-26 18:11:18 +00:00
case 'a':
return SVGPathSeg.PATHSEG_ARC_REL;
2020-07-26 18:11:18 +00:00
case 'H':
return SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS;
2020-07-26 18:11:18 +00:00
case 'h':
return SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL;
2020-07-26 18:11:18 +00:00
case 'V':
return SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS;
2020-07-26 18:11:18 +00:00
case 'v':
return SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL;
2020-07-26 18:11:18 +00:00
case 'S':
return SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS;
2020-07-26 18:11:18 +00:00
case 's':
return SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL;
2020-07-26 18:11:18 +00:00
case 'T':
return SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS;
2020-07-26 18:11:18 +00:00
case 't':
return SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL;
2020-07-26 18:11:18 +00:00
default:
return SVGPathSeg.PATHSEG_UNKNOWN;
}
}
2020-07-26 18:11:18 +00:00
}, {
key: "_nextCommandHelper",
value: function _nextCommandHelper(lookahead, previousCommand) {
// Check for remaining coordinates in the current command.
if ((lookahead === '+' || lookahead === '-' || lookahead === '.' || lookahead >= '0' && lookahead <= '9') && previousCommand !== SVGPathSeg.PATHSEG_CLOSEPATH) {
if (previousCommand === SVGPathSeg.PATHSEG_MOVETO_ABS) {
return SVGPathSeg.PATHSEG_LINETO_ABS;
}
if (previousCommand === SVGPathSeg.PATHSEG_MOVETO_REL) {
return SVGPathSeg.PATHSEG_LINETO_REL;
}
return previousCommand;
}
2020-07-26 18:11:18 +00:00
return SVGPathSeg.PATHSEG_UNKNOWN;
}
2020-07-26 18:11:18 +00:00
}, {
key: "initialCommandIsMoveTo",
value: function initialCommandIsMoveTo() {
// If the path is empty it is still valid, so return true.
if (!this.hasMoreData()) {
return true;
}
2020-07-26 18:11:18 +00:00
var command = this.peekSegmentType(); // Path must start with moveTo.
2020-07-26 18:11:18 +00:00
return command === SVGPathSeg.PATHSEG_MOVETO_ABS || command === SVGPathSeg.PATHSEG_MOVETO_REL;
} // Parse a number from an SVG path. This very closely follows genericParseNumber(...) from Source/core/svg/SVGParserUtilities.cpp.
// Spec: https://www.w3.org/TR/SVG11/single-page.html#paths-PathDataBNF
2020-07-26 18:11:18 +00:00
}, {
key: "_parseNumber",
value: function _parseNumber() {
var exponent = 0;
var integer = 0;
var frac = 1;
var decimal = 0;
var sign = 1;
var expsign = 1;
var startIndex = this._currentIndex;
2020-07-26 18:11:18 +00:00
this._skipOptionalSpaces(); // Read the sign.
2020-07-26 18:11:18 +00:00
if (this._currentIndex < this._endIndex && this._string.charAt(this._currentIndex) === '+') {
this._currentIndex++;
} else if (this._currentIndex < this._endIndex && this._string.charAt(this._currentIndex) === '-') {
this._currentIndex++;
sign = -1;
}
2020-07-26 18:11:18 +00:00
if (this._currentIndex === this._endIndex || (this._string.charAt(this._currentIndex) < '0' || this._string.charAt(this._currentIndex) > '9') && this._string.charAt(this._currentIndex) !== '.') {
// The first character of a number must be one of [0-9+-.].
return undefined;
} // Read the integer part, build right-to-left.
2020-07-26 18:11:18 +00:00
var startIntPartIndex = this._currentIndex;
2020-07-26 18:11:18 +00:00
while (this._currentIndex < this._endIndex && this._string.charAt(this._currentIndex) >= '0' && this._string.charAt(this._currentIndex) <= '9') {
this._currentIndex++; // Advance to first non-digit.
}
2020-07-26 18:11:18 +00:00
if (this._currentIndex !== startIntPartIndex) {
var scanIntPartIndex = this._currentIndex - 1;
var multiplier = 1;
2020-07-26 18:11:18 +00:00
while (scanIntPartIndex >= startIntPartIndex) {
integer += multiplier * (this._string.charAt(scanIntPartIndex--) - '0');
multiplier *= 10;
}
} // Read the decimals.
2020-07-26 18:11:18 +00:00
if (this._currentIndex < this._endIndex && this._string.charAt(this._currentIndex) === '.') {
this._currentIndex++; // There must be a least one digit following the .
2020-07-26 18:11:18 +00:00
if (this._currentIndex >= this._endIndex || this._string.charAt(this._currentIndex) < '0' || this._string.charAt(this._currentIndex) > '9') {
return undefined;
}
2020-07-26 18:11:18 +00:00
while (this._currentIndex < this._endIndex && this._string.charAt(this._currentIndex) >= '0' && this._string.charAt(this._currentIndex) <= '9') {
frac *= 10;
decimal += (this._string.charAt(this._currentIndex) - '0') / frac;
this._currentIndex += 1;
}
} // Read the exponent part.
2020-07-26 18:11:18 +00:00
if (this._currentIndex !== startIndex && this._currentIndex + 1 < this._endIndex && (this._string.charAt(this._currentIndex) === 'e' || this._string.charAt(this._currentIndex) === 'E') && this._string.charAt(this._currentIndex + 1) !== 'x' && this._string.charAt(this._currentIndex + 1) !== 'm') {
this._currentIndex++; // Read the sign of the exponent.
2020-07-26 18:11:18 +00:00
if (this._string.charAt(this._currentIndex) === '+') {
this._currentIndex++;
} else if (this._string.charAt(this._currentIndex) === '-') {
this._currentIndex++;
expsign = -1;
} // There must be an exponent.
2020-07-26 18:11:18 +00:00
if (this._currentIndex >= this._endIndex || this._string.charAt(this._currentIndex) < '0' || this._string.charAt(this._currentIndex) > '9') {
return undefined;
}
2020-07-26 18:11:18 +00:00
while (this._currentIndex < this._endIndex && this._string.charAt(this._currentIndex) >= '0' && this._string.charAt(this._currentIndex) <= '9') {
exponent *= 10;
exponent += this._string.charAt(this._currentIndex) - '0';
this._currentIndex++;
}
}
2020-07-26 18:11:18 +00:00
var number = integer + decimal;
number *= sign;
2020-07-26 18:11:18 +00:00
if (exponent) {
number *= Math.pow(10, expsign * exponent);
}
2020-07-26 18:11:18 +00:00
if (startIndex === this._currentIndex) {
return undefined;
}
2020-07-26 18:11:18 +00:00
this._skipOptionalSpacesOrDelimiter();
2020-07-26 18:11:18 +00:00
return number;
}
}, {
key: "_parseArcFlag",
value: function _parseArcFlag() {
if (this._currentIndex >= this._endIndex) {
return undefined;
}
2020-07-26 18:11:18 +00:00
var flag = false;
var flagChar = this._string.charAt(this._currentIndex++);
2020-07-26 18:11:18 +00:00
if (flagChar === '0') {
flag = false;
} else if (flagChar === '1') {
flag = true;
} else {
return undefined;
}
2020-07-26 18:11:18 +00:00
this._skipOptionalSpacesOrDelimiter();
2020-07-26 18:11:18 +00:00
return flag;
}
}, {
key: "parseSegment",
value: function parseSegment() {
var lookahead = this._string[this._currentIndex];
var command = this._pathSegTypeFromChar(lookahead);
if (command === SVGPathSeg.PATHSEG_UNKNOWN) {
// Possibly an implicit command. Not allowed if this is the first command.
if (this._previousCommand === SVGPathSeg.PATHSEG_UNKNOWN) {
return null;
}
command = this._nextCommandHelper(lookahead, this._previousCommand);
if (command === SVGPathSeg.PATHSEG_UNKNOWN) {
return null;
}
} else {
this._currentIndex++;
}
2020-07-26 18:11:18 +00:00
this._previousCommand = command;
switch (command) {
case SVGPathSeg.PATHSEG_MOVETO_REL:
return new SVGPathSegMovetoRel(owningPathSegList, this._parseNumber(), this._parseNumber());
case SVGPathSeg.PATHSEG_MOVETO_ABS:
return new SVGPathSegMovetoAbs(owningPathSegList, this._parseNumber(), this._parseNumber());
case SVGPathSeg.PATHSEG_LINETO_REL:
return new SVGPathSegLinetoRel(owningPathSegList, this._parseNumber(), this._parseNumber());
case SVGPathSeg.PATHSEG_LINETO_ABS:
return new SVGPathSegLinetoAbs(owningPathSegList, this._parseNumber(), this._parseNumber());
case SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL:
return new SVGPathSegLinetoHorizontalRel(owningPathSegList, this._parseNumber());
case SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS:
return new SVGPathSegLinetoHorizontalAbs(owningPathSegList, this._parseNumber());
case SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL:
return new SVGPathSegLinetoVerticalRel(owningPathSegList, this._parseNumber());
case SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS:
return new SVGPathSegLinetoVerticalAbs(owningPathSegList, this._parseNumber());
case SVGPathSeg.PATHSEG_CLOSEPATH:
this._skipOptionalSpaces();
return new SVGPathSegClosePath(owningPathSegList);
case SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL:
{
var points = {
x1: this._parseNumber(),
y1: this._parseNumber(),
x2: this._parseNumber(),
y2: this._parseNumber(),
x: this._parseNumber(),
y: this._parseNumber()
};
return new SVGPathSegCurvetoCubicRel(owningPathSegList, points.x, points.y, points.x1, points.y1, points.x2, points.y2);
}
case SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS:
{
var _points = {
x1: this._parseNumber(),
y1: this._parseNumber(),
x2: this._parseNumber(),
y2: this._parseNumber(),
x: this._parseNumber(),
y: this._parseNumber()
};
return new SVGPathSegCurvetoCubicAbs(owningPathSegList, _points.x, _points.y, _points.x1, _points.y1, _points.x2, _points.y2);
}
case SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL:
{
var _points2 = {
x2: this._parseNumber(),
y2: this._parseNumber(),
x: this._parseNumber(),
y: this._parseNumber()
};
return new SVGPathSegCurvetoCubicSmoothRel(owningPathSegList, _points2.x, _points2.y, _points2.x2, _points2.y2);
}
case SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS:
{
var _points3 = {
x2: this._parseNumber(),
y2: this._parseNumber(),
x: this._parseNumber(),
y: this._parseNumber()
};
return new SVGPathSegCurvetoCubicSmoothAbs(owningPathSegList, _points3.x, _points3.y, _points3.x2, _points3.y2);
}
case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL:
{
var _points4 = {
x1: this._parseNumber(),
y1: this._parseNumber(),
x: this._parseNumber(),
y: this._parseNumber()
};
return new SVGPathSegCurvetoQuadraticRel(owningPathSegList, _points4.x, _points4.y, _points4.x1, _points4.y1);
}
case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS:
{
var _points5 = {
x1: this._parseNumber(),
y1: this._parseNumber(),
x: this._parseNumber(),
y: this._parseNumber()
};
return new SVGPathSegCurvetoQuadraticAbs(owningPathSegList, _points5.x, _points5.y, _points5.x1, _points5.y1);
}
case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL:
return new SVGPathSegCurvetoQuadraticSmoothRel(owningPathSegList, this._parseNumber(), this._parseNumber());
case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS:
return new SVGPathSegCurvetoQuadraticSmoothAbs(owningPathSegList, this._parseNumber(), this._parseNumber());
case SVGPathSeg.PATHSEG_ARC_REL:
{
var _points6 = {
x1: this._parseNumber(),
y1: this._parseNumber(),
arcAngle: this._parseNumber(),
arcLarge: this._parseArcFlag(),
arcSweep: this._parseArcFlag(),
x: this._parseNumber(),
y: this._parseNumber()
};
return new SVGPathSegArcRel(owningPathSegList, _points6.x, _points6.y, _points6.x1, _points6.y1, _points6.arcAngle, _points6.arcLarge, _points6.arcSweep);
}
case SVGPathSeg.PATHSEG_ARC_ABS:
{
var _points7 = {
x1: this._parseNumber(),
y1: this._parseNumber(),
arcAngle: this._parseNumber(),
arcLarge: this._parseArcFlag(),
arcSweep: this._parseArcFlag(),
x: this._parseNumber(),
y: this._parseNumber()
};
return new SVGPathSegArcAbs(owningPathSegList, _points7.x, _points7.y, _points7.x1, _points7.y1, _points7.arcAngle, _points7.arcLarge, _points7.arcSweep);
}
default:
throw new Error('Unknown path seg type.');
}
}
}]);
2020-07-26 18:11:18 +00:00
return Source;
}();
2020-07-26 18:11:18 +00:00
var builder = new Builder();
var source = new Source(string);
2020-07-26 18:11:18 +00:00
if (!source.initialCommandIsMoveTo()) {
return [];
}
2020-07-26 18:11:18 +00:00
while (source.hasMoreData()) {
var pathSeg = source.parseSegment();
2020-07-26 18:11:18 +00:00
if (!pathSeg) {
return [];
}
2020-07-26 18:11:18 +00:00
builder.appendSegment(pathSeg);
}
2020-07-26 18:11:18 +00:00
return builder.pathSegList;
} // STATIC
}], [{
key: "_pathSegArrayAsString",
value: function _pathSegArrayAsString(pathSegArray) {
var string = '';
var first = true;
pathSegArray.forEach(function (pathSeg) {
if (first) {
first = false;
string += pathSeg._asPathString();
} else {
string += ' ' + pathSeg._asPathString();
}
});
return string;
}
}]);
return SVGPathSegList;
}();
SVGPathSegList.prototype.classname = 'SVGPathSegList';
Object.defineProperty(SVGPathSegList.prototype, 'numberOfItems', {
2020-07-26 18:11:18 +00:00
get: function get() {
this._checkPathSynchronizedToList();
return this._list.length;
},
enumerable: true
}); // Add the pathSegList accessors to SVGPathElement.
// Spec: https://www.w3.org/TR/SVG11/single-page.html#paths-InterfaceSVGAnimatedPathData
Object.defineProperties(SVGPathElement.prototype, {
pathSegList: {
2020-07-26 18:11:18 +00:00
get: function get() {
if (!this._pathSegList) {
this._pathSegList = new SVGPathSegList(this);
}
return this._pathSegList;
},
enumerable: true
},
// TODO: The following are not implemented and simply return SVGPathElement.pathSegList.
normalizedPathSegList: {
2020-07-26 18:11:18 +00:00
get: function get() {
return this.pathSegList;
},
enumerable: true
},
animatedPathSegList: {
2020-07-26 18:11:18 +00:00
get: function get() {
return this.pathSegList;
},
enumerable: true
},
animatedNormalizedPathSegList: {
2020-07-26 18:11:18 +00:00
get: function get() {
return this.pathSegList;
},
enumerable: true
}
});
window.SVGPathSegList = SVGPathSegList;
}
})();
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`); also expect one directory higher; incorporates #207 (@iuyiuy) - Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons) - Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for better namespacing); incorporates #207 (@iuyiuy) - Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine) - Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed - Fix: Update Atom feed reference in HTML - Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes - Enhancement: Move config-sample.js out of `editor` directory - Enhancement: For `callback`-style extensions, also provide config object; add following to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml - Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel; make Node build routine for converting modular source to non-modular, use `loadStylesheets` for modular stylehsheet defining (but parallel loading); - Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default). - Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines - Refactoring: Avoid embedded API adding inline JavaScript listener - Refactoring: Move layers and context code to `draw.js` - Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js` - Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing) - Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency - Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules - Refactoring: Further avoidance of quotes on properties (as possible) - Refactoring: Use `class` in place of functions where intended as classes - Refactoring: Consistency and granularity in extensions imports - Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions - Testing: Add node-static for automating (and accessing out-of-directory contents) - Testing: Avoid HTML attributes for styling - Testing: Add npm `test` script - Testing: Comment out unused jQuery SVG test - Testing: Add test1 and svgutils_performance_test to all tests page - Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class - npm: Update devDeps - npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
// The button toggles whether the path is open or closed
- Breaking change: Extension now formatted as export (and `this` is set to editor, including for `callback`) - Breaking change: Locale now formatted as export - Breaking change: Moved out remaining modular i18n (imagelib) to own folder - Breaking change: Drop `executeAfterLoads` (and getJSPDF/getCanvg) - Breaking change: `RGBColor` must accept `new` - Breaking change: canvg - `stackBlurCanvasRGBA` must be set now by function (`setStackBlurCanvasRGBA`) rather than global; `canvg` now a named export - Breaking change: Avoid passing `canvg`/`buildCanvgCallback` to extensions (have them import) - Fix: i18nize imaglib more deeply - Fix: Positioning of Document Properties dialog (Fixes #246) - Fix (regression): PDF Export (Fixes #249) - Fix (regression): Add polyfill for `ChildNode`/`ParentNode` (and use further) - Fix (regression): Apply Babel universally to dependencies - Fix (regression): Ordering of `uaPrefix` function in `svgEditor.js` - Fix (regression): Embedded API - Fix (embedded editor): Fix backspace key in Firefox so it doesn't navigate out of frame - Fix: Alert if no exportWindow for PDF (e.g., if blocked) - Refactoring( RGBColor) `RGBColor` as class, without rebuilding constants, optimize string replacement, move methods to prototype, use templates and object literals, use `Object.keys` - Refactoring (canvg) Use classes more internally, use shorthand objects; array extras, return to lazy-loading - Refactoring: Use Promises in place of `$.getScript`; always return Promises in case deciding to await resolving - Refactoring: Avoid importing `RGBColor` into `svgutils.js` (jsPDF imports it itself) - Refactoring: Arrow functions, destructuring, shorter property references - Refactoring: Fix `lang` and `dir` for locales (though not in use currently anyways) - Refactoring: Provide path config for canvg, jspdf
2018-06-02 01:14:38 +00:00
var extClosepath = {
- Security fix: 'extPath', 'imgPath', 'extIconsPath', 'canvgPath', 'langPath', 'jGraduatePath', and 'jspdfPath' were not being prevented - Breaking change: Rename "svgutils.js" to "utilities.js" (make in conformity with JSDoc module naming convention) - Breaking change: Rename "svgedit.js" to "namespaces.js" (to make clear purpose and avoid confusing with editor) - Breaking change: Rename "jquery-svg.js" to "jQuery.attr.js" - Breaking change: Rename "jquery.contextMenu.js" to "jQuery.contextMenu.js" - Breaking change: Rename "jquery.jpicker.js" to "jQuery.jPicker.js" - Breaking change: Rename "JQuerySpinBtn.css" to "jQuery.SpinButton.css" - Breaking change: Rename "JQuerySpinBtn.js" to "jQuery.SpinButton.js" (to have file name more closely reflect name) - Breaking change: Rename "jquery.svgicons.js" to "jQuery.svgIcons.js" - Breaking change: Rename "jquery.jgraduate.js" to "jQuery.jGraduate.js" - Breaking change: Rename "pathseg.js" to "svgpathseg.js" (as it is a poyfill of SVGPathSeg) - Breaking change: Rename `addSvgElementFromJson()` to `addSVGElementFromJson` for consistency - Breaking change: Rename `changeSvgContent()` to `changeSVGContent()` for consistency - Breaking change: Have `exportPDF` resolve with `output` and `outputType` rather than `dataurlstring` (as type may vary) - Breaking change: Rename `extensions/mathjax/MathJax.js` to `extensions/mathjax/MathJax.min.js` - Breaking change: Avoid recent change to have editor ready callbacks return Promises (we're not using and advantageous to keep sequential) - Breaking change: Avoid recent addition of locale-side function in ext-imagelib for l10n - Breaking change: Change name of ext-arrows.js from `Arrows` to `arrows` for sake of file path (not localized anyways). - Breaking change: Change `addlangData` extension event to `addLangData` for consistency with method name - Breaking change: Have `readLang` return lang and data but do not call `setLang` - Fix: Have general locales load first so extensions may use - Fix: Provide `importLocale` to extensions `init` so it may delay adding of the extension until locale data loaded - Fix: Ensure call to `rasterExport` without `imgType` properly sets MIME type to PNG - Fix: Wrong name for moinsave - Update: Update WebAppFind per new API changes - Enhancement: Make `setStrings` public on editor for late setting (used by `ext-shapes.js`) - Enhancement: Add `extensions_added` event - Enhancement: Add `message` event (Relay messages including those which have been been received prior to extension load) - Enhancement: Allow SVGEdit to work out of the box--avoid need for copying sample config file. Should also help with Github-based file servers - Enhancement: Allow avoiding "name" in extension export (just extract out of file name) - Enhancement: Add stack blur to canvg by default (and refactoring it) - Enhancement: Return `Promise` for `embedImage` (as with some other loading methods) - Enhancement: Supply `importLocale` to `langReady` to facilitate extension locale loading - Enhancement: Recover if an extension fails to load (just log and otherwise ignore) - Enhancement: More i18n of extensions (also fixed issue with some console warnings about missing locale strings); i18nize Hello World too - Enhancement: Allowing importing of locales within `addLangData` - npm: Update devDeps - Docs: Migrate copies of all old wiki pages to docs/from-old-wiki folder; intended for a possible move to Markdown, so raw HTML (with formatting) was not preserved, though named links had their absolute URL links preserved - Docs: Begin deleting `SvgCanvas.md` as ensuring jsdoc has replacements - Docs: Add Edtior doc file for help to general users - Docs: Clarify/simplify install instructions - npm/Docs (JSDoc): Add script to check for overly generic types - Docs (JSDoc): For config/prefs and extension creating, link to tutorials (moved tutorials to own directory to avoid recursion problems by jsdoc) - Docs (JSDoc): Add modules (upper case for usual main entrance files or regular names) - Docs (JSDoc): Fill out missing areas; indicate return of `undefined`; consistency with `@returns` - Docs (JSDoc): Add our own layout template to support overflow - Docs (JSDoc): Use cleverLinks and disallow unknown tags - Docs (JSDoc): Insist on "pedantic" flag; put output directory in config - Docs (JSDoc): Use more precise Integer/Float over number, the specific type of array/function/object - Docs (JSDoc): Use `@throws`, `@enum`, `@event`/`@fires`/`@listens` - Docs: Generally update/improve docs (fixes #92) - Docs: Update links to `latest` path (Avoid needing to update such references upon each release) - Docs: 80 chars max - Refactoring: Drop code for extension as function (already requiring export to be an object) - Refactoring: Object destructuring, `Object.entries`, Object shorthand, array extras, more camelCase variable names - Refactoring: Add a `Command` base class - Refactoring: Simplify svgicons `callback` ready detection - Refactoring: Put `let` or `const` closer to scope - Refactoring: Remove unneeded `delimiter` from regex escaping utility - Refactoring: Clearer variable names - Refactoring: Use (non-deprecated) Event constructors - Testing: Use new Sinon
2018-06-06 07:26:20 +00:00
name: 'closepath',
2020-07-26 18:11:18 +00:00
init: function init(_ref) {
var _this = this;
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
var importLocale, $, strings, svgEditor, selElems, updateButton, showPanel, toggleClosed, buttons;
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
importLocale = _ref.importLocale, $ = _ref.$;
_context.next = 3;
return importLocale();
case 3:
strings = _context.sent;
svgEditor = _this;
updateButton = function updateButton(path) {
var seglist = path.pathSegList,
closed = seglist.getItem(seglist.numberOfItems - 1).pathSegType === 1,
showbutton = closed ? '#tool_openpath' : '#tool_closepath',
hidebutton = closed ? '#tool_closepath' : '#tool_openpath';
$(hidebutton).hide();
$(showbutton).show();
};
showPanel = function showPanel(on) {
$('#closepath_panel').toggle(on);
if (on) {
var path = selElems[0];
if (path) {
updateButton(path);
}
}
};
2020-07-26 18:11:18 +00:00
toggleClosed = function toggleClosed() {
var path = selElems[0];
2020-07-26 18:11:18 +00:00
if (path) {
var seglist = path.pathSegList,
last = seglist.numberOfItems - 1; // is closed
- Security fix: 'extPath', 'imgPath', 'extIconsPath', 'canvgPath', 'langPath', 'jGraduatePath', and 'jspdfPath' were not being prevented - Breaking change: Rename "svgutils.js" to "utilities.js" (make in conformity with JSDoc module naming convention) - Breaking change: Rename "svgedit.js" to "namespaces.js" (to make clear purpose and avoid confusing with editor) - Breaking change: Rename "jquery-svg.js" to "jQuery.attr.js" - Breaking change: Rename "jquery.contextMenu.js" to "jQuery.contextMenu.js" - Breaking change: Rename "jquery.jpicker.js" to "jQuery.jPicker.js" - Breaking change: Rename "JQuerySpinBtn.css" to "jQuery.SpinButton.css" - Breaking change: Rename "JQuerySpinBtn.js" to "jQuery.SpinButton.js" (to have file name more closely reflect name) - Breaking change: Rename "jquery.svgicons.js" to "jQuery.svgIcons.js" - Breaking change: Rename "jquery.jgraduate.js" to "jQuery.jGraduate.js" - Breaking change: Rename "pathseg.js" to "svgpathseg.js" (as it is a poyfill of SVGPathSeg) - Breaking change: Rename `addSvgElementFromJson()` to `addSVGElementFromJson` for consistency - Breaking change: Rename `changeSvgContent()` to `changeSVGContent()` for consistency - Breaking change: Have `exportPDF` resolve with `output` and `outputType` rather than `dataurlstring` (as type may vary) - Breaking change: Rename `extensions/mathjax/MathJax.js` to `extensions/mathjax/MathJax.min.js` - Breaking change: Avoid recent change to have editor ready callbacks return Promises (we're not using and advantageous to keep sequential) - Breaking change: Avoid recent addition of locale-side function in ext-imagelib for l10n - Breaking change: Change name of ext-arrows.js from `Arrows` to `arrows` for sake of file path (not localized anyways). - Breaking change: Change `addlangData` extension event to `addLangData` for consistency with method name - Breaking change: Have `readLang` return lang and data but do not call `setLang` - Fix: Have general locales load first so extensions may use - Fix: Provide `importLocale` to extensions `init` so it may delay adding of the extension until locale data loaded - Fix: Ensure call to `rasterExport` without `imgType` properly sets MIME type to PNG - Fix: Wrong name for moinsave - Update: Update WebAppFind per new API changes - Enhancement: Make `setStrings` public on editor for late setting (used by `ext-shapes.js`) - Enhancement: Add `extensions_added` event - Enhancement: Add `message` event (Relay messages including those which have been been received prior to extension load) - Enhancement: Allow SVGEdit to work out of the box--avoid need for copying sample config file. Should also help with Github-based file servers - Enhancement: Allow avoiding "name" in extension export (just extract out of file name) - Enhancement: Add stack blur to canvg by default (and refactoring it) - Enhancement: Return `Promise` for `embedImage` (as with some other loading methods) - Enhancement: Supply `importLocale` to `langReady` to facilitate extension locale loading - Enhancement: Recover if an extension fails to load (just log and otherwise ignore) - Enhancement: More i18n of extensions (also fixed issue with some console warnings about missing locale strings); i18nize Hello World too - Enhancement: Allowing importing of locales within `addLangData` - npm: Update devDeps - Docs: Migrate copies of all old wiki pages to docs/from-old-wiki folder; intended for a possible move to Markdown, so raw HTML (with formatting) was not preserved, though named links had their absolute URL links preserved - Docs: Begin deleting `SvgCanvas.md` as ensuring jsdoc has replacements - Docs: Add Edtior doc file for help to general users - Docs: Clarify/simplify install instructions - npm/Docs (JSDoc): Add script to check for overly generic types - Docs (JSDoc): For config/prefs and extension creating, link to tutorials (moved tutorials to own directory to avoid recursion problems by jsdoc) - Docs (JSDoc): Add modules (upper case for usual main entrance files or regular names) - Docs (JSDoc): Fill out missing areas; indicate return of `undefined`; consistency with `@returns` - Docs (JSDoc): Add our own layout template to support overflow - Docs (JSDoc): Use cleverLinks and disallow unknown tags - Docs (JSDoc): Insist on "pedantic" flag; put output directory in config - Docs (JSDoc): Use more precise Integer/Float over number, the specific type of array/function/object - Docs (JSDoc): Use `@throws`, `@enum`, `@event`/`@fires`/`@listens` - Docs: Generally update/improve docs (fixes #92) - Docs: Update links to `latest` path (Avoid needing to update such references upon each release) - Docs: 80 chars max - Refactoring: Drop code for extension as function (already requiring export to be an object) - Refactoring: Object destructuring, `Object.entries`, Object shorthand, array extras, more camelCase variable names - Refactoring: Add a `Command` base class - Refactoring: Simplify svgicons `callback` ready detection - Refactoring: Put `let` or `const` closer to scope - Refactoring: Remove unneeded `delimiter` from regex escaping utility - Refactoring: Clearer variable names - Refactoring: Use (non-deprecated) Event constructors - Testing: Use new Sinon
2018-06-06 07:26:20 +00:00
2020-07-26 18:11:18 +00:00
if (seglist.getItem(last).pathSegType === 1) {
seglist.removeItem(last);
} else {
seglist.appendItem(path.createSVGPathSegClosePath());
}
2020-07-26 18:11:18 +00:00
updateButton(path);
}
};
buttons = [{
id: 'tool_openpath',
icon: svgEditor.curConfig.extIconsPath + 'openpath.png',
type: 'context',
panel: 'closepath_panel',
events: {
click: function click() {
toggleClosed();
}
}
}, {
id: 'tool_closepath',
icon: svgEditor.curConfig.extIconsPath + 'closepath.png',
type: 'context',
panel: 'closepath_panel',
events: {
click: function click() {
toggleClosed();
}
}
}];
return _context.abrupt("return", {
name: strings.name,
svgicons: svgEditor.curConfig.extIconsPath + 'closepath_icons.svg',
buttons: strings.buttons.map(function (button, i) {
return Object.assign(buttons[i], button);
}),
callback: function callback() {
$('#closepath_panel').hide();
},
selectedChanged: function selectedChanged(opts) {
selElems = opts.elems;
var i = selElems.length;
while (i--) {
var elem = selElems[i];
if (elem && elem.tagName === 'path') {
if (opts.selectedElement && !opts.multiselected) {
showPanel(true);
} else {
showPanel(false);
}
} else {
showPanel(false);
}
}
}
});
2020-07-26 18:11:18 +00:00
case 10:
case "end":
return _context.stop();
}
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`); also expect one directory higher; incorporates #207 (@iuyiuy) - Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons) - Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for better namespacing); incorporates #207 (@iuyiuy) - Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine) - Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed - Fix: Update Atom feed reference in HTML - Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes - Enhancement: Move config-sample.js out of `editor` directory - Enhancement: For `callback`-style extensions, also provide config object; add following to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml - Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel; make Node build routine for converting modular source to non-modular, use `loadStylesheets` for modular stylehsheet defining (but parallel loading); - Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default). - Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines - Refactoring: Avoid embedded API adding inline JavaScript listener - Refactoring: Move layers and context code to `draw.js` - Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js` - Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing) - Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency - Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules - Refactoring: Further avoidance of quotes on properties (as possible) - Refactoring: Use `class` in place of functions where intended as classes - Refactoring: Consistency and granularity in extensions imports - Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions - Testing: Add node-static for automating (and accessing out-of-directory contents) - Testing: Avoid HTML attributes for styling - Testing: Add npm `test` script - Testing: Comment out unused jQuery SVG test - Testing: Add test1 and svgutils_performance_test to all tests page - Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class - npm: Update devDeps - npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
}
2020-07-26 18:11:18 +00:00
}, _callee);
}))();
}
- Breaking change: Extension now formatted as export (and `this` is set to editor, including for `callback`) - Breaking change: Locale now formatted as export - Breaking change: Moved out remaining modular i18n (imagelib) to own folder - Breaking change: Drop `executeAfterLoads` (and getJSPDF/getCanvg) - Breaking change: `RGBColor` must accept `new` - Breaking change: canvg - `stackBlurCanvasRGBA` must be set now by function (`setStackBlurCanvasRGBA`) rather than global; `canvg` now a named export - Breaking change: Avoid passing `canvg`/`buildCanvgCallback` to extensions (have them import) - Fix: i18nize imaglib more deeply - Fix: Positioning of Document Properties dialog (Fixes #246) - Fix (regression): PDF Export (Fixes #249) - Fix (regression): Add polyfill for `ChildNode`/`ParentNode` (and use further) - Fix (regression): Apply Babel universally to dependencies - Fix (regression): Ordering of `uaPrefix` function in `svgEditor.js` - Fix (regression): Embedded API - Fix (embedded editor): Fix backspace key in Firefox so it doesn't navigate out of frame - Fix: Alert if no exportWindow for PDF (e.g., if blocked) - Refactoring( RGBColor) `RGBColor` as class, without rebuilding constants, optimize string replacement, move methods to prototype, use templates and object literals, use `Object.keys` - Refactoring (canvg) Use classes more internally, use shorthand objects; array extras, return to lazy-loading - Refactoring: Use Promises in place of `$.getScript`; always return Promises in case deciding to await resolving - Refactoring: Avoid importing `RGBColor` into `svgutils.js` (jsPDF imports it itself) - Refactoring: Arrow functions, destructuring, shorter property references - Refactoring: Fix `lang` and `dir` for locales (though not in use currently anyways) - Refactoring: Provide path config for canvg, jspdf
2018-06-02 01:14:38 +00:00
};
return extClosepath;
- Breaking change: Rename config file to `svgedit-config-iife.js` (or for the module version, `svgedit-config-es.js`); also expect one directory higher; incorporates #207 (@iuyiuy) - Breaking change: Separate `extIconsPath` from `extPath` (not copying over icons) - Breaking change: Don't reference `custom.css` in HTML; can instead be referenced in JavaScript through the config file (provided in `svgedit-config-sample-iife.js`/`svgedit-config-sample-es.js` as `svgedit-custom.css` for better namespacing); incorporates #207 (@iuyiuy) - Breaking change: Remove minified jgraduate/spinbtn files (minified within Rollup routine) - Fix: Zoom when scrolled; incorporates #169 (@AndrolGenhald), adapting for conventions; also allow avoidance when shift key pressed - Fix: Update Atom feed reference in HTML - Fixes related to recent commits: Some path and method name fixes needed, function order, missing methods, variable scope declaration, no need for DOMContentLoaded listeners in modules, switch back to non-default export, avoid trimming nullish, deal with mock tests, fix `math.matrixMultiply`, use jquery-svg where needed for array/SVG attributes; add babel-polyfill and defer script to imagelib; other misc. fixes - Enhancement: Move config-sample.js out of `editor` directory - Enhancement: For `callback`-style extensions, also provide config object; add following to that object: buildCanvgCallback, canvg, decode64, encode64, executeAfterLoads, getTypeMap, isChrome, ieIE, NS, text2xml - Enhancement: Complete ES6 modules work (extensions, locales, tests), along with Babel; make Node build routine for converting modular source to non-modular, use `loadStylesheets` for modular stylehsheet defining (but parallel loading); - Enhancement: Add `stylesheets` config for modular but parallel stylesheet loading with `@default` option for simple inclusion/exclusion of defaults (if not going with default). - Refactoring: Clean up `svg-editor.html`: consistent indents; avoid extra lbs, avoid long lines - Refactoring: Avoid embedded API adding inline JavaScript listener - Refactoring: Move layers and context code to `draw.js` - Refactoring: Move `pathActions` from `svgcanvas.js` (though preserve aliases to these methods on `canvas`) and `convertPath` from `svgutils.js` to `path.js` - Refactoring: Move `getStrokedBBox` from `svgcanvas.js` (while keeping an alias) to `svgutils.js` (as `getStrokedBBoxDefaultVisible` to avoid conflict with existing) - Docs: Remove "dependencies" comments in code except where summarizing role of jQuery or a non-obvious dependency - Refactoring/Linting: Enfore `no-extra-semi` and `quote-props` rules - Refactoring: Further avoidance of quotes on properties (as possible) - Refactoring: Use `class` in place of functions where intended as classes - Refactoring: Consistency and granularity in extensions imports - Testing: Update QUnit to 2.6.1 (node_modules) and Sinon to 5.0.8 (and add sinon-test at 2.1.3) and enforce eslint-plugin-qunit linting rules; update custom extensions - Testing: Add node-static for automating (and accessing out-of-directory contents) - Testing: Avoid HTML attributes for styling - Testing: Add npm `test` script - Testing: Comment out unused jQuery SVG test - Testing: Add test1 and svgutils_performance_test to all tests page - Testing: Due apparently to Path having not been a formal class, the test was calling it without `new`; refactored now with sufficient mock data to take into account it is a class - npm: Update devDeps - npm: Add html modules and config build to test script
2018-05-22 10:03:16 +00:00
}());