- Refactoring: Use `static` keyword for classes

master
Brett Zamir 2019-05-08 09:58:18 +08:00
parent fc0c53f61a
commit 597644999d
22 changed files with 615 additions and 557 deletions

View File

@ -1,5 +1,9 @@
# SVG-Edit CHANGES
## ?
- Refactoring: Use `static` keyword for classes
## 5.0.0
- Breaking change: Switch from deprecated `@babel/polyfill` to

54
dist/canvg.js vendored
View File

@ -521,35 +521,41 @@ var canvg = (function (exports) {
return '#' + r + g + b;
}
/**
* Offers a bulleted list of help.
* @returns {HTMLUListElement}
*/
}], [{
key: "getHelpXML",
value: function getHelpXML() {
var examples = [].concat(_toConsumableArray(colorDefs.flatMap(function (_ref2) {
var example = _ref2.example;
return example;
})), _toConsumableArray(Object.keys(simpleColors)));
var xml = document.createElement('ul');
xml.setAttribute('id', 'rgbcolor-examples');
xml.append.apply(xml, _toConsumableArray(examples.map(function (example) {
try {
var listItem = document.createElement('li');
var listColor = new RGBColor(example);
var exampleDiv = document.createElement('div');
exampleDiv.style.cssText = "\n margin: 3px;\n border: 1px solid black;\n background: ".concat(listColor.toHex(), ";\n color: ").concat(listColor.toHex(), ";");
exampleDiv.append('test');
var listItemValue = " ".concat(example, " -> ").concat(listColor.toRGB(), " -> ").concat(listColor.toHex());
listItem.append(exampleDiv, listItemValue);
return listItem;
} catch (e) {
return '';
}
})));
return xml;
}
}]);
return RGBColor;
}();
RGBColor.getHelpXML = function () {
var examples = [].concat(_toConsumableArray(colorDefs.flatMap(function (_ref2) {
var example = _ref2.example;
return example;
})), _toConsumableArray(Object.keys(simpleColors)));
var xml = document.createElement('ul');
xml.setAttribute('id', 'rgbcolor-examples');
xml.append.apply(xml, _toConsumableArray(examples.map(function (example) {
try {
var listItem = document.createElement('li');
var listColor = new RGBColor(example);
var exampleDiv = document.createElement('div');
exampleDiv.style.cssText = "\nmargin: 3px;\nborder: 1px solid black;\nbackground: ".concat(listColor.toHex(), ";\ncolor: ").concat(listColor.toHex(), ";");
exampleDiv.append('test');
var listItemValue = " ".concat(example, " -> ").concat(listColor.toRGB(), " -> ").concat(listColor.toHex());
listItem.append(exampleDiv, listItemValue);
return listItem;
} catch (e) {
return '';
}
})));
return xml;
};
function _typeof$1(obj) {
if (typeof Symbol === "function" && _typeof(Symbol.iterator) === "symbol") {
_typeof$1 = function _typeof$1(obj) {

View File

@ -521,35 +521,41 @@ var svgEditorExtension_server_moinsave = (function () {
return '#' + r + g + b;
}
/**
* Offers a bulleted list of help.
* @returns {HTMLUListElement}
*/
}], [{
key: "getHelpXML",
value: function getHelpXML() {
var examples = [].concat(_toConsumableArray(colorDefs.flatMap(function (_ref2) {
var example = _ref2.example;
return example;
})), _toConsumableArray(Object.keys(simpleColors)));
var xml = document.createElement('ul');
xml.setAttribute('id', 'rgbcolor-examples');
xml.append.apply(xml, _toConsumableArray(examples.map(function (example) {
try {
var listItem = document.createElement('li');
var listColor = new RGBColor(example);
var exampleDiv = document.createElement('div');
exampleDiv.style.cssText = "\n margin: 3px;\n border: 1px solid black;\n background: ".concat(listColor.toHex(), ";\n color: ").concat(listColor.toHex(), ";");
exampleDiv.append('test');
var listItemValue = " ".concat(example, " -> ").concat(listColor.toRGB(), " -> ").concat(listColor.toHex());
listItem.append(exampleDiv, listItemValue);
return listItem;
} catch (e) {
return '';
}
})));
return xml;
}
}]);
return RGBColor;
}();
RGBColor.getHelpXML = function () {
var examples = [].concat(_toConsumableArray(colorDefs.flatMap(function (_ref2) {
var example = _ref2.example;
return example;
})), _toConsumableArray(Object.keys(simpleColors)));
var xml = document.createElement('ul');
xml.setAttribute('id', 'rgbcolor-examples');
xml.append.apply(xml, _toConsumableArray(examples.map(function (example) {
try {
var listItem = document.createElement('li');
var listColor = new RGBColor(example);
var exampleDiv = document.createElement('div');
exampleDiv.style.cssText = "\nmargin: 3px;\nborder: 1px solid black;\nbackground: ".concat(listColor.toHex(), ";\ncolor: ").concat(listColor.toHex(), ";");
exampleDiv.append('test');
var listItemValue = " ".concat(example, " -> ").concat(listColor.toRGB(), " -> ").concat(listColor.toHex());
listItem.append(exampleDiv, listItemValue);
return listItem;
} catch (e) {
return '';
}
})));
return xml;
};
function _typeof$1(obj) {
if (typeof Symbol === "function" && _typeof(Symbol.iterator) === "symbol") {
_typeof$1 = function _typeof$1(obj) {

View File

@ -521,35 +521,41 @@ var svgEditorExtension_server_opensave = (function () {
return '#' + r + g + b;
}
/**
* Offers a bulleted list of help.
* @returns {HTMLUListElement}
*/
}], [{
key: "getHelpXML",
value: function getHelpXML() {
var examples = [].concat(_toConsumableArray(colorDefs.flatMap(function (_ref2) {
var example = _ref2.example;
return example;
})), _toConsumableArray(Object.keys(simpleColors)));
var xml = document.createElement('ul');
xml.setAttribute('id', 'rgbcolor-examples');
xml.append.apply(xml, _toConsumableArray(examples.map(function (example) {
try {
var listItem = document.createElement('li');
var listColor = new RGBColor(example);
var exampleDiv = document.createElement('div');
exampleDiv.style.cssText = "\n margin: 3px;\n border: 1px solid black;\n background: ".concat(listColor.toHex(), ";\n color: ").concat(listColor.toHex(), ";");
exampleDiv.append('test');
var listItemValue = " ".concat(example, " -> ").concat(listColor.toRGB(), " -> ").concat(listColor.toHex());
listItem.append(exampleDiv, listItemValue);
return listItem;
} catch (e) {
return '';
}
})));
return xml;
}
}]);
return RGBColor;
}();
RGBColor.getHelpXML = function () {
var examples = [].concat(_toConsumableArray(colorDefs.flatMap(function (_ref2) {
var example = _ref2.example;
return example;
})), _toConsumableArray(Object.keys(simpleColors)));
var xml = document.createElement('ul');
xml.setAttribute('id', 'rgbcolor-examples');
xml.append.apply(xml, _toConsumableArray(examples.map(function (example) {
try {
var listItem = document.createElement('li');
var listColor = new RGBColor(example);
var exampleDiv = document.createElement('div');
exampleDiv.style.cssText = "\nmargin: 3px;\nborder: 1px solid black;\nbackground: ".concat(listColor.toHex(), ";\ncolor: ").concat(listColor.toHex(), ";");
exampleDiv.append('test');
var listItemValue = " ".concat(example, " -> ").concat(listColor.toRGB(), " -> ").concat(listColor.toHex());
listItem.append(exampleDiv, listItemValue);
return listItem;
} catch (e) {
return '';
}
})));
return xml;
};
function _typeof$1(obj) {
if (typeof Symbol === "function" && _typeof(Symbol.iterator) === "symbol") {
_typeof$1 = function _typeof$1(obj) {

143
dist/index-es.js vendored
View File

@ -2559,6 +2559,22 @@ var getReverseNS = function getReverseNS() {
}
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;
}
}]);
@ -2573,24 +2589,9 @@ var getReverseNS = function getReverseNS() {
return this._list.length;
},
enumerable: true
});
SVGPathSegList._pathSegArrayAsString = function (pathSegArray) {
var string = '';
var first = true;
pathSegArray.forEach(function (pathSeg) {
if (first) {
first = false;
string += pathSeg._asPathString();
} else {
string += ' ' + pathSeg._asPathString();
}
});
return string;
}; // Add the pathSegList accessors to SVGPathElement.
}); // Add the pathSegList accessors to SVGPathElement.
// Spec: https://www.w3.org/TR/SVG11/single-page.html#paths-InterfaceSVGAnimatedPathData
Object.defineProperties(SVGPathElement.prototype, {
pathSegList: {
get: function get() {
@ -6316,46 +6317,48 @@ function () {
grips: grips,
closedSubpath: closedSubpath
});
} // STATIC
/**
* @param {Integer} index
* @returns {boolean}
*/
}], [{
key: "subpathIsClosed",
value: function subpathIsClosed(index) {
var clsd = false; // Check if subpath is already open
path.eachSeg(function (i) {
if (i <= index) {
return true;
}
if (this.type === 2) {
// Found M first, so open
return false;
}
if (this.type === 1) {
// Found Z first, so closed
clsd = true;
return false;
}
return true;
});
return clsd;
}
}]);
return Path;
}();
/**
* @param {Integer} index
* @returns {boolean}
*/
Path.subpathIsClosed = function (index) {
var clsd = false; // Check if subpath is already open
path.eachSeg(function (i) {
if (i <= index) {
return true;
}
if (this.type === 2) {
// Found M first, so open
return false;
}
if (this.type === 1) {
// Found Z first, so closed
clsd = true;
return false;
}
return true;
});
return clsd;
};
/**
* @function module:path.getPath_
* @param {SVGPathElement} elem
* @returns {module:path.Path}
*/
var getPath_ = function getPath_(elem) {
var p = pathData[elem.id];
@ -13160,39 +13163,41 @@ function () {
mgr.rotateGripConnector.setAttribute('y2', nbay - gripRadius * 5);
mgr.rotateGrip.setAttribute('cx', nbax + nbaw / 2);
mgr.rotateGrip.setAttribute('cy', nbay - gripRadius * 5); // }
} // STATIC methods
/**
* Updates cursors for corner grips on rotation so arrows point the right way.
* @param {Float} angle - Current rotation angle in degrees
* @returns {void}
*/
}], [{
key: "updateGripCursors",
value: function updateGripCursors(angle) {
var dirArr = Object.keys(selectorManager_.selectorGrips);
var steps = Math.round(angle / 45);
if (steps < 0) {
steps += 8;
}
while (steps > 0) {
dirArr.push(dirArr.shift());
steps--;
}
Object.values(selectorManager_.selectorGrips).forEach(function (gripElement, i) {
gripElement.setAttribute('style', 'cursor:' + dirArr[i] + '-resize');
});
}
}]);
return Selector;
}();
/**
* Updates cursors for corner grips on rotation so arrows point the right way.
* @param {Float} angle - Current rotation angle in degrees
* @returns {void}
*/
Selector.updateGripCursors = function (angle) {
var dirArr = Object.keys(selectorManager_.selectorGrips);
var steps = Math.round(angle / 45);
if (steps < 0) {
steps += 8;
}
while (steps > 0) {
dirArr.push(dirArr.shift());
steps--;
}
Object.values(selectorManager_.selectorGrips).forEach(function (gripElement, i) {
gripElement.setAttribute('style', 'cursor:' + dirArr[i] + '-resize');
});
};
/**
* Manage all selector objects (selection boxes).
*/
var SelectorManager =
/*#__PURE__*/
function () {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

143
dist/index-umd.js vendored
View File

@ -2565,6 +2565,22 @@
}
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;
}
}]);
@ -2579,24 +2595,9 @@
return this._list.length;
},
enumerable: true
});
SVGPathSegList._pathSegArrayAsString = function (pathSegArray) {
var string = '';
var first = true;
pathSegArray.forEach(function (pathSeg) {
if (first) {
first = false;
string += pathSeg._asPathString();
} else {
string += ' ' + pathSeg._asPathString();
}
});
return string;
}; // Add the pathSegList accessors to SVGPathElement.
}); // Add the pathSegList accessors to SVGPathElement.
// Spec: https://www.w3.org/TR/SVG11/single-page.html#paths-InterfaceSVGAnimatedPathData
Object.defineProperties(SVGPathElement.prototype, {
pathSegList: {
get: function get() {
@ -6322,46 +6323,48 @@
grips: grips,
closedSubpath: closedSubpath
});
} // STATIC
/**
* @param {Integer} index
* @returns {boolean}
*/
}], [{
key: "subpathIsClosed",
value: function subpathIsClosed(index) {
var clsd = false; // Check if subpath is already open
path.eachSeg(function (i) {
if (i <= index) {
return true;
}
if (this.type === 2) {
// Found M first, so open
return false;
}
if (this.type === 1) {
// Found Z first, so closed
clsd = true;
return false;
}
return true;
});
return clsd;
}
}]);
return Path;
}();
/**
* @param {Integer} index
* @returns {boolean}
*/
Path.subpathIsClosed = function (index) {
var clsd = false; // Check if subpath is already open
path.eachSeg(function (i) {
if (i <= index) {
return true;
}
if (this.type === 2) {
// Found M first, so open
return false;
}
if (this.type === 1) {
// Found Z first, so closed
clsd = true;
return false;
}
return true;
});
return clsd;
};
/**
* @function module:path.getPath_
* @param {SVGPathElement} elem
* @returns {module:path.Path}
*/
var getPath_ = function getPath_(elem) {
var p = pathData[elem.id];
@ -13166,39 +13169,41 @@
mgr.rotateGripConnector.setAttribute('y2', nbay - gripRadius * 5);
mgr.rotateGrip.setAttribute('cx', nbax + nbaw / 2);
mgr.rotateGrip.setAttribute('cy', nbay - gripRadius * 5); // }
} // STATIC methods
/**
* Updates cursors for corner grips on rotation so arrows point the right way.
* @param {Float} angle - Current rotation angle in degrees
* @returns {void}
*/
}], [{
key: "updateGripCursors",
value: function updateGripCursors(angle) {
var dirArr = Object.keys(selectorManager_.selectorGrips);
var steps = Math.round(angle / 45);
if (steps < 0) {
steps += 8;
}
while (steps > 0) {
dirArr.push(dirArr.shift());
steps--;
}
Object.values(selectorManager_.selectorGrips).forEach(function (gripElement, i) {
gripElement.setAttribute('style', 'cursor:' + dirArr[i] + '-resize');
});
}
}]);
return Selector;
}();
/**
* Updates cursors for corner grips on rotation so arrows point the right way.
* @param {Float} angle - Current rotation angle in degrees
* @returns {void}
*/
Selector.updateGripCursors = function (angle) {
var dirArr = Object.keys(selectorManager_.selectorGrips);
var steps = Math.round(angle / 45);
if (steps < 0) {
steps += 8;
}
while (steps > 0) {
dirArr.push(dirArr.shift());
steps--;
}
Object.values(selectorManager_.selectorGrips).forEach(function (gripElement, i) {
gripElement.setAttribute('style', 'cursor:' + dirArr[i] + '-resize');
});
};
/**
* Manage all selector objects (selection boxes).
*/
var SelectorManager =
/*#__PURE__*/
function () {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -364,35 +364,41 @@
return '#' + r + g + b;
}
/**
* Offers a bulleted list of help.
* @returns {HTMLUListElement}
*/
}], [{
key: "getHelpXML",
value: function getHelpXML() {
var examples = [].concat(_toConsumableArray(colorDefs.flatMap(function (_ref2) {
var example = _ref2.example;
return example;
})), _toConsumableArray(Object.keys(simpleColors)));
var xml = document.createElement('ul');
xml.setAttribute('id', 'rgbcolor-examples');
xml.append.apply(xml, _toConsumableArray(examples.map(function (example) {
try {
var listItem = document.createElement('li');
var listColor = new RGBColor(example);
var exampleDiv = document.createElement('div');
exampleDiv.style.cssText = "\n margin: 3px;\n border: 1px solid black;\n background: ".concat(listColor.toHex(), ";\n color: ").concat(listColor.toHex(), ";");
exampleDiv.append('test');
var listItemValue = " ".concat(example, " -> ").concat(listColor.toRGB(), " -> ").concat(listColor.toHex());
listItem.append(exampleDiv, listItemValue);
return listItem;
} catch (e) {
return '';
}
})));
return xml;
}
}]);
return RGBColor;
}();
RGBColor.getHelpXML = function () {
var examples = [].concat(_toConsumableArray(colorDefs.flatMap(function (_ref2) {
var example = _ref2.example;
return example;
})), _toConsumableArray(Object.keys(simpleColors)));
var xml = document.createElement('ul');
xml.setAttribute('id', 'rgbcolor-examples');
xml.append.apply(xml, _toConsumableArray(examples.map(function (example) {
try {
var listItem = document.createElement('li');
var listColor = new RGBColor(example);
var exampleDiv = document.createElement('div');
exampleDiv.style.cssText = "\nmargin: 3px;\nborder: 1px solid black;\nbackground: ".concat(listColor.toHex(), ";\ncolor: ").concat(listColor.toHex(), ";");
exampleDiv.append('test');
var listItemValue = " ".concat(example, " -> ").concat(listColor.toRGB(), " -> ").concat(listColor.toHex());
listItem.append(exampleDiv, listItemValue);
return listItem;
} catch (e) {
return '';
}
})));
return xml;
};
var jsPDFAPI = jsPDF.API;
var pdfSvgAttr = {
// allowed attributes. all others are removed from the preview.

View File

@ -2343,6 +2343,22 @@
}
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;
}
}]);
@ -2357,24 +2373,9 @@
return this._list.length;
},
enumerable: true
});
SVGPathSegList._pathSegArrayAsString = function (pathSegArray) {
var string = '';
var first = true;
pathSegArray.forEach(function (pathSeg) {
if (first) {
first = false;
string += pathSeg._asPathString();
} else {
string += ' ' + pathSeg._asPathString();
}
});
return string;
}; // Add the pathSegList accessors to SVGPathElement.
}); // Add the pathSegList accessors to SVGPathElement.
// Spec: https://www.w3.org/TR/SVG11/single-page.html#paths-InterfaceSVGAnimatedPathData
Object.defineProperties(SVGPathElement.prototype, {
pathSegList: {
get: function get() {

143
dist/svgcanvas-iife.js vendored
View File

@ -2437,6 +2437,22 @@ var SvgCanvas = (function () {
}
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;
}
}]);
@ -2451,24 +2467,9 @@ var SvgCanvas = (function () {
return this._list.length;
},
enumerable: true
});
SVGPathSegList._pathSegArrayAsString = function (pathSegArray) {
var string = '';
var first = true;
pathSegArray.forEach(function (pathSeg) {
if (first) {
first = false;
string += pathSeg._asPathString();
} else {
string += ' ' + pathSeg._asPathString();
}
});
return string;
}; // Add the pathSegList accessors to SVGPathElement.
}); // Add the pathSegList accessors to SVGPathElement.
// Spec: https://www.w3.org/TR/SVG11/single-page.html#paths-InterfaceSVGAnimatedPathData
Object.defineProperties(SVGPathElement.prototype, {
pathSegList: {
get: function get() {
@ -6388,46 +6389,48 @@ var SvgCanvas = (function () {
grips: grips,
closedSubpath: closedSubpath
});
} // STATIC
/**
* @param {Integer} index
* @returns {boolean}
*/
}], [{
key: "subpathIsClosed",
value: function subpathIsClosed(index) {
var clsd = false; // Check if subpath is already open
path.eachSeg(function (i) {
if (i <= index) {
return true;
}
if (this.type === 2) {
// Found M first, so open
return false;
}
if (this.type === 1) {
// Found Z first, so closed
clsd = true;
return false;
}
return true;
});
return clsd;
}
}]);
return Path;
}();
/**
* @param {Integer} index
* @returns {boolean}
*/
Path.subpathIsClosed = function (index) {
var clsd = false; // Check if subpath is already open
path.eachSeg(function (i) {
if (i <= index) {
return true;
}
if (this.type === 2) {
// Found M first, so open
return false;
}
if (this.type === 1) {
// Found Z first, so closed
clsd = true;
return false;
}
return true;
});
return clsd;
};
/**
* @function module:path.getPath_
* @param {SVGPathElement} elem
* @returns {module:path.Path}
*/
var getPath_ = function getPath_(elem) {
var p = pathData[elem.id];
@ -12938,39 +12941,41 @@ var SvgCanvas = (function () {
mgr.rotateGripConnector.setAttribute('y2', nbay - gripRadius * 5);
mgr.rotateGrip.setAttribute('cx', nbax + nbaw / 2);
mgr.rotateGrip.setAttribute('cy', nbay - gripRadius * 5); // }
} // STATIC methods
/**
* Updates cursors for corner grips on rotation so arrows point the right way.
* @param {Float} angle - Current rotation angle in degrees
* @returns {void}
*/
}], [{
key: "updateGripCursors",
value: function updateGripCursors(angle) {
var dirArr = Object.keys(selectorManager_.selectorGrips);
var steps = Math.round(angle / 45);
if (steps < 0) {
steps += 8;
}
while (steps > 0) {
dirArr.push(dirArr.shift());
steps--;
}
Object.values(selectorManager_.selectorGrips).forEach(function (gripElement, i) {
gripElement.setAttribute('style', 'cursor:' + dirArr[i] + '-resize');
});
}
}]);
return Selector;
}();
/**
* Updates cursors for corner grips on rotation so arrows point the right way.
* @param {Float} angle - Current rotation angle in degrees
* @returns {void}
*/
Selector.updateGripCursors = function (angle) {
var dirArr = Object.keys(selectorManager_.selectorGrips);
var steps = Math.round(angle / 45);
if (steps < 0) {
steps += 8;
}
while (steps > 0) {
dirArr.push(dirArr.shift());
steps--;
}
Object.values(selectorManager_.selectorGrips).forEach(function (gripElement, i) {
gripElement.setAttribute('style', 'cursor:' + dirArr[i] + '-resize');
});
};
/**
* Manage all selector objects (selection boxes).
*/
var SelectorManager =
/*#__PURE__*/
function () {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -238,42 +238,42 @@ export default class RGBColor {
if (b.length === 1) { b = '0' + b; }
return '#' + r + g + b;
}
/**
* Offers a bulleted list of help.
* @returns {HTMLUListElement}
*/
static getHelpXML () {
const examples = [
// add regexps
...colorDefs.flatMap(({example}) => {
return example;
}),
// add type-in colors
...Object.keys(simpleColors)
];
const xml = document.createElement('ul');
xml.setAttribute('id', 'rgbcolor-examples');
xml.append(...examples.map((example) => {
try {
const listItem = document.createElement('li');
const listColor = new RGBColor(example);
const exampleDiv = document.createElement('div');
exampleDiv.style.cssText = `
margin: 3px;
border: 1px solid black;
background: ${listColor.toHex()};
color: ${listColor.toHex()};`;
exampleDiv.append('test');
const listItemValue = ` ${example} -> ${listColor.toRGB()} -> ${listColor.toHex()}`;
listItem.append(exampleDiv, listItemValue);
return listItem;
} catch (e) {
return '';
}
}));
return xml;
}
}
/**
* Offers a bulleted list of help.
* @returns {HTMLUListElement}
*/
RGBColor.getHelpXML = function () {
const examples = [
// add regexps
...colorDefs.flatMap(({example}) => {
return example;
}),
// add type-in colors
...Object.keys(simpleColors)
];
const xml = document.createElement('ul');
xml.setAttribute('id', 'rgbcolor-examples');
xml.append(...examples.map((example) => {
try {
const listItem = document.createElement('li');
const listColor = new RGBColor(example);
const exampleDiv = document.createElement('div');
exampleDiv.style.cssText = `
margin: 3px;
border: 1px solid black;
background: ${listColor.toHex()};
color: ${listColor.toHex()};`;
exampleDiv.append('test');
const listItemValue = ` ${example} -> ${listColor.toRGB()} -> ${listColor.toHex()}`;
listItem.append(exampleDiv, listItemValue);
return listItem;
} catch (e) {
return '';
}
}));
return xml;
};

