绘制旋转矩形 [英] Draw rotated rectangle
问题描述
我是新的C#和.NET,只是试图找出如何做一些事情,我认为将是比较简单的。
我创建一个位图后保存为图像到磁盘,它的一部分我想绘制一个矩形形状。
我能做到这一点,但是我正在寻找一种简单的方法来做到这一点的一个角度。我需要能够指定要绘制矩形以一角度,我还需要能够以指定的旋转点(我需要围绕矩形的左上角点旋转)。
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).
这是怎么通常使用C#实现/。NET,有建在这样的事情,我还没有发现的东西吗?
How is this usually achieved with c#/.net, is there something built in for this sort of thing that I haven't found ?
推荐答案
类支持设置转换,让您缩放,剪切,旋转等请参见坐标系统和转换的。
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.
这篇关于绘制旋转矩形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!