简体   繁体   中英

How to get the actual width of a rotated canvas rectangle

I'm using konva js to make a transformable rectangle . I'm able to access the width of the rectangle using rect1.getClientRect().height . However, when I rotate the rectangle, the width property is changing. I believe width property gives the overall horizontal length of the container of the rectangle canvas. Is there any way I can get the actual width of the rotated rectangle. Here's the jsfiddle

The Konva-object has an attrs attribute: rect1.attrs.width * rect1.attrs.scaleX

https://jsfiddle.net/8gack34s/4/

there is also attrs.rotation that you can use to calculate it mathematically.

Konva warning: Konva.Transformer is currently experimental and may have bugs. Please report any issues to GitHub repo.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM