Line drawing algorithm

  • Thread starter Thread starter rakesh.Mysore
  • Start date Start date
R

rakesh.Mysore

Can any one please suggest me a algorithm to draw horizontal and
vertical line between two points (a right angled line, not a slant
line).
 
For now it looks like to me you would just want to draw from x1,y1 to x2,y1
and then to x2,y2 ? If not that simple, please elaborate a bit about what
you are trying to do....
 
Hello Patrice,

thanks for reply.

i need to draw Stepped line between two points (x1,y1) and (x2,y2) with
x1 not equal to x2, (i don't want to draw slant line). (as links drawn
between blocks in many graphical editor).
 
Ok so the basic response should be a start i.e. the principle I mentionned
will draw an horizontal line from the first point to the x coordinate and
then a vertical line to the second point.

Then you can ehance this a bit depending on what you are after (for example,
the start or destination point could be moved by the user as long as it is
inside the shape, or you could let the user move the corner point, or add
adtional points etc.. but basically the idea is just to move from one point
ot the next by changing one of the coordinates so that you draw only
vertical or horizontal lines...
 
Back
Top