aboutsummaryrefslogtreecommitdiffstats
path: root/src/elements/Path.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/elements/Path.js')
-rw-r--r--src/elements/Path.js36
1 files changed, 21 insertions, 15 deletions
diff --git a/src/elements/Path.js b/src/elements/Path.js
index 2aa0a51..ec9a19f 100644
--- a/src/elements/Path.js
+++ b/src/elements/Path.js
@@ -6,59 +6,65 @@ import Shape from './Shape.js'
export default class Path extends Shape {
// Initialize node
- constructor (node, attrs = node) {
+ constructor(node, attrs = node) {
super(nodeOrNew('path', node), attrs)
}
// Get array
- array () {
+ array() {
return this._array || (this._array = new PathArray(this.attr('d')))
}
// Clear array cache
- clear () {
+ clear() {
delete this._array
return this
}
// Set height of element
- height (height) {
- return height == null ? this.bbox().height : this.size(this.bbox().width, height)
+ height(height) {
+ return height == null
+ ? this.bbox().height
+ : this.size(this.bbox().width, height)
}
// Move by left top corner
- move (x, y) {
+ move(x, y) {
return this.attr('d', this.array().move(x, y))
}
// Plot new path
- plot (d) {
- return (d == null)
+ plot(d) {
+ return d == null
? this.array()
- : this.clear().attr('d', typeof d === 'string' ? d : (this._array = new PathArray(d)))
+ : this.clear().attr(
+ 'd',
+ typeof d === 'string' ? d : (this._array = new PathArray(d))
+ )
}
// Set element size to given width and height
- size (width, height) {
+ size(width, height) {
const p = proportionalSize(this, width, height)
return this.attr('d', this.array().size(p.width, p.height))
}
// Set width of element
- width (width) {
- return width == null ? this.bbox().width : this.size(width, this.bbox().height)
+ width(width) {
+ return width == null
+ ? this.bbox().width
+ : this.size(width, this.bbox().height)
}
// Move by left top corner over x-axis
- x (x) {
+ x(x) {
return x == null ? this.bbox().x : this.move(x, this.bbox().y)
}
// Move by left top corner over y-axis
- y (y) {
+ y(y) {
return y == null ? this.bbox().y : this.move(this.bbox().x, y)
}
-
}
// Define morphable array