diff options
Diffstat (limited to 'src/modules/core/poly.js')
-rw-r--r-- | src/modules/core/poly.js | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/modules/core/poly.js b/src/modules/core/poly.js index d422028..0640735 100644 --- a/src/modules/core/poly.js +++ b/src/modules/core/poly.js @@ -2,32 +2,33 @@ import { proportionalSize } from '../../utils/utils.js' import PointArray from '../../types/PointArray.js' // Get array -export function array () { +export function array() { return this._array || (this._array = new PointArray(this.attr('points'))) } // Clear array cache -export function clear () { +export function clear() { delete this._array return this } // Move by left top corner -export function move (x, y) { +export function move(x, y) { return this.attr('points', this.array().move(x, y)) } // Plot new path -export function plot (p) { - return (p == null) +export function plot(p) { + return p == null ? this.array() - : this.clear().attr('points', typeof p === 'string' - ? p - : (this._array = new PointArray(p))) + : this.clear().attr( + 'points', + typeof p === 'string' ? p : (this._array = new PointArray(p)) + ) } // Set element size to given width and height -export function size (width, height) { +export function size(width, height) { const p = proportionalSize(this, width, height) return this.attr('points', this.array().size(p.width, p.height)) } |