Search code examples
c#geometrydrawellipse

Float parameters instead of int for new Rectangle() c#?


Is it possible to use as parameters float instead of int for the Rectangle class in c#?! Or any way in which I can do this by creating maybe a new class similar to Rectangle that takes as parameters float?

I am trying to use this within the e.Graphics.DrawEllipse.

Example :

e.Graphics.DrawEllipse(new Pen(Brushes.Black, stroke), new Rectangle(10,20,30,40);

Instead of 10,20,30,40 I would like to use floats.

Any help appreciated. Thanks.


Solution

  • There is the RectangleF class in System.Drawing which takes single-precision floating point numbers as parameters:

    http://msdn.microsoft.com/EN-US/library/kwafa1d7(v=VS.110,d=hv.2).aspx