-
Drawing triangles in C#
So I whipped up the gesture based drawing stuff myself. But what's the best way to go about drawing Triangles in C#? If I record mouse movements and store the coordinates, I guess I need to draw three lines? But than how do I fill them in with colour? I'll probably write a "triangle" class. But any suggestions or ideas?
-
You can use Graphics.DrawPoligon and Graphics.FillPoligon
both Method gets an array of Points , if there are 3 points - it'll make a triangles
can you send me the code for the gesture based drawing "stuff"?
i'm trying for a week or so to make something like that ...but i cant find how to redraw the forms...
Thanks
-
If theres a built in method it will be easiest to use that. If you want to code your own filled triangle heres some very rough pseudo code for it. Having your own line drawing algo may help too.
Code:
order points from highest to lowest
get xa decrement for each y iteraion
get xb increment for each y iteration
for(y = highest; y > mid; y--)
{
line(xa, y, xb, y);
xa-= xa_inc;
xb+= xb_inc;
}
repeat for mid to base