View File

@ -1305,32 +1305,33 @@ export class Path {
const closedSubpath = Path.subpathIsClosed(this.selected_pts[0]);
editorContext_.addPtsToSelection({grips, closedSubpath});
}
// STATIC
/**
* @param {Integer} index
* @returns {boolean}
*/
static subpathIsClosed (index) {
let clsd = false;
// Check if subpath is already open
path.eachSeg(function (i) {
if (i <= index) { return true; }
if (this.type === 2) {
// Found M first, so open
return false;
}
if (this.type === 1) {
// Found Z first, so closed
clsd = true;
return false;
}
return true;
});
return clsd;
}
}
/**
* @param {Integer} index
* @returns {boolean}
*/
Path.subpathIsClosed = function (index) {
let clsd = false;
// Check if subpath is already open
path.eachSeg(function (i) {
if (i <= index) { return true; }
if (this.type === 2) {
// Found M first, so open
return false;
}
if (this.type === 1) {
// Found Z first, so closed
clsd = true;
return false;
}
return true;
});
return clsd;
};
/**
* @function module:path.getPath_
* @param {SVGPathElement} elem

View File

@ -236,24 +236,26 @@ export class Selector {
mgr.rotateGrip.setAttribute('cy', nbay - (gripRadius * 5));
// }
}
}
/**
* Updates cursors for corner grips on rotation so arrows point the right way.
* @param {Float} angle - Current rotation angle in degrees
* @returns {void}
*/
Selector.updateGripCursors = function (angle) {
const dirArr = Object.keys(selectorManager_.selectorGrips);
let steps = Math.round(angle / 45);
if (steps < 0) { steps += 8; }
while (steps > 0) {
dirArr.push(dirArr.shift());
steps--;
// STATIC methods
/**
* Updates cursors for corner grips on rotation so arrows point the right way.
* @param {Float} angle - Current rotation angle in degrees
* @returns {void}
*/
static updateGripCursors (angle) {
const dirArr = Object.keys(selectorManager_.selectorGrips);
let steps = Math.round(angle / 45);
if (steps < 0) { steps += 8; }
while (steps > 0) {
dirArr.push(dirArr.shift());
steps--;
}
Object.values(selectorManager_.selectorGrips).forEach((gripElement, i) => {
gripElement.setAttribute('style', ('cursor:' + dirArr[i] + '-resize'));
});
}
Object.values(selectorManager_.selectorGrips).forEach((gripElement, i) => {
gripElement.setAttribute('style', ('cursor:' + dirArr[i] + '-resize'));
});
};
}
/**
* Manage all selector objects (selection boxes).

View File

@ -922,6 +922,21 @@ if (!('SVGPathSegList' in window) || !('appendItem' in window.SVGPathSegList.pro
return builder.pathSegList;
}
// STATIC
static _pathSegArrayAsString (pathSegArray) {
let string = '';
let first = true;
pathSegArray.forEach((pathSeg) => {
if (first) {
first = false;
string += pathSeg._asPathString();
} else {
string += ' ' + pathSeg._asPathString();
}
});
return string;
}
}
SVGPathSegList.prototype.classname = 'SVGPathSegList';
@ -934,20 +949,6 @@ if (!('SVGPathSegList' in window) || !('appendItem' in window.SVGPathSegList.pro
enumerable: true
});
SVGPathSegList._pathSegArrayAsString = function (pathSegArray) {
let string = '';
let first = true;
pathSegArray.forEach((pathSeg) => {
if (first) {
first = false;
string += pathSeg._asPathString();
} else {
string += ' ' + pathSeg._asPathString();
}
});
return string;
};
// Add the pathSegList accessors to SVGPathElement.
// Spec: https://www.w3.org/TR/SVG11/single-page.html#paths-InterfaceSVGAnimatedPathData
Object.defineProperties(SVGPathElement.prototype, {

View File

@ -120,7 +120,7 @@ let listMap_ = {};
* implementing as much of SVGTransformList that we need to get the job done.
* @implements {module:SVGTransformList.SVGEditTransformList}
*/
export class SVGTransformList {// eslint-disable-line no-shadow
export class SVGTransformList { // eslint-disable-line no-shadow
/**
* @param {Element} elem
*/

View File

@ -2562,6 +2562,22 @@
}
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;
}
}]);
@ -2576,24 +2592,9 @@
return this._list.length;
},
enumerable: true
});
SVGPathSegList._pathSegArrayAsString = function (pathSegArray) {
var string = '';
var first = true;
pathSegArray.forEach(function (pathSeg) {
if (first) {
first = false;
string += pathSeg._asPathString();
} else {
string += ' ' + pathSeg._asPathString();
}
});
return string;
}; // Add the pathSegList accessors to SVGPathElement.
}); // Add the pathSegList accessors to SVGPathElement.
// Spec: https://www.w3.org/TR/SVG11/single-page.html#paths-InterfaceSVGAnimatedPathData
Object.defineProperties(SVGPathElement.prototype, {
pathSegList: {
get: function get() {
@ -6319,46 +6320,48 @@
grips: grips,
closedSubpath: closedSubpath
});
} // STATIC
/**
* @param {Integer} index
* @returns {boolean}
*/
}], [{
key: "subpathIsClosed",
value: function subpathIsClosed(index) {
var clsd = false; // Check if subpath is already open
path.eachSeg(function (i) {
if (i <= index) {
return true;
}
if (this.type === 2) {
// Found M first, so open
return false;
}
if (this.type === 1) {
// Found Z first, so closed
clsd = true;
return false;
}
return true;
});
return clsd;
}
}]);
return Path;
}();
/**
* @param {Integer} index
* @returns {boolean}
*/
Path.subpathIsClosed = function (index) {
var clsd = false; // Check if subpath is already open
path.eachSeg(function (i) {
if (i <= index) {
return true;
}
if (this.type === 2) {
// Found M first, so open
return false;
}
if (this.type === 1) {
// Found Z first, so closed
clsd = true;
return false;
}
return true;
});
return clsd;
};
/**
* @function module:path.getPath_
* @param {SVGPathElement} elem
* @returns {module:path.Path}
*/
var getPath_ = function getPath_(elem) {
var p = pathData[elem.id];
@ -13163,39 +13166,41 @@
mgr.rotateGripConnector.setAttribute('y2', nbay - gripRadius * 5);
mgr.rotateGrip.setAttribute('cx', nbax + nbaw / 2);
mgr.rotateGrip.setAttribute('cy', nbay - gripRadius * 5); // }
} // STATIC methods
/**
* Updates cursors for corner grips on rotation so arrows point the right way.
* @param {Float} angle - Current rotation angle in degrees
* @returns {void}
*/
}], [{
key: "updateGripCursors",
value: function updateGripCursors(angle) {
var dirArr = Object.keys(selectorManager_.selectorGrips);
var steps = Math.round(angle / 45);
if (steps < 0) {
steps += 8;
}
while (steps > 0) {
dirArr.push(dirArr.shift());
steps--;
}
Object.values(selectorManager_.selectorGrips).forEach(function (gripElement, i) {
gripElement.setAttribute('style', 'cursor:' + dirArr[i] + '-resize');
});
}
}]);
return Selector;
}();
/**
* Updates cursors for corner grips on rotation so arrows point the right way.
* @param {Float} angle - Current rotation angle in degrees
* @returns {void}
*/
Selector.updateGripCursors = function (angle) {
var dirArr = Object.keys(selectorManager_.selectorGrips);
var steps = Math.round(angle / 45);
if (steps < 0) {
steps += 8;
}
while (steps > 0) {
dirArr.push(dirArr.shift());
steps--;
}
Object.values(selectorManager_.selectorGrips).forEach(function (gripElement, i) {
gripElement.setAttribute('style', 'cursor:' + dirArr[i] + '-resize');
});
};
/**
* Manage all selector objects (selection boxes).
*/
var SelectorManager =
/*#__PURE__*/
function () {

View File

@ -2562,6 +2562,22 @@
}
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;
}
}]);
@ -2576,24 +2592,9 @@
return this._list.length;
},
enumerable: true
});
SVGPathSegList._pathSegArrayAsString = function (pathSegArray) {
var string = '';
var first = true;
pathSegArray.forEach(function (pathSeg) {
if (first) {
first = false;
string += pathSeg._asPathString();
} else {
string += ' ' + pathSeg._asPathString();
}
});
return string;
}; // Add the pathSegList accessors to SVGPathElement.
}); // Add the pathSegList accessors to SVGPathElement.
// Spec: https://www.w3.org/TR/SVG11/single-page.html#paths-InterfaceSVGAnimatedPathData
Object.defineProperties(SVGPathElement.prototype, {
pathSegList: {
get: function get() {
@ -6319,46 +6320,48 @@
grips: grips,
closedSubpath: closedSubpath
});
} // STATIC
/**
* @param {Integer} index
* @returns {boolean}
*/
}], [{
key: "subpathIsClosed",
value: function subpathIsClosed(index) {
var clsd = false; // Check if subpath is already open
path.eachSeg(function (i) {
if (i <= index) {
return true;
}
if (this.type === 2) {
// Found M first, so open
return false;
}
if (this.type === 1) {
// Found Z first, so closed
clsd = true;
return false;
}
return true;
});
return clsd;
}
}]);
return Path;
}();
/**
* @param {Integer} index
* @returns {boolean}
*/
Path.subpathIsClosed = function (index) {
var clsd = false; // Check if subpath is already open
path.eachSeg(function (i) {
if (i <= index) {
return true;
}
if (this.type === 2) {
// Found M first, so open
return false;
}
if (this.type === 1) {
// Found Z first, so closed
clsd = true;
return false;
}
return true;
});
return clsd;
};
/**
* @function module:path.getPath_
* @param {SVGPathElement} elem
* @returns {module:path.Path}
*/
var getPath_ = function getPath_(elem) {
var p = pathData[elem.id];
@ -13163,39 +13166,41 @@
mgr.rotateGripConnector.setAttribute('y2', nbay - gripRadius * 5);
mgr.rotateGrip.setAttribute('cx', nbax + nbaw / 2);
mgr.rotateGrip.setAttribute('cy', nbay - gripRadius * 5); // }
} // STATIC methods
/**
* Updates cursors for corner grips on rotation so arrows point the right way.
* @param {Float} angle - Current rotation angle in degrees
* @returns {void}
*/
}], [{
key: "updateGripCursors",
value: function updateGripCursors(angle) {
var dirArr = Object.keys(selectorManager_.selectorGrips);
var steps = Math.round(angle / 45);
if (steps < 0) {
steps += 8;
}
while (steps > 0) {
dirArr.push(dirArr.shift());
steps--;
}
Object.values(selectorManager_.selectorGrips).forEach(function (gripElement, i) {
gripElement.setAttribute('style', 'cursor:' + dirArr[i] + '-resize');
});
}
}]);
return Selector;
}();
/**
* Updates cursors for corner grips on rotation so arrows point the right way.
* @param {Float} angle - Current rotation angle in degrees
* @returns {void}
*/
Selector.updateGripCursors = function (angle) {
var dirArr = Object.keys(selectorManager_.selectorGrips);
var steps = Math.round(angle / 45);
if (steps < 0) {
steps += 8;
}
while (steps > 0) {
dirArr.push(dirArr.shift());
steps--;
}
Object.values(selectorManager_.selectorGrips).forEach(function (gripElement, i) {
gripElement.setAttribute('style', 'cursor:' + dirArr[i] + '-resize');
});
};
/**
* Manage all selector objects (selection boxes).
*/
var SelectorManager =
/*#__PURE__*/
function () {