creating 90 degree perpendicular lines

topic posted Fri, July 21, 2006 - 2:15 PM by  cpr
Share/Save/Bookmark
Advertisement
this is not c++ specific, and I am working in c to implement it, but, I am starting to work on gradient fill routines, and for the linear version I need to draw lines perpendicular to the fill path. so, given a line from x1,y1 to x2,y2, how to I calculate end points for all of the perpendicular lines (one per pixel along my fill path)? any takers? hehe.. :)
posted by:
cpr
offline cpr
SF Bay Area
Advertisement
Advertisement
  • Re: creating 90 degree perpendicular lines

    Fri, July 21, 2006 - 6:20 PM
    Have you considered using a scan line approach instead of drawing a bunch of perpendicular lines?

    • Re: creating 90 degree perpendicular lines

      Sat, July 22, 2006 - 11:39 PM
      That could be done but the gradient wouldn't follow the edge of the triangle in that case without doing a spatial calculation on its distance from the vertices. I'm guessing he just wanted to interpolate between two RGB values following a straight path.
    • Re: creating 90 degree perpendicular lines

      Mon, July 24, 2006 - 2:57 PM
      actually, I haven't considered any different approaches.. :) Graphics is not my area of specialily, but I will be implementing some gradient fill routines in the near future. So, I guess my real question could have been asking for advice in implementing gradient fills, both linear and circular.. my first idea for the non-circular fill was to draw the perpendicular lines all along the fill path.. I've written some code which calculates the colors for each line of the fill, but I don't know how to generate the co-ordinates for the series of lines to draw.. google searches have not provided me with much, except for some great stuff from Chris Lomont regarding circular gradient fills..

      anyways, if anyone wants to point me to some other good sources regarding linear fills, etc, that would be great..

      peace
      -cpr