参考官方文档,画圆是没有问题的。关键代码如下:
onCreateRoot() {
let dragArea = this._tool.circle()
this._tool.plot = (radius, position) => {
this._tool.move(position.x, position.y);
dragArea.radius(radius);
};
onUpdate() {
this._tool.plot(radius, position);
}
我问题是想画个矩形,将上述代码修改成如下:
onCreateRoot() {
let dragArea = this._tool.rect() //这个是查的SVG,画矩形用rect
this._tool.plot = (width,height, position) => {
this._tool.move(position.x, position.y);
dragArea.radius(radius); //现在的问题是这里要写什么?试过 width,height,size,rect都不对,文档也没地儿查
};
onUpdate() {
this._tool.plot(width,height, position);
}