954,514 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

creating shape like circle or oval(i wanted to design my own circle shape)

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?

karhong
Newbie Poster
14 posts since Aug 2006
Reputation Points: 10
Solved Threads: 0
 

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?

selvaganapathy
Posting Pro
547 posts since Feb 2008
Reputation Points: 44
Solved Threads: 100
 

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

karhong
Newbie Poster
14 posts since Aug 2006
Reputation Points: 10
Solved Threads: 0
 

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

selvaganapathy
Posting Pro
547 posts since Feb 2008
Reputation Points: 44
Solved Threads: 100
 

Thanks alot !!
it works out fine !!
Appreciate it !!

karhong
Newbie Poster
14 posts since Aug 2006
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You