Ejemplo n.º 1
0
/*==================================================================================
 pselip - generates an ellipse
	if dx or dy = 0, then they are set to minimum values in device space
 ==================================================================================*/
void pselip_ (double *xor, double *yor, double *dx, double *dy, double *rline, double *width, int *ifill) {
	double devX = deviceX(*xor);
	double devY = deviceY(*yor);
	double devW = deviceW(*dx);
	double devH = deviceH(*dy);
	
	DEBUGPRINT(("In pselip.  Origin: (%f, %f), Size: (%f, %f), DevOrigin: (%f, %f), DevSize: (%f, %f).\n", 
				*xor, *yor, *dx, *dy, devX, devY, devW, devH));
	completeRelativeOperation();
	cairo_new_path(dmh_cr);
	cairo_save (dmh_cr);
	
	if (devW == 0 || devH == 0) {
		devW = MINCIRCLESIZE;
		devH = MINCIRCLESIZE;
	}

	cairo_translate (dmh_cr, devX + devW/ 2., devY + devH / 2.);
	cairo_scale (dmh_cr, devW / 2., devH / 2.);
	cairo_arc (dmh_cr, 0., 0., 1., 0., 2 * M_PI);
	cairo_restore (dmh_cr);
	
	setLineProperties((int) *rline, *width);
	cairo_set_source_rgb (dmh_cr, 0, 0, 0);	/* black */
	cairo_stroke_preserve(dmh_cr);
	setFillType (*ifill);
	cairo_fill(dmh_cr);
}
Ejemplo n.º 2
0
/*==================================================================================
 psbspl - subroutine to generate open bsplines
	We receive only the vertices from perplex, so we must figure out good control
	points to use for the spline.
 ==================================================================================*/
void psbspl_ (double *x, double *y, int *npts, double *rline, double *width, int *ifill) {
	int i, N;
	double ctrl1_x, ctrl1_y, ctrl2_x, ctrl2_y;
	
	N = *npts;
	
	DEBUGPRINT(("In psbspl. With %i points, rline=%f, wdith=%f, fill=%i.\n", N, *rline, *width, *ifill));
	completeRelativeOperation();

	if (dmh_inRotatedTransform) {
		cairo_set_matrix(dmh_cr, &dmh_unrotatedMatrix);	/* remove rotation */
		dmh_inRotatedTransform = 0;
		DEBUGPRINT(("Removing rotation.\n"));
	}

	if (N >= 4) {
		cairo_move_to(dmh_cr, deviceX(x[0]), deviceY(y[0]));
		getControlPoints(deviceX(x[0]), deviceY(y[0]), deviceX(x[0]), deviceY(y[0]), 
						 deviceX(x[1]), deviceY(y[1]), deviceX(x[2]), deviceY(y[2]), 
						 &ctrl1_x, &ctrl1_y, &ctrl2_x, &ctrl2_y);
		cairo_curve_to(dmh_cr, ctrl1_x, ctrl1_y, ctrl2_x, ctrl2_y, deviceX(x[1]), deviceY(y[1]));
//		cairo_line_to(dmh_cr, deviceX(x[1]), deviceY(y[1]));
		for (i=1; i <= N-3; i++) {
			getControlPoints(deviceX(x[i-1]), deviceY(y[i-1]), deviceX(x[i]), deviceY(y[i]), 
							 deviceX(x[i+1]), deviceY(y[i+1]), deviceX(x[i+2]), deviceY(y[i+2]), 
							 &ctrl1_x, &ctrl1_y, &ctrl2_x, &ctrl2_y);
			cairo_curve_to(dmh_cr, ctrl1_x, ctrl1_y, ctrl2_x, ctrl2_y, deviceX(x[i+1]), deviceY(y[i+1]));
		}
		
		/* We've now drawn all the way to N-2.  We need to draw through N-1.
			We can get one more control point by working backwards from the end: */
		getControlPoints(deviceX(x[N-3]), deviceY(y[N-3]), deviceX(x[N-2]), deviceY(y[N-2]), 
						 deviceX(x[N-1]), deviceY(y[N-1]), deviceX(x[N-1]), deviceY(y[N-1]), 
						 &ctrl1_x, &ctrl1_y, &ctrl2_x, &ctrl2_y);
		cairo_curve_to(dmh_cr, ctrl1_x, ctrl1_y, ctrl2_x, ctrl2_y, deviceX(x[N-1]), deviceY(y[N-1]));
//		cairo_line_to(dmh_cr, deviceX(x[N-1]), deviceY(y[N-1]));
	} else if (N == 3) {
		/* for three points, we'll pretend for the purposes of control point calculation that
		 it's a closed loop */
		cairo_move_to(dmh_cr, deviceX(x[0]), deviceY(y[0]));
		getControlPoints(deviceX(x[2]), deviceY(y[2]), deviceX(x[0]), deviceY(y[0]), 
						 deviceX(x[1]), deviceY(y[1]), deviceX(x[2]), deviceY(y[2]), 
						 &ctrl1_x, &ctrl1_y, &ctrl2_x, &ctrl2_y);
		cairo_curve_to(dmh_cr, ctrl1_x, ctrl1_y, ctrl2_x, ctrl2_y, deviceX(x[1]), deviceY(y[1]));
		getControlPoints(deviceX(x[0]), deviceY(y[0]), deviceX(x[1]), deviceY(y[1]), 
						 deviceX(x[2]), deviceY(y[2]), deviceX(x[0]), deviceY(y[0]), 
						 &ctrl1_x, &ctrl1_y, &ctrl2_x, &ctrl2_y);
		cairo_curve_to(dmh_cr, ctrl1_x, ctrl1_y, ctrl2_x, ctrl2_y, deviceX(x[2]), deviceY(y[2]));
	} else if (N == 2) {
		/* for two points, it's a line segment.  Duh. */
		cairo_move_to(dmh_cr, deviceX(x[0]), deviceY(y[0]));
		cairo_line_to(dmh_cr, deviceX(x[1]), deviceY(y[1]));
	}
	setLineProperties((int) *rline, *width);
	cairo_set_source_rgb (dmh_cr, 0, 0, 0);	/* black */
	cairo_stroke_preserve(dmh_cr);
	setFillType (*ifill);
	cairo_fill(dmh_cr);
}
Ejemplo n.º 3
0
/*==================================================================================
 psrect - subroutine to output a rectangle, with integer fill code
 ==================================================================================*/
