c# - Cuál es la diferencia entre System.Drawing.Point y System.Drawing.PointF
winforms (3)
Cuál es la diferencia entre System.Drawing.Point y System.Drawing.PointF . ¿Puedes dar un ejemplo entre estos dos?
Gracias por adelantado.
Creo que PointF existe en parte porque la clase System.Drawing.Graphics admite la transformación y el anti-aliasing. Por ejemplo, puede dibujar una línea entre pixelx discreto en modo anti-aliasing.
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)); ;
}
y se verá como
sin PointF esas funcionalidades serán limitadas.
Por ejemplo, en algunos sistemas integrados, solo es compatible con "System.Drawing.Point", debe crear el tipo "PointF" usted mismo.
Point usa coordenadas enteras ( int para X e Y ).
PointF usa puntos flotantes ( float para X e Y ).