📄 psdrawcurve.c
字号:
/* Copyright (c) Colorado School of Mines, 2006.*//* All rights reserved. *//* Copyright (c) Colorado School of Mines, 1998.*//* All rights reserved. *//* PSDRAWCURVE: $Revision: 1.1 $ ; $Date: 1999/02/15 20:35:14 $ *//*********************** self documentation **********************//*****************************************************************************PSDRAWCURVE - Functions to draw a curve from a set of pointspsDrawCurve Draw a curve from a set of points via PostScript******************************************************************************Function Prototypes:void psDrawCurve( float x, float y, float width, float height, float x1Beg, float x1End, float p1Beg, float p1End, float x2Beg, float x2End, float p2Beg, float p2End, float *x1curve, float *x2curve, int ncurve, char *curveColor, float curvewidth, int style);******************************************************************************psDrawCurve:Input:x x coordinate of lower left corner of boxy y coordinate of lower left corner of boxwidth width of boxheight height of boxx1Beg axis value at beginning of axis 1x1End axis value at end of axis 1p1Beg pad value at beginning of axis 1p1End pad value at end of axis 1x2Beg axis value at beginning of axis 2x2End axis value at end of axis 2p2Beg pad value at beginning of axis 2p2End pad value at end of axis 2x1curve vector of x1 coordinates for points along curvex2curve vector of x2 coordinates for points along curvencurve number of points along curvecurveColor color to use for curvecurvewidth width (in points) of curvestyle NORMAL (axis 1 on bottom, axis 2 on left) SEISMIC (axis 1 on left, axis 2 on top)*****************************************************************************Author: Brian Macy, Phillips Petroleum Co., 11/20/98 (Adapted after Dave Hale and other's psAxesBox routine)*****************************************************************************//**************** end self doc ********************************/#include "cwp.h"#include "psplot.h"typedef struct { float x; float y;} LPoint;void psDrawCurve( float x, float y, float width, float height, float x1Beg, float x1End, float p1Beg, float p1End, float x2Beg, float x2End, float p2Beg, float p2End, float *x1curve, float *x2curve, int ncurve, char *curveColor, float curvewidth, int style)/*****************************************************************************Draw a curve from a set of points via PostScript******************************************************************************Input:x x coordinate of lower left corner of boxy y coordinate of lower left corner of boxwidth width of boxheight height of boxx1Beg axis value at beginning of axis 1x1End axis value at end of axis 1p1Beg pad value at beginning of axis 1p1End pad value at end of axis 1x2Beg axis value at beginning of axis 2x2End axis value at end of axis 2p2Beg pad value at beginning of axis 2p2End pad value at end of axis 2x1curve vector of x1 coordinates for points along curvex2curve vector of x2 coordinates for points along curvencurve number of points along curvecurveColor color to use for curvecurvewidth width (in points) of curvestyle NORMAL (axis 1 on bottom, axis 2 on left) SEISMIC (axis 1 on left, axis 2 on top)******************************************************************************Author: Brian Macy, Phillips Petroleum Co., 11/20/98 (Adapted after Dave Hale and other's psAxesBox routine)*****************************************************************************/{ float xbase,ybase,xscale,yscale,size1,size2; float *xcurve,*ycurve; LPoint *lpoints; /* points for drawing line */ int i; /* allocate memory for lpoints */ if ((lpoints=(LPoint *)malloc(ncurve*sizeof(LPoint)))==NULL) { fprintf(stderr,"Cannot allocate memory for lpoints\n"); exit(-1); } /* determine sizes of axes 1 and 2 */ if (style==NORMAL) { size1 = width; size2 = height; } else { size1 = height; size2 = width; } /* save graphics state */ gsave(); /* translate coordinate system, so that origin is at x,y */ translate(x,y); /* if style is not NORMAL, rotate coordinate system */ if (style!=NORMAL) { rotate(-90.0); translate(-height,0.0); } /* start a new path (just to be safe) */ newpath(); /* set up parameters */ setcolor(curveColor); setlinewidth(curvewidth); xscale = size1/(x1End+p1End-x1Beg-p1Beg); xbase = -xscale*(x1Beg+p1Beg); xcurve=x1curve; yscale = size2/(x2End+p2End-x2Beg-p2Beg); ybase = -yscale*(x2Beg+p2Beg); ycurve=x2curve; /* * Draw a curve from input data xcurve,ycurve. Clip * the curve outside the axesbox. */ for (i=0; i<ncurve; ++i) { lpoints[i].x=xbase+xscale*xcurve[i]; lpoints[i].y=ybase+yscale*ycurve[i]; } rectclip(0,0,size1,size2); if (ncurve > 1) { for (i=1; i<ncurve; i++) { moveto(lpoints[i-1].x,lpoints[i-1].y); lineto(lpoints[i].x,lpoints[i].y); } stroke(); } /* restore graphics state */ grestore(); /* free resources before returning */ free(lpoints);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -