Re: [LIBART] more on clipping



>>>>> "Federico" == Federico Mena Quintero <federico ximian com> writes:

    Federico> I haven't tested this, but try reversing the order of
    Federico> your arc vpath's points.  Libart expects paths to be in
    Federico> counterclockwise order.

Hey, that got my hopes up but it was a nogo.  I also noticed that I
started my arc path with a lineto which I thought would have explained
the problem.  But the attached, modified code still has the artifact

If you have any more thoughts, please let me know.

Thanks for the help,
JDH

//gcc -I/usr/include/libart-2.0/ libart_clip3.c -lart_lgpl_2

#include <stdio.h>
#include <libart_lgpl/art_svp_vpath.h>
#include <libart_lgpl/art_svp_ops.h>
#include <libart_lgpl/art_svp_vpath_stroke.h>
#include <libart_lgpl/art_render_svp.h>
#include <libart_lgpl/art_svp_intersect.h>

#define BYTES_PP 3

static void
output_svp_ppm (const ArtSVP *svp, int color)
{
  art_u8 buf[100 * 100 * 3];
  art_rgb_svp_aa (svp, 0, 0, 100, 100, color, 0x000080, 
		  buf, 100 * 3, NULL);
  printf ("P6\n100 100\n255\n");
  fwrite (buf, 1, 100 * 100 * 3, stdout);
}

static void
print_svp (ArtSVP *vp)
{
  int i, j;

  for (i = 0; i < vp->n_segs; i++)
    {
      printf ("segment %d, dir = %s (%f, %f) - (%f, %f)\n",
	      i, vp->segs[i].dir ? "down" : "up",
	      vp->segs[i].bbox.x0,
	      vp->segs[i].bbox.y0,
	      vp->segs[i].bbox.x1,
	      vp->segs[i].bbox.y1);
      for (j = 0; j < vp->segs[i].n_points; j++)
        printf ("  (%g, %g)\n",
                vp->segs[i].points[j].x,
                vp->segs[i].points[j].y);
    }
}

int
main (int argc, char **argv)
{

  ArtVpath vpath1[] = {  // a square
    { ART_MOVETO, 20, 10 },
    { ART_LINETO, 20, 50 },
    { ART_LINETO, 70, 50 },
    { ART_LINETO, 70, 10 },
    { ART_LINETO, 70, 10 },
    { ART_END, 0, 0}
  };


  ArtVpath vpath2[] = {
    { ART_MOVETO, 40, 70},
    { ART_LINETO, 42, 69},
    { ART_LINETO, 45, 68},
    { ART_LINETO, 48, 67},
    { ART_LINETO, 50, 65},
    { ART_LINETO, 53, 62},
    { ART_LINETO, 55, 59},
    { ART_LINETO, 56, 56},
    { ART_LINETO, 58, 52},
    { ART_LINETO, 59, 48},
    { ART_LINETO, 59, 44},
    { ART_LINETO, 60, 40},
    { ART_LINETO, 59, 35},
    { ART_LINETO, 59, 31},
    { ART_LINETO, 58, 27},
    { ART_LINETO, 56, 23},
    { ART_LINETO, 55, 20},
    { ART_LINETO, 53, 17},
    { ART_LINETO, 50, 14},
    { ART_LINETO, 48, 12},
    { ART_LINETO, 45, 11},
    { ART_LINETO, 42, 10},
    { ART_LINETO, 40, 10},
    { ART_END, 0, 0}
  };
  ArtSVP *svp1, *svp2, *svp3;

  svp1 = art_svp_from_vpath (vpath1);
  //svp2 = art_svp_from_vpath (vpath2);			      

  svp2 = art_svp_vpath_stroke (vpath2,
			       ART_PATH_STROKE_JOIN_MITER,
			       ART_PATH_STROKE_CAP_BUTT,
			        5,
			       4,
			       0.5);



  svp3 = art_svp_intersect(svp1, svp2);  


  //print_svp(svp3);
  output_svp_ppm (svp3, 0x00ee80);
}






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