Home| base |src.lib|graphic|ps| PostScriptMakeClip Index

PostScriptMakeClip

Syntax
struct PostScriptClip *PostScriptMakeClip(float x,float y,float wdt, float hgt, int num,float *px, float *py,int *t);
Header
base/rps.h
Library
rps
Description

The PostScriptMakeClip function creates a clipping polygon.

The arguments x and y are applied as an offset to each vertex in the clipping polygon. The polygon is expected to lie with the rectangle whose size is given by the arguments wdt and hgt.

The number of vertices of the clipping polygon is given by the argument num. The arrays containing the X and Y coordinates of each vertex are pointed to by the arguments px and y.

A polygon can be constructed from straight line segments or bezier curves. The array pointed to by the argument t determines what kind of line segment is used to join to a vertex. If the corresponding entry in the array equals zero, then the segment between the current point and the next point is a straight line; if the entry is (1) then the connecting segment is a bezier curve and the next two vertices are the control points, the curve connects to the third point.

Returns
Returns a pointer to the structure containing the clipping polygon on success. On error, a NULL pointer is returned.
Errors
On error, a NULL pointer is returned.
Example
PostScriptMakeClip
Source Code: PostScriptMakeClip.c

/* PostScriptMakeClip
   ==================
   Author: R.J.Barnes
 Copyright (c) 2012 The Johns Hopkins University/Applied Physics Laboratory

This file is part of the Radar Software Toolkit (RST).

RST is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.

Modifications:




#include <stdio.h>
#include <stdlib.h>
#include "rfbuffer.h"
#include "rps.h"

int stream(char *buf,int sze,void *data) {
  FILE *fp;
  fp=(FILE *) data;
  fwrite(buf,sze,1,stdout);
  return 0;
} 


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=0xffff0000;

  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);   
  PostScriptMakeDocument(ps,xoff,yoff,wdt,hgt,0);
  PostScriptMakePlot(ps);

  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);
  PostScriptEndDocument(ps);
  return 0;
}