<?php $sur = new CairoImageSurface(CairoFormat::ARGB32, 32, 16); $con = new CairoContext($sur); $con->save(); $con->setSourceRgb(1, 1, 1); $con->paint(); $con->restore(); $con->arc(8, 8, 4, 0, M_PI); $con->closePath(); $con->arc(8, 8, 4, M_PI, 2 * M_PI); $con->fill(); $con->translate(16, 0); $con->moveTo(8, 4); $con->arcNegative(8, 8, 4, 3 * M_PI / 2, M_PI / 2); $con->closePath(); $con->curveTo(12, 4, 12, 12, 8, 12); $path = $con->copyPathFlat(); $con->newPath(); $con->appendPath($path); $con->fill(); $sur->writeToPng(dirname(__FILE__) . "/close-path-php.png"); ?>
<?php $dashes = array(50.0, 10.0, 10.0, 10.0); $ndash = count($dashes); $offset = -50.0; $sur = new CairoImageSurface(0, 500, 500); $con = new CairoContext($sur); $con->setDash($dashes, $offset); $con->setLineWidth(10.0); $con->moveTo(128.0, 25.6); $con->lineTo(230.4, 230.4); $con->relLineTo(-102.4, 0.0); $con->curveTo(51.2, 230.4, 51.2, 128.0, 128.0, 128.0); $con->stroke(); $sur->writeToPng(dirname(__FILE__) . "/image_dash.png");
<?php $sur = new CairoImageSurface(CairoFormat::RGB24, 165, 30); $con = new CairoContext($sur); $con->moveTo(0, 0); $con->setSourceRgb(1, 1, 1); $con->paint(); $con->setSourceRgb(0, 0, 0); $con->moveTo(0, 0); $con->translate(5, 5); /* First compress the pen to a vertical line. */ $con->rectangle(0, 0, 20, 20); $con->curveTo(20 / 2, 0, 20, 20 / 2, 20, 20); $con->save(); $con->scale(1.0E-5, 1.0); $con->stroke(); $con->restore(); $con->translate(5 + 20, 0); /* Then compress the pen to a horizontal line. */ $con->rectangle(0, 0, 20, 20); $con->curveTo(20 / 2, 0, 20, 20 / 2, 20, 20); $con->save(); $con->scale(1.0, 1.0E-5); $con->stroke(); $con->restore(); $con->translate(5 + 20, 0); /* Finally a line at an angle. */ $con->rectangle(0, 0, 20, 20); $con->curveTo(20 / 2, 0, 20, 20 / 2, 20, 20); $con->save(); $con->rotate(M_PI / 4.0);