Draw rotated rectangle

自闭症网瘾萝莉.ら 提交于 2020-01-02 18:04:07

问题


I'm new to C# and .net, just trying to work out how to do something that I thought would be relatively simple. I'm creating a bitmap to be later saved as an image to disk, part of it I want to draw a rectangle shape. I can do this, however I'm looking for a simple way to do this on an angle. I need to be able to specify an angle to draw the rectangle at, I also need to be able to to specify the rotation point (I need to rotate around the top left hand point of the rectangle).

How is this usually achieved with c#/.net, is there something built in for this sort of thing that I haven't found ?


回答1:


The Graphics class supports setting transforms that will let you scale, shear, rotate, etc. See Coordinate Systems and Transformations.

You can find an example at Using a matrix to rotate rectangles individually.



来源:https://stackoverflow.com/questions/18402311/draw-rotated-rectangle

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!