GDI+ Point size
1,point 和size可以互相转换,如:
View Code
Point p = new Point(300, 300);
p.Offset(12,14);
Size s = new Size(12, 12);
p = (Point)s; //size转换为point
s = (Size)p; //point转换为size
p.Offset(12,14);
Size s = new Size(12, 12);
p = (Point)s; //size转换为point
s = (Size)p; //point转换为size
2.两个矩形的交集
Graphics g = e.Graphics;
g.Clear(Color.White); Rectangle rr = new Rectangle(55,55,100,100);
Rectangle r2 = new Rectangle(5,5,60,120);
Rectangle r3 = Rectangle.Intersect(rr,r2);
g.FillRectangle(Brushes.Blue, rr);
g.FillRectangle(Brushes.Black,r2);
g.FillRectangle(Brushes.DeepPink, r3);
Rectangle r2 = new Rectangle(5,5,60,120);
Rectangle r3 = Rectangle.Intersect(rr,r2);
g.FillRectangle(Brushes.Blue, rr);
g.FillRectangle(Brushes.Black,r2);
g.FillRectangle(Brushes.DeepPink, r3);