예제 #1
0
QRadialGradient* getRadialGradient(const CLRadialGradient* radial, const CLBoundingBox* bounds, const CLRenderResolver* resolver)
{
  double cx = bounds->getPosition().getX() + radial->getCenterX().getAbsoluteValue()  + radial->getCenterX().getRelativeValue() / 100.0 * bounds->getDimensions().getWidth();
  double cy = bounds->getPosition().getY() + radial->getCenterY().getAbsoluteValue()  + radial->getCenterY().getRelativeValue() / 100.0 * bounds->getDimensions().getHeight();
  double fx = bounds->getPosition().getX() + radial->getFocalPointX().getAbsoluteValue()  + radial->getFocalPointX().getRelativeValue() / 100.0 * bounds->getDimensions().getWidth();
  double fy = bounds->getPosition().getY() + radial->getFocalPointY().getAbsoluteValue()  + radial->getFocalPointY().getRelativeValue() / 100.0 * bounds->getDimensions().getHeight();
  double r = radial->getRadius().getAbsoluteValue()  + radial->getRadius().getRelativeValue() / 100.0 * bounds->getDimensions().getWidth();

  QRadialGradient* result = new QRadialGradient(cx, cy, r, fx, fy);

  switch (radial->getSpreadMethod())
    {
      case CLGradientBase::REFLECT:
        result->setSpread(QGradient::ReflectSpread);
        break;

      case CLGradientBase::REPEAT:
        result->setSpread(QGradient::RepeatSpread);
        break;

      case CLGradientBase::PAD:
        result->setSpread(QGradient::PadSpread);
        break;

      default:
        break;
    }

  for (size_t i = 0; i < radial->getNumGradientStops(); ++i)
    {
      const CLGradientStop* stop = radial->getGradientStop(i);
      result->setColorAt(stop->getOffset().getAbsoluteValue() + stop->getOffset().getRelativeValue() / 100.0, getColor(stop->getStopColor(), resolver));
    }

  return result;
}
예제 #2
0
void StyleLoader::loadComposite(QRadialGradient& value)
{
	int coordinateMode;
	int spread;
	QPointF center;
	QPointF focal;
	double radius;
	QGradientStops stopPoints;

	load("coordinateMode", coordinateMode);
	load("spread", spread);
	load("centerPoint", center);
	load("focalPoint", focal);
	load("radius", radius);
	load("stopPoints", stopPoints);

	value = QRadialGradient(center, radius, focal);
	value.setSpread((QGradient::Spread) spread);
	value.setCoordinateMode((QGradient::CoordinateMode) coordinateMode);
	value.setStops(stopPoints);
}