I think I sent a pull request, but I’m just getting my feet wet with Github, so my commits are all over the place. I’ll post the code here.
cairocontext.cpp
void Context::fillRadialGradient (CGraphicsPath* path, const CGradient& gradient,
const CPoint& center, CCoord radius, const CPoint& originOffset,
bool evenOdd, CGraphicsTransform* transformation)
{
if (path)
{
auto graphicsPath = dynamic_cast<GraphicsPath*> (
path->getPlatformPath (PlatformGraphicsPathFillMode::Ignored).get ());
if (!graphicsPath)
return;
std::unique_ptr<GraphicsPath> alignedPath;
if (needPixelAlignment (getDrawMode ()))
alignedPath = graphicsPath->copyPixelAlign (getCurrentTransform ());
if (auto cairoGradient = dynamic_cast<Gradient*> (gradient.getPlatformGradient ().get ()))
{
if (auto cd = DrawBlock::begin (*this))
{
auto p = alignedPath ? alignedPath->getCairoPath () : graphicsPath->getCairoPath ();
cairo_set_source (cr, cairoGradient->getRadialGradient (center, radius, originOffset));
if (transformation)
{
cairo_matrix_t currentMatrix;
cairo_matrix_t resultMatrix;
auto matrix = convert (*transformation);
cairo_get_matrix (cr, ¤tMatrix);
cairo_matrix_multiply (&resultMatrix, &matrix, ¤tMatrix);
cairo_set_matrix (cr, &resultMatrix);
}
cairo_append_path (cr, p);
if (evenOdd)
{
cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
cairo_fill (cr);
}
else
{
cairo_fill (cr);
}
}
}
}
}
Line 23 of cairogradient.h
const PatternHandle& getRadialGradient (CPoint center, CCoord radius, CPoint offset);
cairogradient.cpp
const PatternHandle& Gradient::getRadialGradient (CPoint center, CCoord radius, CPoint offset)
{
if (!radialGradient)
{
radialGradient = PatternHandle (cairo_pattern_create_radial (center.x, center.y, 0, center.x + offset.x, center.y + offset.y, radius));
for (auto& it : getColorStops ())
{
cairo_pattern_add_color_stop_rgba (
radialGradient, it.first, it.second.normRed<double> (),
it.second.normGreen<double> (), it.second.normBlue<double> (),
it.second.normAlpha<double> ());
}
}
return radialGradient;
}