int main(int argc,char *argv[]) { struct PostScript *ps=NULL; struct PostScriptClip *clip=NULL; float wdt=400,hgt=400; float xoff=50,yoff=50; unsigned int fgcol=0xff000000; float x[4]={0,200,400,200}; float y[4]={200,0,200,400}; int t[4]={0,0,0,0}; ps=PostScriptMake(); PostScriptSetText(ps,stream,stdout); PostScriptMakePlot(ps,xoff,yoff,wdt,hgt,0); clip=PostScriptMakeClip(50,50,wdt,hgt,4,x,y,t); PostScriptRectangle(ps,NULL,10,10,wdt-20,hgt-20, 1,fgcol,0,NULL,clip); PostScriptFreeClip(clip); PostScriptEndPlot(ps); return 0; }
int SplotClip(struct Splot *ptr, int num,float *px,float *py,int *t) { int s=0; if (ptr==NULL) return -1; if (ptr->ps.ptr !=NULL) { struct PostScript *ps; ps=ptr->ps.ptr; if (ptr->ps.clip !=NULL) PostScriptFreeClip(ptr->ps.clip); ptr->ps.clip=NULL; if (num==0) return 0; ptr->ps.clip=PostScriptMakeClip(ps->x,ps->y,ps->wdt,ps->hgt,num,px,py,t); if (ptr->ps.clip==NULL) s=-1; } if (ptr->fb.ptr !=NULL) { int *ix=NULL,*iy=NULL; int i; struct FrameBuffer *img; img=*(ptr->fb.ptr); if (img==NULL) return -1; if (ptr->fb.clip !=NULL) FrameBufferFreeClip(ptr->fb.clip); ptr->fb.clip=NULL; if (num==0) return 0; ix=malloc(sizeof(int)*num); if (ix==NULL) return -1; iy=malloc(sizeof(int)*num); if (iy==NULL) { free(ix); return -1; } for (i=0;i<num;i++) { ix[i]=px[i]; iy[i]=py[i]; } ptr->fb.clip=FrameBufferMakeClip(img->wdt,img->hgt,num,ix,iy,t); if (ptr->fb.clip==NULL) s=-1; free(ix); free(iy); } return s; }