Re: [LIBART] clipping



>>>>> "Bruce" == Bruce Q Hammond <bruceq hammondranch com> writes:

    Bruce> Well libart has to be able to do rectangular clips, because
    Bruce> otherwise libart would write off the top/bottom of the
    Bruce> pixel buf (corrupting memory) or off the left/right which
    Bruce> would wrap around to the prev/next raster line destroying
    Bruce> the image.  What is doesn't have to do is make it
    Bruce> convenient. :-)

I've been experimenting with art_svp_intersect and am not getting the
results I expect.  I have a rectangle (clip path) and an open arc.
When rendered, the arc starts inside the rectangle and extends outside
it.  I want to clip the arc to inside the rectangle.  Here is a link
to the unclipped image

  http://nitace.bsd.uchicago.edu:8080/files/share/noclip.png

and it's the blue grey arc in the yellow rectangle that I am trying to
clip to the rectangle.

When I use art_svp_intersect(arc, rect), I get zero segments in the
intersection.  I wonder if this is a winding number problem, and if
someone can advise me on how to proceed.

  http://nitace.bsd.uchicago.edu:8080/files/share/intersect.png

I copied the print_svp code from testart.c.  Perhaps a veteran can
tell me why the intersection of these 2 paths is zeros

Here is the code and the output of print_svp

    svpSelf     = art_svp_from_vpath(self->vpath);
    svpClipPath = art_svp_from_vpath(clippath->vpath);
    svpClipped  = art_svp_intersect(svpSelf, svpClipPath );

    printf("Self\n");         // the arc
    print_svp(svpSelf);

    printf("ClipPath\n");     // the rectangle
    print_svp(svpClipPath);

    printf("Clipped\n");      // the intersection
    print_svp(svpClipped);

    N = svpClipped->n_segs;
    printf("N=%d\n", N);       

And now the output....
Self
segment 0, dir = up (40.000000, 10.000000) - (60.000000, 70.000000)
  (40, 10)
  (42.8463, 10.3054)
  (45.6347, 11.2152)
  (48.3083, 12.711)
  (50.8128, 14.7624)
  (53.0972, 17.3275)
  (55.115, 20.3542)
  (56.8251, 23.7808)
  (58.1926, 27.5375)
  (59.1899, 31.548)
  (59.7964, 35.7306)
  (60, 40)
  (59.7964, 44.2694)
  (59.1899, 48.452)
  (58.1926, 52.4625)
  (56.8251, 56.2192)
  (55.115, 59.6458)
  (53.0972, 62.6725)
  (50.8128, 65.2376)
  (48.3083, 67.289)
  (45.6347, 68.7848)
  (42.8463, 69.6946)
  (40, 70)
ClipPath
segment 0, dir = up (20.000000, 10.000000) - (70.000000, 50.000000)
  (20, 10)
  (20, 50)
  (70, 50)
segment 1, dir = down (20.000000, 10.000000) - (70.000000, 50.000000)
  (20, 10)
  (70, 10)
  (70, 50)
Clipped
N=0

Interestingly, when I do the union, I get only the part of the arc
outside the rectangle, and the arc path outside the rect is closed

  http://nitace.bsd.uchicago.edu:8080/files/share/union.png

That's one reason why I wonder if it's a winding number problem.

Thanks for any advice!
John Hunter



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