diff options
author | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2018-11-08 12:04:13 +0100 |
---|---|---|
committer | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2018-11-08 12:04:13 +0100 |
commit | 6cebf3bf0e5d3cade7b0a7dc9c8feb191b2eb91f (patch) | |
tree | 3f511399ec23f9d653f2c08f9c62afb4412f0542 | |
parent | 24111571324badc5282cf835c6565576d7fcb90f (diff) | |
download | svg.js-6cebf3bf0e5d3cade7b0a7dc9c8feb191b2eb91f.tar.gz svg.js-6cebf3bf0e5d3cade7b0a7dc9c8feb191b2eb91f.zip |
size function of circle now only accepts one argument (#788)
-rw-r--r-- | CHANGELOG.md | 4 | ||||
-rw-r--r-- | dist/svg.js | 36 | ||||
-rw-r--r-- | src/elements/Circle.js | 10 | ||||
-rw-r--r-- | src/elements/Ellipse.js | 10 | ||||
-rw-r--r-- | src/modules/core/circled.js | 10 |
5 files changed, 41 insertions, 29 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f9c07d..695052f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,7 +22,9 @@ The document follows the conventions described in [“Keep a CHANGELOG”](http: - added `npm build:dev` to let you develop without getting too annoyed - added `beziere()` and `steps()` to generate easing functions - added `insertAfter()` and `insertBefore` -- added `SVG.Style` which can be created with `style()` or `fontface()` +- added `SVG.Style` which can be created with `style()` or `fontface()` (#517) +- added `EventTarget` which is a baseclass to get event abilities (#641) +- added `Dom` which is a baseclass to get dom abilities ### Removed - removed `SVG.Array.split()` function diff --git a/dist/svg.js b/dist/svg.js index bf77e3a..6b05383 100644 --- a/dist/svg.js +++ b/dist/svg.js @@ -6,7 +6,7 @@ * @copyright Wout Fierens <wout@mick-wout.com> * @license MIT * -* BUILT: Thu Nov 08 2018 11:29:15 GMT+0100 (GMT+01:00) +* BUILT: Thu Nov 08 2018 12:02:46 GMT+0100 (GMT+01:00) */; var SVG = (function () { 'use strict'; @@ -2978,11 +2978,6 @@ var SVG = (function () { function height(height) { return height == null ? this.ry() * 2 : this.ry(new SVGNumber(height).divide(2)); - } // Custom size function - - function size(width, height) { - var p = proportionalSize(this, width, height); - return this.rx(new SVGNumber(p.width).divide(2)).ry(new SVGNumber(p.height).divide(2)); } var circled = /*#__PURE__*/Object.freeze({ @@ -2993,8 +2988,7 @@ var SVG = (function () { cx: cx, cy: cy, width: width, - height: height, - size: size + height: height }); var Queue = @@ -4973,7 +4967,7 @@ var SVG = (function () { return this.cx(x$$1).cy(y$$1); }, // Add animatable size - size: function size$$1(width$$1, height$$1) { + size: function size(width$$1, height$$1) { // animate bbox based size for all other elements var box; @@ -5317,6 +5311,11 @@ var SVG = (function () { value: function ry$$1(_ry) { return this.rx(_ry); } + }, { + key: "size", + value: function size(_size) { + return this.radius(new SVGNumber(_size).divide(2)); + } }]); return Circle; @@ -5327,14 +5326,13 @@ var SVG = (function () { cx: cx, cy: cy, width: width, - height: height, - size: size + height: height }); registerMethods({ Element: { // Create circle element - circle: function circle(size$$1) { - return this.put(new Circle()).radius(new SVGNumber(size$$1).divide(2)).move(0, 0); + circle: function circle(size) { + return this.put(new Circle()).size(size).move(0, 0); } } }); @@ -5351,6 +5349,14 @@ var SVG = (function () { return _possibleConstructorReturn(this, _getPrototypeOf(Ellipse).call(this, nodeOrNew('ellipse', node), Ellipse)); } + _createClass(Ellipse, [{ + key: "size", + value: function size(width$$1, height$$1) { + var p = proportionalSize(this, width$$1, height$$1); + return this.rx(new SVGNumber(p.width).divide(2)).ry(new SVGNumber(p.height).divide(2)); + } + }]); + return Ellipse; }(Shape); extend(Ellipse, circled); @@ -6038,7 +6044,7 @@ var SVG = (function () { return this.attr('points', this.array().move(x, y)); } // Set element size to given width and height - function size$1(width, height) { + function size(width, height) { var p = proportionalSize(this, width, height); return this.attr('points', this.array().size(p.width, p.height)); } @@ -6048,7 +6054,7 @@ var SVG = (function () { plot: plot, clear: clear, move: move, - size: size$1 + size: size }); var Polygon = diff --git a/src/elements/Circle.js b/src/elements/Circle.js index c296885..52aaa3d 100644 --- a/src/elements/Circle.js +++ b/src/elements/Circle.js @@ -1,4 +1,4 @@ -import { cx, cy, height, size, width, x, y } from '../modules/core/circled.js' +import { cx, cy, height, width, x, y } from '../modules/core/circled.js' import { extend, nodeOrNew, register } from '../utils/adopter.js' import { registerMethods } from '../utils/methods.js' import SVGNumber from '../types/SVGNumber.js' @@ -22,16 +22,20 @@ export default class Circle extends Shape { ry (ry) { return this.rx(ry) } + + size (size) { + return this.radius(new SVGNumber(size).divide(2)) + } } -extend(Circle, { x, y, cx, cy, width, height, size }) +extend(Circle, { x, y, cx, cy, width, height }) registerMethods({ Element: { // Create circle element circle (size) { return this.put(new Circle()) - .radius(new SVGNumber(size).divide(2)) + .size(size) .move(0, 0) } } diff --git a/src/elements/Ellipse.js b/src/elements/Ellipse.js index 40b9369..b0ee4bf 100644 --- a/src/elements/Ellipse.js +++ b/src/elements/Ellipse.js @@ -1,5 +1,7 @@ import { extend, nodeOrNew, register } from '../utils/adopter.js' +import { proportionalSize } from '../utils/utils.js' import { registerMethods } from '../utils/methods.js' +import SVGNumber from '../types/SVGNumber.js' import Shape from './Shape.js' import * as circled from '../modules/core/circled.js' @@ -7,6 +9,14 @@ export default class Ellipse extends Shape { constructor (node) { super(nodeOrNew('ellipse', node), Ellipse) } + + size (width, height) { + var p = proportionalSize(this, width, height) + + return this + .rx(new SVGNumber(p.width).divide(2)) + .ry(new SVGNumber(p.height).divide(2)) + } } extend(Ellipse, circled) diff --git a/src/modules/core/circled.js b/src/modules/core/circled.js index b94d237..597d252 100644 --- a/src/modules/core/circled.js +++ b/src/modules/core/circled.js @@ -1,4 +1,3 @@ -import { proportionalSize } from '../../utils/utils.js' import SVGNumber from '../../types/SVGNumber.js' // Radius x value @@ -52,12 +51,3 @@ export function height (height) { ? this.ry() * 2 : this.ry(new SVGNumber(height).divide(2)) } - -// Custom size function -export function size (width, height) { - var p = proportionalSize(this, width, height) - - return this - .rx(new SVGNumber(p.width).divide(2)) - .ry(new SVGNumber(p.height).divide(2)) -} |