在这里,我使用Konvajs库绘制了一些弧线,但是在绘制对象后我无法获得它们的宽度和高度,我该怎么做?快速阅读代码:
function drawSurface(idnumber, radius, x, y, startAngleParam, endAngleParam) {
var borderbold = 5;
var surface;
if (typeof startAngleParam !== 'undefined') {
surface = new Konva.Shape({
x: x,
y: y,
fill: '#ccc',
stroke: "#ccc",
strokeWidth: 8,
id: idnumber,
opacity: 1,
drawFunc: function (context) {
var startAngle = startAngleParam * Math.PI;
var endAngle = (startAngleParam + 0.5 + endAngleParam) * Math.PI;
var counterClockwise = false;
context.beginPath();
context.arc(0, 0, radius, startAngle, endAngle, counterClockwise);
context.setAttr("lineWidth", borderbold);
context.stroke();
context.fillStrokeShape(this);
}
});
}
else {
surface = new Konva.Circle({
x: x,
y: y,
radius: radius,
fill: '#ccc',
strokeWidth: 3,
id: idnumber,
opacity: 1
});
}
return surface;
}
请用代码示例支持您的答案。