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

PostScriptLine

Syntax
int PostScriptLine(struct PostScript *ptr, float ax,float ay,float bx,float by, unsigned int color,float width, struct PostScriptDash *dash, struct PostScriptClip *clip);
Header
base/rps.h
Library
rps
Description

The PostScriptLine function plots a straight line segment.

The argument ptr is a pointer to the PostScript control structure.

The coordinates of the two points that define the line are given by the arguments ax, ay, and bx, by.

The color used to plot the line is given by the color which is a 24-bit number that represents the alpha,red,green and blue components of the color as 8-bit numbers. The alpha channel occupies the most significant bits and the blue channel occupies the least significant bits.

The width of the line is controlled using the argument width, a value of zero will plot a hairline. The dot-dash pattern is given by dash. If this is set to a NULL pointer, a solid line is plotted.

The clipping polygon is given by the argument clip. If this is set to a NULL pointer, no clipping is performed.

Returns
Returns zero on success. On error, (-1) is returned.
Errors
On error, (-1) is returned.
Example
PostScriptLine
Source Code: PostScriptLine.c

/* PostScriptLine
   ==============
   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;

  float wdt=400,hgt=400;
  float xoff=50,yoff=50;

  unsigned int fgcol=0xff000000;
  int x;

  ps=PostScriptMake();
  PostScriptSetText(ps,stream,stdout);  
  PostScriptMakeDocument(ps,xoff,yoff,wdt,hgt,0);
  PostScriptMakePlot(ps);


  for (x=0;x<wdt;x+=10) {
    PostScriptLine(ps,x,0,0,hgt-x,
              fgcol,1.0,NULL,NULL);
  }


  PostScriptEndPlot(ps);
  PostScriptEndDocument(ps);
  return 0;
}