开发者

get non-rotated rectangle just big enough to enclose rotated rectangle

I have a Rectangle drawn on a Canvas and it is rotated (any degree) and I'd like to get a non-rotated outer rectangle just big enough to enclose the rotated rectangle. how can I go about doing this?开发者_如何学运维 PS: I do have the RotateTransform that was used to rotate the inner rectangle in the first place.


Compute the min/max of the x/y values of all the corners transformed. There is a built in functionality for this in WPF:

GeneralTransform transform = yourRect.TransformToVisual(yourCanvas);
Rect bounds = transform.TransformBounds(new Rect(0,0, yourRect.ActualWidth, yourRect.ActualHeight));


Compute the four corners and from them derive min/max-X/Y.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