[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

arrows when two points are on each other



When there are two (or more) points at the end and there is an arrow
at that end, the arrow is always pointing right. This may be a
non-issue for polylines (just remove the redundant points).
However, for a zig-zag line sometimes this is a need.

So I put this function in lib/arrows.c:

Point *
next_point(Point *points, int rem)
{
  Point *endpoint;
  int dir;

  endpoint = points;      /* the real endpoint */
  dir = rem > 0 ? 1 : -1; /* direction (+ve / -ve) */

  while (rem != 0) {      /* keep in legal range */
    /* compare next point to the end point, and if they are different, */
    /* return the differing point */
    points += dir;
    if (endpoint->x != points->x || endpoint->y != points->y)
      return points;

    /* one less point to use */
    rem -= dir;
  }

  /* no different points were found */
  return points;
}

This function moves forwards or backwards from "points" (according
to "dir") to a point which is not coincident with it. It can move to a
maximum offset "rem" from the original pointer.

I also put the prototype in lib/arrows.h and modified the following lines
in objects/standard/zigzagline.c (diff for 0.88.1).
219c219
<            &points[0], &points[1],
---
 >            &points[0], next_point(&points[0], n-1),
226c226
<            &points[n-1], &points[n-2],
---
 >            &points[n-1], next_point(&points[n-1], 1-n),

I did something similar to objects/standard/polyline.c.

Sorry if I am posting this to the wrong list, I don't know how these
lists work very well.

Thanks
Trevor Spiteri






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index] Mail converted by Mofo Magic and the Flying D

 
All trademarks and copyrights are the property of their respective owners.

Other Directory Sites: SeekWonder | Directory Owners Forum

GuideSMACK