static int
gnome_print_multipage_stroke (GnomePrintContext *pc, const ArtBpath *bpath)
{
	GnomePrintMultipage *mp;
	const ArtVpathDash *dash;
	ArtBpath *p;
	gint ret;

	mp = GNOME_PRINT_MULTIPAGE (pc);
	dash = gp_gc_get_dash (pc->gc);
	p = art_bpath_affine_transform (bpath, mp->subpage->data);

	gnome_print_setrgbcolor   (mp->subpc, gp_gc_get_red (pc->gc), gp_gc_get_green (pc->gc), gp_gc_get_blue (pc->gc));
	gnome_print_setopacity    (mp->subpc, gp_gc_get_opacity    (pc->gc));
	gnome_print_setlinewidth  (mp->subpc, gp_gc_get_linewidth  (pc->gc));
	gnome_print_setmiterlimit (mp->subpc, gp_gc_get_miterlimit (pc->gc));
	gnome_print_setlinejoin   (mp->subpc, gp_gc_get_linejoin   (pc->gc));
	gnome_print_setlinecap    (mp->subpc, gp_gc_get_linecap    (pc->gc));
	gnome_print_setdash       (mp->subpc, dash->n_dash, dash->dash, dash->offset);

	ret = gnome_print_stroke_bpath (mp->subpc, p);

	art_free (p);

	return ret;
}
static int
gnome_print_multipage_clip (GnomePrintContext *pc, const ArtBpath *bpath, ArtWindRule rule)
{
	GnomePrintMultipage *mp;
	ArtBpath *p;
	gint ret;

	mp = GNOME_PRINT_MULTIPAGE (pc);

	p = art_bpath_affine_transform (bpath, mp->subpage->data);

	ret = gnome_print_clip_bpath_rule (mp->subpc, p, rule);

	art_free (p);

	return ret;
}
static int
gnome_print_multipage_fill (GnomePrintContext *pc, const ArtBpath *bpath, ArtWindRule rule)
{
	GnomePrintMultipage *mp;
	ArtBpath *p;
	gint ret;

	mp = GNOME_PRINT_MULTIPAGE(pc);

	p = art_bpath_affine_transform (bpath, mp->subpage->data);

	gnome_print_setrgbcolor (mp->subpc, gp_gc_get_red (pc->gc), gp_gc_get_green (pc->gc), gp_gc_get_blue (pc->gc));
	gnome_print_setopacity (mp->subpc, gp_gc_get_opacity (pc->gc));

	ret = gnome_print_fill_bpath_rule (mp->subpc, p, rule);

	art_free (p);

	return ret;
}
Beispiel #4
0
static void sp_genericellipse_set_shape (SPShape *shape)
{
	SPGenericEllipse *ellipse;
	SPCurve *c;
	ArtBpath bpath[16], * abp;

	double cx, cy, rx, ry, s, e;
	double x0, y0, x1, y1, x2, y2, x3, y3;
	double len;
	double affine[6];
	gint slice = FALSE;
	gint i;

	ellipse = (SPGenericEllipse *) shape;

	if ((ellipse->rx.computed < 1e-18) || (ellipse->ry.computed < 1e-18)) return;
	if (fabs (ellipse->end - ellipse->start) < 1e-9) return;

	sp_genericellipse_normalize (ellipse);

	cx = 0.0;
	cy = 0.0;
	rx = ellipse->rx.computed;
	ry = ellipse->ry.computed;

	len = fmod (ellipse->end - ellipse->start, SP_2PI);
	if (len < 0.0) len += SP_2PI;
	if (fabs (len) < 1e-9) {
		slice = FALSE;
	} else {
		slice = TRUE;
	}

	nr_matrix_d_set_scale (NR_MATRIX_D_FROM_DOUBLE (affine), rx, ry);
	affine[4] = ellipse->cx.computed;
	affine[5] = ellipse->cy.computed;

	i = 0;
	if (ellipse->closed) {
		bpath[i].code = ART_MOVETO;
	} else {
		bpath[i].code = ART_MOVETO_OPEN;
	}
	bpath[i].x3 = cos (ellipse->start);
	bpath[i].y3 = sin (ellipse->start);
	i++;

	for (s = ellipse->start; s < ellipse->end; s += M_PI_2) {
		e = s + M_PI_2;
		if (e > ellipse->end)
			e = ellipse->end;
		len = C1 * (e - s) / M_PI_2;
		x0 = cos (s);
		y0 = sin (s);
		x1 = x0 + len * cos (s + M_PI_2);
		y1 = y0 + len * sin (s + M_PI_2);
		x3 = cos (e);
		y3 = sin (e);
		x2 = x3 + len * cos (e - M_PI_2);
		y2 = y3 + len * sin (e - M_PI_2);
#ifdef ELLIPSE_VERBOSE
g_print ("step %d s %f e %f coords %f %f %f %f %f %f\n",
	i, s, e, x1, y1, x2, y2, x3, y3);
#endif
		bpath[i].code = ART_CURVETO;
		bpath[i].x1 = x1;
		bpath[i].y1 = y1;
		bpath[i].x2 = x2;
		bpath[i].y2 = y2;
		bpath[i].x3 = x3;
		bpath[i].y3 = y3;
		i++;
	}

	if (slice && ellipse->closed) {
		bpath[i].code = ART_LINETO;
		bpath[i].x3 = 0.0;
		bpath[i].y3 = 0.0;
		i++;
		bpath[i].code = ART_LINETO;
		bpath[i].x3 = bpath[0].x3;
		bpath[i].y3 = bpath[0].y3;
		i++;
	} else if (ellipse->closed) {
		bpath[i-1].x3 = bpath[0].x3;
		bpath[i-1].y3 = bpath[0].y3;
	}

	bpath[i].code = ART_END;

	abp = art_bpath_affine_transform (bpath, affine);

	c = sp_curve_new_from_bpath (abp);
	sp_shape_set_curve_insync ((SPShape *) ellipse, c, TRUE);
	sp_curve_unref (c);
}