Rye*_*Rye 20 c# system.drawing winforms
System.Drawing.Point和之间有什么区别System.Drawing.PointF.你能举两个这样的例子吗?
提前致谢.
Jon*_*eet 29
Point使用整数坐标(intfor X和Y).
PointF使用浮点(floatfor X和Y).
tia*_*tia 22
我认为PointF存在的部分原因是System.Drawing.Graphics类支持转换和抗锯齿.例如,您可以在抗锯齿模式下在离散像素x之间绘制一条线.
private void Form1_Paint(object sender, PaintEventArgs e)
{
e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
Pen pen = Pens.Red;
// draw two vertical line
e.Graphics.DrawLine(pen, new Point(100, 100), new Point(100, 200));
e.Graphics.DrawLine(pen, new Point(103, 100), new Point(103, 200));
// draw a line exactly in the middle of those two lines
e.Graphics.DrawLine(pen, new PointF(101.5f, 200.0f), new PointF(101.5f, 300.0f)); ;
}
Run Code Online (Sandbox Code Playgroud)
它看起来像

没有PointF这些功能将是有限的.