Beispiel #1
0
// MakeGradient
Gradient*
SVGRadialGradient::MakeGradient() const
{
//printf("SVGRadialGradient::MakeGradient()\n");
	// TODO: handle userSpaceOnUse/objectBoundingBox
	Gradient* gradient = new Gradient(true);
	gradient->SetType(GRADIENT_CIRCULAR);
	gradient->SetInterpolation(INTERPOLATION_LINEAR);

	double cx = 0.0;
	double cy = 0.0;
	double r = 100.0;

	BString value;
	if (FindString("cx", &value) >= B_OK)
		cx = atof(value.String());
	if (FindString("cy", &value) >= B_OK)
		cy = atof(value.String());
	if (FindString("r", &value) >= B_OK)
		r = atof(value.String());

	// the transformed parallelogram
	double parl[6];
	parl[0] = cx - r;
	parl[1] = cy - r;
	parl[2] = cx + r;
	parl[3] = cy - r;
	parl[4] = cx + r;
	parl[5] = cy + r;

	trans_affine transform(-64.0, -64.0, 64.0, 64.0, parl);
	gradient->multiply(transform);

	return gradient;
}
Beispiel #2
0
// MakeGradient
Gradient*
SVGLinearGradient::MakeGradient() const
{
//printf("SVGLinearGradient::MakeGradient()\n");
//PrintToStream();

	Gradient* gradient = new Gradient(true);
	gradient->SetType(GRADIENT_LINEAR);
	gradient->SetInterpolation(INTERPOLATION_LINEAR);
	// setup the gradient transform 
	BPoint start(-64.0, -64.0);
	BPoint end(64.0, -64.0);
	BString coordinate;
	if (FindString("x1", &coordinate) >= B_OK)
		start.x = atof(coordinate.String());
	if (FindString("y1", &coordinate) >= B_OK)
		start.y = atof(coordinate.String());
	if (FindString("x2", &coordinate) >= B_OK)
		end.x = atof(coordinate.String());
	if (FindString("y2", &coordinate) >= B_OK)
		end.y = atof(coordinate.String());

	// the transformed parallelogram
	double parl[6];
	parl[0] = start.x;
	parl[1] = start.y;
	parl[2] = end.x;
	parl[3] = end.y;
	parl[4] = end.x - (end.y - start.y);
	parl[5] = end.y + (end.x - start.x);

	trans_affine transform(-64.0, -64.0, 64.0, 64.0, parl);
	gradient->multiply(transform);

	return gradient;
}