Results 1 to 8 of 8

Thread: Draw a line

  1. #1

    Thread Starter
    Fanatic Member Wynd's Avatar
    Join Date
    Dec 2000
    Location
    In a bar frequented by colossal death robots
    Posts
    772

    Draw a line

    Is there any simple function to draw a line from point a to point b?

  2. #2
    Megatron
    Guest
    Code:
    MoveToEx(hDC, x1,y1,NULL);
    LineTo(hDC,x2,y2);

  3. #3
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    If you're using Windows, there's the GDI function Line(). I forget the specifics of the parameters though.
    Harry.

    "From one thing, know ten thousand things."

  4. #4
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    I don't think there is a Line() function although there is LineTo, Polyline, PolylineTo
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  5. #5
    Megatron
    Guest
    You could create your own Line() function with MoveToEx, and LineTo.
    Code:
    void Line(HDC hDC, int x1, int y1, int x2, int y2) 
    {
    MoveToEx(hDC,x1,y1,NULL);
    LineTo(hDC,x2,y2);
    }

  6. #6
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    There isn't?... Umm... oh.... umm... well okay then ... I could have sworn there was. Never mind.
    Harry.

    "From one thing, know ten thousand things."

  7. #7

    Thread Starter
    Fanatic Member Wynd's Avatar
    Join Date
    Dec 2000
    Location
    In a bar frequented by colossal death robots
    Posts
    772
    Ok, thanks. Does this draw the line on the screen, or in the window? I was trying to create a class with some shapes (rectangle, point, segment, etc) and I didn't see any line being drawn.

  8. #8
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    It draws the line on a specified device context, (check out msdn in GDI programming)
    If you want to draw to the window, you pass a device context handle you retrieve with GetDC(hwnd) where hwnd is the window handle
    If you want to draw directly on the screen you pass the handle of GetDC(0)
    If you want to draw lines with doublebuffering you create a memory dc with CreateCompatibleDC and pass that, then update the window with bitblt as needed.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width