Draw dot by dot?

This is a discussion on Draw dot by dot? within the C# Programming forums, part of the General Programming Boards category; Hi folks, I'm trying to implement Brasenham's algorithm, I need to draw a line on a given coordinates (x1,y1,x2,y2). The ...

  1. #1
    Registered User
    Join Date
    Jan 2006
    Posts
    14

    Draw dot by dot?

    Hi folks,

    I'm trying to implement Brasenham's algorithm, I need to draw a line on a given coordinates (x1,y1,x2,y2). The problem is that when I try to do this in C# (GDI+) I have this function drawLine, but this draws the line itself.

    I need to construct the line myself, point by point (pixel by pixel), can anyone show me on how to draw only one pixel at the time, not connect two point. I will need to draw the line recursively, one pixel at the time so in the end I end up with the complete line.

    advice is welcomed in any language C#, Java, C++ ?

    Thanx in prior

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,855
    There are a huge number of sites which detail the algorithm - just read a few of them.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Jan 2006
    Posts
    14
    I know the algorithms perfectly well, I just have problems implementing it.
    I dont know how to draw a single point so then I can then construct the whole line dot by dot, it is perfectly well described in my thread above.

    can anyone show me on how to draw only one pixel at the time
    I did not ask about algorithms itself, it is rather a simple question.
    Last edited by fiska; 10-11-2006 at 07:39 AM.

  4. #4
    and the Hat of Clumsiness GanglyLamb's Avatar
    Join Date
    Oct 2002
    Location
    between photons and phonons
    Posts
    1,109
    Since this is obviously for learning purposes only , why not just use DrawRectangle ( or something like that ) with a width and height of 1 pixel.

    I know it's not the best solution , but I've looked at msdn Graphics documentation at a glance and didn't see any method to just draw a pixel.

    C#, Java, C++
    >>
    Java: http://forums.java.net/jive/thread.j...ssageID=111831

    Using the windows GDI: http://www.toymaker.info/Games/html/gdi.html
    Last edited by GanglyLamb; 10-11-2006 at 10:43 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Which is the better way to draw?
    By g4j31a5 in forum Game Programming
    Replies: 16
    Last Post: 01-22-2007, 11:56 PM
  2. need help making a dot bounce up and down y axis in this prog
    By redwing26 in forum Game Programming
    Replies: 10
    Last Post: 08-05-2006, 01:48 PM
  3. draw function HELP!!!
    By sunoflight77 in forum C++ Programming
    Replies: 1
    Last Post: 05-11-2005, 12:28 AM
  4. Simple program i cant get (dot moving)
    By Lupusk9 in forum C++ Programming
    Replies: 4
    Last Post: 09-14-2004, 09:04 PM
  5. ray casting
    By lambs4 in forum Game Programming
    Replies: 62
    Last Post: 01-09-2003, 06:57 PM

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