Linux implementation requests

I think I now have the Linux code base working well enough my current needs. I realize that you guys are incredibly busy, but if you find time to develop the Linux code base, here are a few unimplemented features I’d love to see:

  • Linear Gradients with transformations
  • Radial Gradients (also with transformations)
  • Text Path (this looks like it’s not even possible)

I managed to implement the first two of these on my own,

Maybe you like to share the implementation for it?

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, &currentMatrix);
                    cairo_matrix_multiply (&resultMatrix, &matrix, &currentMatrix);
                    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;
}
1 Like