Add API for points to draw code class

This commit is contained in:
Steve Ruiz 2021-06-27 20:50:11 +01:00
parent 9f16f886ea
commit 6ef197e30a
2 changed files with 58 additions and 0 deletions

View file

@ -3156,6 +3156,35 @@ interface ShapeUtility<K extends Shape> {
},
})
}
/**
* Add a point to the draw shape's points.
*
* \`\`\`ts
* shape.addPoint([100,100])
* \`\`\`
*/
addPoint(point: number[]): CodeShape<DrawShape> {
this.utils.setProperty(this.shape, 'points', [...this.points, point])
return this
}
/**
* The draw shape's points.
*
* \`\`\`ts
* const shapePoints = shape.points
*
* shape.points = [[0,0], [100,100], [100,200]]
* \`\`\`
*/
get points(): number[][] {
return this.shape.points
}
set points(points: number[][]) {
this.utils.setProperty(this.shape, 'points', points)
}
}

View file

@ -28,4 +28,33 @@ export default class Draw extends CodeShape<DrawShape> {
},
})
}
/**
* Add a point to the draw shape's points.
*
* ```ts
* shape.addPoint([100,100])
* ```
*/
addPoint(point: number[]): CodeShape<DrawShape> {
this.utils.setProperty(this.shape, 'points', [...this.points, point])
return this
}
/**
* The draw shape's points.
*
* ```ts
* const shapePoints = shape.points
*
* shape.points = [[0,0], [100,100], [100,200]]
* ```
*/
get points(): number[][] {
return this.shape.points
}
set points(points: number[][]) {
this.utils.setProperty(this.shape, 'points', points)
}
}