C Board  

Go Back   C Board > General Programming Boards > C# Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 03-14-2008, 03:24 PM   #1
Registered User
 
Join Date: Sep 2007
Posts: 119
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?
John_L is offline   Reply With Quote
Old 03-15-2008, 05:39 AM   #2
Registered User
 
Join Date: Nov 2007
Posts: 14
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
Rainbowinblack is offline   Reply With Quote
Old 03-15-2008, 08:48 AM   #3
Dr Dipshi++
 
mike_g's Avatar
 
Join Date: Oct 2006
Location: On me hyperplane
Posts: 1,219
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

Last edited by mike_g; 03-15-2008 at 08:51 AM.
mike_g is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Drawing HBITMAP into CWnd, Acquired from "screenshot" DeusAduro Windows Programming 6 07-02-2009 03:41 PM
Slow drawing code tjpanda Windows Programming 5 05-09-2008 05:09 PM
How to do double buffing with win32 drawing? Josh Kasten Windows Programming 2 03-27-2004 12:02 AM
Need help drawing triangles (C) Belvedeer84 C Programming 6 10-02-2003 02:00 PM
Drawing triangles TonyLFL C++ Programming 7 06-02-2002 09:51 AM


All times are GMT -6. The time now is 10:43 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22