1
0
Fork 0

feat(core): Added new utility methods for attrs

This commit is contained in:
joostdecock 2022-07-23 14:52:56 +02:00
parent 21434ed2f6
commit 50b37f4cb5
3 changed files with 39 additions and 0 deletions

View file

@ -359,4 +359,20 @@ Part.prototype.generateTransform = function(transforms) {
}
}
/** Chainable way to set the grain property */
Part.prototype.setGrain = function (grain = 90) {
this.attributes.set('data-grain', grain)
return this
}
/** Chainable way to set the grain property */
Part.prototype.setCut = function (cut = { count: 2, mirror: true, onFold: false }) {
this.attributes.set('data-cut', cut)
return this
}
export default Part

View file

@ -35,6 +35,13 @@ Path.prototype.setRender = function (render = true) {
return this
}
/** Chainable way to set the class property */
Path.prototype.setClass = function (className = false) {
if (className) this.attributes.set('class', className)
return this
}
/** Adds a move operation to Point to */
Path.prototype.move = function (to) {
if (to instanceof Point !== true)

View file

@ -231,4 +231,20 @@ Point.prototype.translate = function (x, y) {
return p
}
/** Chainable way to set the data-text property (and optional class) */
Point.prototype.setText = function (text = '', className=false) {
this.attributes.set('data-text', text)
if (className) this.attributes.set('data-text-class', className)
return this
}
/** Chainable way to set the data-circle property (and optional class) */
Point.prototype.setCircle = function (radius = false, className=false) {
if (radius) this.attributes.set('data-circle', radius)
if (className) this.attributes.set('data-circle-class', className)
return this
}
export default Point