void psrect_ (double *x1, double *x2, double *y1, double *y2, double *rline, double *width, int *ifill) {
	DEBUGPRINT(("In psrect. minPt(1)=(%f, %f); maxPt(2)=(%f, %f), rline=%f, width=%f, fill=%i\n", *x1, *y1, *x2, *y2, *rline, *width, *ifill));
	DEBUGPRINT(("In psrect. Device Coords: minPt=(%f, %f); Size=(%f, %f)\n", deviceX(*x1), 
				deviceY(*y2),
				deviceW(*x2 - *x1), 
				deviceH(fabs(*y2 - *y1))));
	completeRelativeOperation();
	cairo_rectangle(dmh_cr, deviceX(*x1), 
					deviceY(*y2),	/* this is y2, not y1, to deal with Cairo's flipped coordinate system */
					deviceW(*x2 - *x1),
					deviceH(*y2 - *y1));
	setLineProperties((int) *rline, *width);
	cairo_set_source_rgb (dmh_cr, 0, 0, 0);	/* black */
	cairo_stroke_preserve(dmh_cr);
	setFillType (*ifill);
	cairo_fill(dmh_cr);
}
Ejemplo n.º 4
0
/*==================================================================================
 pspygn - subroutine to generate closed polygons, abs. coordinates
 ==================================================================================*/
void pspygn_ (double *x, double *y, int *npts, double *rline, double *width, int *ifill) {

	int i;
	
	DEBUGPRINT(("In pspygn.  Received %i points.  First=(%f, %f); Dev=(%f,%f). rline=%f, width=%f, fill=%i\n", *npts, x[0], y[0], deviceX(x[0]), deviceY(y[0]), *rline, *width, *ifill));
	completeRelativeOperation();
	cairo_move_to(dmh_cr, deviceX(x[0]), deviceY(y[0]));
	for (i = 1; i <= *npts-1; i++) {
		cairo_line_to(dmh_cr, deviceX(x[i]), deviceY(y[i]));
	}
	cairo_close_path(dmh_cr);
	
	setLineProperties((int) *rline, *width);
	cairo_set_source_rgb (dmh_cr, 0, 0, 0);	/* black */
	cairo_stroke_preserve(dmh_cr);
	setFillType (*ifill);
	cairo_fill(dmh_cr);
}
Ejemplo n.º 5
0
/*==================================================================================
 psrpgn - subroutine to generate closed polygons using rel. coordinates for all after
	the first
==================================================================================*/
void psrpgn_ (double *x1, double *y1, double *rx, double *ry, int *npts, double *rline, double *width,int *ifill) {

	int i;

	DEBUGPRINT(("In psrpgn\n"));
	completeRelativeOperation();
	cairo_move_to(dmh_cr, *x1, *y1);
	for (i = 0; i <= *npts-1; i++) {
		cairo_rel_line_to(dmh_cr, deviceW(rx[i]), deviceH(ry[i]));
	}
	cairo_close_path(dmh_cr);

	setLineProperties((int) *rline, *width);
	cairo_set_source_rgb (dmh_cr, 0, 0, 0);	/* black */
	cairo_stroke_preserve(dmh_cr);
	setFillType (*ifill);
	cairo_fill(dmh_cr);
}	
Ejemplo n.º 6
0
/*==================================================================================
 pspyln - subroutine to generate open polylines
 ==================================================================================*/
void pspyln_ (double *x, double *y, int *npts, double *rline, double *width, int *ifill) {
	int i;
	
	DEBUGPRINT(("In pspyln. Received %i points, with rline=%f, width=%f, fill=%i\n", *npts, *rline, *width, *ifill));
	completeRelativeOperation();

	if (dmh_inRotatedTransform) {
		cairo_set_matrix(dmh_cr, &dmh_unrotatedMatrix);	/* remove rotation */
		dmh_inRotatedTransform = 0;
		DEBUGPRINT(("Removing rotation.\n"));
	}

	cairo_move_to(dmh_cr, deviceX(x[0]), deviceY(y[0]));
	for (i = 1; i <= *npts-1; i++) {
		DEBUGPRINT(("In pspyln, lineto: (%f, %f).\n", deviceX(x[i]), deviceY(y[i])));
		cairo_line_to(dmh_cr, deviceX(x[i]), deviceY(y[i]));
	}
	
	setLineProperties((int) *rline, *width);
	cairo_set_source_rgb (dmh_cr, 0, 0, 0);	/* black */
	cairo_stroke_preserve(dmh_cr);
	setFillType (*ifill);
	cairo_fill(dmh_cr);
}
void Graphics::setGradientFill (const ColourGradient& gradient)
{
    setFillType (gradient);
}
Ejemplo n.º 8
0
void Graphics::setGradientFill (ColourGradient&& gradient)
{
    setFillType (std::move (gradient));
}