Thread: Drawing a triangle with hatch marks?

  1. #1
    Registered User Bajanine's Avatar
    Join Date
    Dec 2001
    Location
    The most peaks over 10,000 feet!
    Posts
    396

    Drawing a triangle with hatch marks?

    So far my draw function draws my 'enclosed sections' circles and rectangles correctly with hatch marks (SolidBrush.lbStyle = BS_HATCHED.

    Now I would like to draw triangles with hatch marks also. I've drawn the tringle with the LineTo function. Since this isn't a predesigned 'enclosed section' but just 3 lines how do I hatch the enclosed area.

    Is there a different function I should be using to draw the triangle instead of LineTo? Last night I tried something like PolyLine but I botched it up so bad that I deleted it.

    Any pointers will be greatly appreciated.

    I have attached my programs output to hopefully help clarify what I am up to!
    Favorite Quote:

    >For that reason someone invented C++.
    BLASPHEMY! Begone from my C board, you foul lover of objects, before the gods of C cast you into the void as punishment for your weakness! There is no penance for saying such things in my presence. You are henceforth excommunicated. Never return to this house, filthy heretic!



  2. #2
    Registered User Bajanine's Avatar
    Join Date
    Dec 2001
    Location
    The most peaks over 10,000 feet!
    Posts
    396
    Uh, lost my attachment somewhere.
    Favorite Quote:

    >For that reason someone invented C++.
    BLASPHEMY! Begone from my C board, you foul lover of objects, before the gods of C cast you into the void as punishment for your weakness! There is no penance for saying such things in my presence. You are henceforth excommunicated. Never return to this house, filthy heretic!



  3. #3
    Registered User Bajanine's Avatar
    Join Date
    Dec 2001
    Location
    The most peaks over 10,000 feet!
    Posts
    396
    I tried my Polyline hypothesis, no such luck it also just draws the outline with the pen (no brush hatch marks). I thought that maybe it would be treated as a "solid" and paint its interior!
    Code:
    	POINT ptA[4] = {
    		0,0,
    		1441,1441,
    		2882,0,
    		0,0};
    	Polyline(hdc, ptA, 4);
    I am sure there is an easy answer to my delima but I am too tired to figure it out. It's 1:40 in the morning and I am starting to zone out!


    Looks like maybe regions are what I need!
    Last edited by Bajanine; 05-17-2003 at 02:03 AM.
    Favorite Quote:

    >For that reason someone invented C++.
    BLASPHEMY! Begone from my C board, you foul lover of objects, before the gods of C cast you into the void as punishment for your weakness! There is no penance for saying such things in my presence. You are henceforth excommunicated. Never return to this house, filthy heretic!



  4. #4
    Registered User Bajanine's Avatar
    Join Date
    Dec 2001
    Location
    The most peaks over 10,000 feet!
    Posts
    396
    I figured it out, you can actually find stuff on MS site once in a while! Here is what I did:
    Code:
    	case 3:	
    //	Polyline(hdc, ptA, 4);
    //	SetPolyFillMode(hdc, WINDING);
    	HRGN hRgn;
    	hRgn = CreatePolygonRgn(ptA, 4, WINDING);
    	FillRgn (hdc, hRgn, hHatchBrush);
    
    	DeleteObject(SelectObject(hdc, hPerimeterBrush));
    	FrameRgn (hdc, hRgn, hPerimeterBrush,1,1);
    	DeleteObject (hRgn);
    
    	break;
    Favorite Quote:

    >For that reason someone invented C++.
    BLASPHEMY! Begone from my C board, you foul lover of objects, before the gods of C cast you into the void as punishment for your weakness! There is no penance for saying such things in my presence. You are henceforth excommunicated. Never return to this house, filthy heretic!



  5. #5
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    Or use a path:

    Code:
    BeginPath(hdc);
    // Draw a triangle
    EndPath(hdc);
    StrokeAndFillPath(hdc);
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Recursive Triangle Function
    By w2look in forum C Programming
    Replies: 14
    Last Post: 11-13-2010, 02:31 PM
  2. Right Triangle Program
    By BSmith4740 in forum C# Programming
    Replies: 9
    Last Post: 02-27-2008, 12:24 AM
  3. Just in case: "Odd" Triangle Challenge (for me)
    By BB18 in forum C Programming
    Replies: 3
    Last Post: 10-09-2004, 12:02 AM
  4. Determining a Triangle using get and pointer
    By naynay in forum C Programming
    Replies: 7
    Last Post: 04-11-2003, 05:55 AM
  5. OpenGL Question...simple (triangle drawing stuff)
    By incognito in forum Game Programming
    Replies: 7
    Last Post: 03-15-2003, 08:47 PM