1.旋转矩形
我参考了这篇 文章 里xuzuning的方法,写一个旋转矩形的方法。
旋转矩形代码:
private void Rect2Pointfs(Rectangle rect, float angle, out PointF[] lpfs)
{
using (var graph = new GraphicsPath())
{
Point Center = new Point(rect.X + rect.Width / 2, rect.Y + rect.Height / 2);
graph.AddRectangle(rect);
var a = -angle * (Math.PI / 180);
var n1 = (float)Math.Cos(a);
var n2 = (float)Math.Sin(a);
var n3 = -(float)Math.Sin(a);
var n4 = (float)Math.Cos(a);
var n5 = (float)(Center.X * (1 - Math.Cos(a)) + Center.Y * Math.Sin(a));
var n6 = (float)(Center.Y * (1 - Math.Cos(a))