Few days ago I was doing some reading and came across another Cairo wrapper extension for PHP in development. So it seems like a duplicate effort being wasted, however, my implementation uses OOP API (similar to the python PHP extension) and the other extension is implemented in a flat, C-Style API.
I don't know whether my extension is really needed or whether it will be accepted to PECL so for now I'll wait with it until I will know that it will be useful for someone or maybe try to submit it to PECL and see what happens.
0.0.3 is the first public version of my libCairo extension and the source code is available for download.
The extension doesn't cover the whole Cairo API and there is no documentation but the following code will give you an idea of what the API looks like:
$Surface = new CairoSurfaceImage(0,256,256);
$ctx = new CairoContext($Surface);
$ctx->setAntialias(0);
$ctx->setFillRule(0);
$ctx->scale(256/1.0, 256/1.0);
$pat = new CairoPatternGradientLinear(0.0, 0.0, 0.0, 1.0);
$pat->addColorStopRGBA(1, 0, 0, 0, 1);
$pat->addColorStopRGBA(0, 1, 1, 1, 1);
$ctx->rectangle(0,0,1,1);
$ctx->setSource($pat);
$ctx->fill();
$pat = new CairoPatternGradientRadial(0.45, 0.4, 0.1,
0.4, 0.4, 0.5);
$pat->addColorStopRGBA(0, 1, 1, 1, 1);
$pat->addColorStopRGBA(1, 0, 0, 0, 1);
$ctx->setSource($pat);
$ctx->arc(0.5, 0.5, 0.3, 0, 2*3.14);
$ctx->fill();
$Surface->toPng();
?>
This snippet fully work in the current version and will produce the above picture.
Anyway, I don't know what will become of my extension but if there will be demand for it i'll continue coding.
It was a very educational experience and I believe that I'm ready to get my fingers even deeper into the PHP engine.
5 comments:
Nice work! :) It works like a charm :) You just saved my day ;)
Really??
But it's .. a little "half baked" ..
isn't it?
I think you are a respect man because you did saying the truth when you wrote about your extension .However, you can be easily better than him but on stages, How?.
From my opinion, I think you MUST still up to date with your extension and piece by piece in every release version your work will raise to the sky and in some day MAY be he will come to take your permit to share you in your extension and this is the state of our world (IT IS IN LOOP). That will come to you by HARE EFFORT, just look to your future target about your extension (DREAM HOW DOES LOOK LIKE?) after that MAY be you find a new message in your mail box that call you to be one of the PHP teamwork.
Enthuse your morale,
Abdullah
*HARD EFFORT
Abdullah, Thank you for your comment.
This extension is now irrelevant.
There are two Cairo extensions in PECL:
http://pecl.php.net/package-search.php?pkg_name=cairo&bool=AND&submit=Search
One of them was developed during GSOC.
I lost interest in Cairo PHP.
A long time ago I had this vision that PHP can become a RAD env for desktop application. I don't think so anymore.
Post a Comment