diff --git a/ShadowEditor.UI/src/svg/SvgDom.js b/ShadowEditor.UI/src/svg/SvgDom.js deleted file mode 100644 index 0f4b4472..00000000 --- a/ShadowEditor.UI/src/svg/SvgDom.js +++ /dev/null @@ -1,57 +0,0 @@ -import Control from '../Control'; - -/** - * SvgDom - * @author tengge / https://github.com/tengge1 - */ -function SvgDom(options) { - Control.call(this, options); - - options = options || {}; - this.width = options.width || 960; - this.height = options.height || 500; - this.children = []; -} - -SvgDom.prototype = Object.create(Control.prototype); -SvgDom.prototype.constructor = SvgDom; - -SvgDom.prototype.add = function (element) { - this.children.push(element); -}; - -SvgDom.prototype.insert = function (index, element) { - this.children.splice(index, 0, element); -}; - -SvgDom.prototype.remove = function (element) { - var index = this.children.indexOf(element); - if (index > -1) { - this.removeAt(index); - } -}; - -SvgDom.prototype.removeAt = function (index) { - this.children.splice(index, 1); -}; - -SvgDom.prototype.removeAll = function () { - this.children = []; -}; - -SvgDom.prototype.clear = function () { - this.removeAll(); -}; - -SvgDom.prototype.render = function () { - this.el = this.parent.append('svg') - .attr('width', this.width) - .attr('height', this.height); - var _this = this; - this.children.forEach(function (n) { - n.parent = _this.el; - n.render.call(n); - }); -}; - -export default SvgDom; \ No newline at end of file diff --git a/ShadowEditor.UI/src/svg/SvgGroup.js b/ShadowEditor.UI/src/svg/SvgGroup.js deleted file mode 100644 index f61812db..00000000 --- a/ShadowEditor.UI/src/svg/SvgGroup.js +++ /dev/null @@ -1,54 +0,0 @@ -import { SvgElement } from './element/SvgElement'; - -/** - * @author tengge / https://github.com/tengge1 - */ - -function SvgGroup(options) { - SvgElement.call(this, options); - options = options || {}; - this.fill = options.fill || null; - this.children = []; -} - -SvgGroup.prototype = Object.create(SvgElement.prototype); -SvgGroup.prototype.constructor = SvgGroup; - -SvgGroup.prototype.add = function(element) { - this.children.push(element); -}; - -SvgGroup.prototype.insert = function(index, element) { - this.children.splice(index, 0, element); -}; - -SvgGroup.prototype.remove = function(element) { - var index = this.children.indexOf(element); - if (index > -1) { - this.removeAt(index); - } -}; - -SvgGroup.prototype.removeAt = function(index) { - this.children.splice(index, 1); -}; - -SvgGroup.prototype.removeAll = function() { - this.children = []; -}; - -SvgGroup.prototype.clear = function() { - this.removeAll(); -}; - -SvgGroup.prototype.render = function() { - this.el = this.parent.append('g') - .call(this.renderStyle, this); - var _this = this; - this.children.forEach(function(n) { - n.parent = _this.el; - n.render.call(n); - }); -}; - -export { SvgGroup }; \ No newline at end of file diff --git a/ShadowEditor.UI/src/svg/element/SvgCircle.js b/ShadowEditor.UI/src/svg/element/SvgCircle.js deleted file mode 100644 index 339fc803..00000000 --- a/ShadowEditor.UI/src/svg/element/SvgCircle.js +++ /dev/null @@ -1,26 +0,0 @@ -import { SvgElement } from './SvgElement'; - -/** - * @author tengge / https://github.com/tengge1 - */ - -function SvgCircle(options) { - SvgElement.call(this, options); - options = options || {}; - this.cx = options.cx || null; - this.cy = options.cy || null; - this.r = options.r || 50; -} - -SvgCircle.prototype = Object.create(SvgElement.prototype); -SvgCircle.prototype.constructor = SvgCircle; - -SvgCircle.prototype.render = function() { - this.parent.append('circle') - .attr('cx', this.cx) - .attr('cy', this.cy) - .attr('r', this.r) - .call(this.renderStyle, this); -}; - -export { SvgCircle }; \ No newline at end of file diff --git a/ShadowEditor.UI/src/svg/element/SvgElement.js b/ShadowEditor.UI/src/svg/element/SvgElement.js deleted file mode 100644 index c4590d7a..00000000 --- a/ShadowEditor.UI/src/svg/element/SvgElement.js +++ /dev/null @@ -1,36 +0,0 @@ -/** - * @author tengge / https://github.com/tengge1 - */ - -function SvgElement(options) { - options = options || []; - this.parent = d3.select(options.parent || document.body); - this.stroke = options.stroke || null; - this.strokeWidth = options.strokeWidth || null; - this.strokeOpacity = options.strokeOpacity || null; - this.strokeLinecap = options.strokeLinecap || null; // butt, square, round - this.fill = options.fill || null; - this.fillOpacity = options.fillOpacity || null; - this.fillRule = options.fillRule || null; // nonzero, evenodd - this.opacity = options.opacity || null; - this.style = options.style || null; -} - -SvgElement.prototype.render = function() { - -}; - -SvgElement.prototype.renderStyle = function(selection, scope) { - return selection - .attr('stroke', scope.stroke) - .attr('stroke-width', scope.strokeWidth) - .attr('stroke-opacity', scope.strokeOpacity) - .attr('stroke-linecap', scope.strokeLinecap) - .attr('fill', scope.fill) - .attr('fill-opacity', scope.fillOpacity) - .attr('fill-rule', scope.fillRule) - .attr('opacity', scope.opacity) - .attr('style', scope.style); -}; - -export { SvgElement }; \ No newline at end of file diff --git a/ShadowEditor.UI/src/svg/element/SvgEllipse.js b/ShadowEditor.UI/src/svg/element/SvgEllipse.js deleted file mode 100644 index 1c7b7b5a..00000000 --- a/ShadowEditor.UI/src/svg/element/SvgEllipse.js +++ /dev/null @@ -1,28 +0,0 @@ -import { SvgElement } from './SvgElement'; - -/** - * @author tengge / https://github.com/tengge1 - */ - -function SvgEllipse(options) { - SvgElement.call(this, options); - options = options || {}; - this.cx = options.cx || null; - this.cy = options.cy || null; - this.rx = options.rx || 100; - this.ry = options.ry || 60; -} - -SvgEllipse.prototype = Object.create(SvgElement.prototype); -SvgEllipse.prototype.constructor = SvgEllipse; - -SvgEllipse.prototype.render = function() { - this.parent.append('ellipse') - .attr('cx', this.cx) - .attr('cy', this.cy) - .attr('rx', this.rx) - .attr('ry', this.ry) - .call(this.renderStyle, this); -}; - -export { SvgEllipse }; \ No newline at end of file diff --git a/ShadowEditor.UI/src/svg/element/SvgLine.js b/ShadowEditor.UI/src/svg/element/SvgLine.js deleted file mode 100644 index 1984aa85..00000000 --- a/ShadowEditor.UI/src/svg/element/SvgLine.js +++ /dev/null @@ -1,30 +0,0 @@ -import { SvgElement } from './SvgElement'; - -/** - * @author tengge / https://github.com/tengge1 - */ - -function SvgLine(options) { - SvgElement.call(this, options); - options = options || {}; - this.x1 = options.x1 || 0; - this.y1 = options.y1 || 0; - this.x2 = options.x2 || 100; - this.y2 = options.y2 || 100; - this.stroke = options.stroke === undefined ? 'red' : options.stroke; - this.strokeWidth = options.strokeWidth || 2; -} - -SvgLine.prototype = Object.create(SvgElement.prototype); -SvgLine.prototype.constructor = SvgLine; - -SvgLine.prototype.render = function() { - this.parent.append('line') - .attr('x1', this.x1) - .attr('y1', this.y1) - .attr('x2', this.x2) - .attr('y2', this.y2) - .call(this.renderStyle, this); -}; - -export { SvgLine }; \ No newline at end of file diff --git a/ShadowEditor.UI/src/svg/element/SvgPath.js b/ShadowEditor.UI/src/svg/element/SvgPath.js deleted file mode 100644 index 5cbc1e9b..00000000 --- a/ShadowEditor.UI/src/svg/element/SvgPath.js +++ /dev/null @@ -1,25 +0,0 @@ -import { SvgElement } from './SvgElement'; - -/** - * @author tengge / https://github.com/tengge1 - */ - -function SvgPath(options) { - SvgElement.call(this, options); - options = options || {}; - this.d = options.d || 'M0 0 L100 0 L100 100 Z'; // M, L, H, V, C, S, Q, T, A, Z - this.stroke = options.stroke || 'red'; - this.strokeWidth = options.strokeWidth || 2; - this.fill = options.fill || 'none'; -} - -SvgPath.prototype = Object.create(SvgElement.prototype); -SvgPath.prototype.constructor = SvgPath; - -SvgPath.prototype.render = function() { - this.parent.append('path') - .attr('d', this.d) - .call(this.renderStyle, this); -}; - -export { SvgPath }; \ No newline at end of file diff --git a/ShadowEditor.UI/src/svg/element/SvgPolygon.js b/ShadowEditor.UI/src/svg/element/SvgPolygon.js deleted file mode 100644 index 9909db3a..00000000 --- a/ShadowEditor.UI/src/svg/element/SvgPolygon.js +++ /dev/null @@ -1,25 +0,0 @@ -import { SvgElement } from './SvgElement'; - -/** - * @author tengge / https://github.com/tengge1 - */ - -function SvgPolygon(options) { - SvgElement.call(this, options); - options = options || {}; - this.points = options.points || '0,0,100,0,100,100,0,100'; - this.stroke = options.stroke || 'red'; - this.strokeWidth = options.strokeWidth || 2; - this.fill = options.fill || 'yellow'; -} - -SvgPolygon.prototype = Object.create(SvgElement.prototype); -SvgPolygon.prototype.constructor = SvgPolygon; - -SvgPolygon.prototype.render = function() { - this.parent.append('polygon') - .attr('points', this.points) - .call(this.renderStyle, this); -}; - -export { SvgPolygon }; \ No newline at end of file diff --git a/ShadowEditor.UI/src/svg/element/SvgPolyline.js b/ShadowEditor.UI/src/svg/element/SvgPolyline.js deleted file mode 100644 index d76263b0..00000000 --- a/ShadowEditor.UI/src/svg/element/SvgPolyline.js +++ /dev/null @@ -1,25 +0,0 @@ -import { SvgElement } from './SvgElement'; - -/** - * @author tengge / https://github.com/tengge1 - */ - -function SvgPolyline(options) { - SvgElement.call(this, options); - options = options || {}; - this.points = options.points || '0,0,100,100,150,100,150,150'; - this.stroke = options.stroke === undefined ? 'red' : options.stroke; - this.strokeWidth = options.strokeWidth || 2; - this.fill = options.fill || 'none'; -} - -SvgPolyline.prototype = Object.create(SvgElement.prototype); -SvgPolyline.prototype.constructor = SvgPolyline; - -SvgPolyline.prototype.render = function() { - this.parent.append('polyline') - .attr('points', this.points) - .call(this.renderStyle, this); -}; - -export { SvgPolyline }; \ No newline at end of file diff --git a/ShadowEditor.UI/src/svg/element/SvgRect.js b/ShadowEditor.UI/src/svg/element/SvgRect.js deleted file mode 100644 index 992dea56..00000000 --- a/ShadowEditor.UI/src/svg/element/SvgRect.js +++ /dev/null @@ -1,32 +0,0 @@ -import { SvgElement } from './SvgElement'; - -/** - * @author tengge / https://github.com/tengge1 - */ - -function SvgRect(options) { - SvgElement.call(this, options); - options = options || {}; - this.x = options.x || null; - this.y = options.y || null; - this.width = options.width || 100; - this.height = options.height || 60; - this.rx = options.rx || null; - this.ry = options.ry || null; -} - -SvgRect.prototype = Object.create(SvgElement.prototype); -SvgRect.prototype.constructor = SvgRect; - -SvgRect.prototype.render = function() { - this.parent.append('rect') - .attr('x', this.x) - .attr('y', this.y) - .attr('width', this.width) - .attr('height', this.height) - .attr('rx', this.rx) - .attr('ry', this.ry) - .call(this.renderStyle, this); -}; - -export { SvgRect }; \ No newline at end of file