Hi,

I'm trying to draw circle and oval by myself without using ".addEllipse"
Can I draw it by pointer? which mean i point 4 point and then make it to become the shape of circle and oval.
I tried to find solution in the net, but i dont seems to get any solution.

Any Idea?

Do you want to implement the Circle, or Line Drawing Algorithm instead of using Graphics.DrawLine(), DrawEllipse () Method?

Or

You want to make application like paint ? rubberband elastic Drawing?

Actually, I created other shape such as trapezium, parallelogram, by using the addlines.

I created them by having a middle point of the shape start from (x,y) - (100,100)

but when i straight use the build in function to draw ellipse, i can't find any ways to set the mid point of the ellipse start from (100,100)

I do that is because when the user need to change from one shape to another, the position of it wont be changing because all of the shape started from 100,100

Any idea of drawing my own ellipse so that i can start from position 100,100 ??
Any help would be very appreciated

Hi, You can perform the Transformation on your Points(By just adding or subtracting (100, 100) to each points). GDI+ uses (0,0) is the Mid point. But it provides Matrix class to Transform the Coordinate System.

Example to Transform the Coordinate System

private void Form1_Paint(object sender, PaintEventArgs e)
{
    Graphics g = e.Graphics;
    Rectangle rect = new Rectangle (0,0,100,100);
    Matrix matrix = new Matrix();
    
    g.DrawEllipse(Pens.Blue, rect);
    matrix.Translate(100, 100);
    g.Transform = matrix;
    g.DrawEllipse(Pens.Green, rect);
}

Here first Circle will be drawn Blue color and (0,0) as the starting point
Second circle will use the Transformation and (100,100) as the starting Point

I think this may helpful to you

Comments
Great !!
This article has been dead for over six months. Start a new discussion instead.