function draw_mask($x, $y) { global $con, $width, $height, $sur; $wi = floor(0.9 * $width); $he = floor(0.9 * $height); $x += 0.05 * $width; $y += 0.05 * $height; //$s = new CairoImageSurface(FORMATARGB32, 1, 1); $s = $sur->createSimilar(CairoContent::ALPHA, $wi, $he); $con2 = new CairoContext($s); $con2->setSourceRgb(1, 1, 1); /* white */ $con2->arc(0.5 * $wi, 0.5 * $he, 0.45 * $he, 0, 2 * M_PI); $con2->fill(); $con->maskSurface($s, $x, $y); }
/** * Draw an image * * The image will be inlined in the SVG document using data URL scheme. For * this the mime type and base64 encoded file content will be merged to * URL. * * @param mixed $file Image file * @param ezcGraphCoordinate $position Top left position * @param mixed $width Width of image in destination image * @param mixed $height Height of image in destination image * @return void */ public function drawImage($file, ezcGraphCoordinate $position, $width, $height) { $this->initiliazeSurface(); // Ensure given bitmap is a PNG image $data = getimagesize($file); if ($data[2] !== IMAGETYPE_PNG) { throw new Exception('Cairo only has support for PNGs.'); } // Create new surface from given bitmap $imageSurface = CairoImageSurface::createFromPng($file); // Create pattern from source image to be able to transform it $pattern = new CairoSurfacePattern($imageSurface); // Scale pattern to defined dimensions and move it to its destination position $matrix = CairoMatrix::multiply($move = CairoMatrix::initTranslate(-$position->x, -$position->y), $scale = CairoMatrix::initScale($data[0] / $width, $data[1] / $height)); $pattern->setMatrix($matrix); // Merge surfaces $this->context->setSource($pattern); $this->context->rectangle($position->x, $position->y, $width, $height); $this->context->fill(); }
<?php $s = new CairoImageSurface(CairoFormat::ARGB32, 100, 100); $c = new CairoContext($s); $c->setSourceRgb(0, 0, 0); $c->paint(); $c->setLineWidth(1); $c->setSourceRgb(1, 1, 1); for ($r = 50; $r > 0; $r -= 10) { $c->arc(50, 50, $r, 0, 2 * M_PI); $c->stroke(); $c->fill(); } $s->writeToPng(dirname(__FILE__) . '/CairoContext__arc.png');
<?php $sur = new CairoImageSurface(CairoFormat::ARGB32, 120, 100); $con = new CairoContext($sur); $con->setSourceRgb(1, 1, 1); $con->paint(); $con->setSourceRgb(0, 0, 0); $con->setMiterLimit(100000); for ($xscale = 1; $xscale <= 1000; $xscale += 999) { for ($yscale = 1; $yscale <= 1000; $yscale += 999) { //$max_scale = ($xscale > $yscale) ? $xscale : $yscale; $max_scale = max($xscale, $yscale); $con->save(); if ($xscale > 1) { $con->translate(50, 0); } if ($yscale > 1) { $con->translate(0, 50); } $con->scale($xscale, $yscale); $con->setLineWidth(10.0 / $max_scale); $con->moveTo(10.0 / $xscale, 10.0 / $yscale); $con->lineTo(40.0 / $xscale, 10.0 / $yscale); $con->lineTo(10.0 / $xscale, 30.0 / $yscale); $con->stroke(); $con->restore(); } } $sur->writeToPng(dirname(__FILE__) . "/miter-precision-php.png");
<?php $sur = new CairoImageSurface(CairoFormat::ARGB32, 32, 32); $con = new CairoContext($sur); $data = ""; for ($i = 0; $i < 2; $i++) { $data .= chr(0x80); $data .= chr(0x80); $data .= chr(0x80); $data .= chr(0x80); $data .= chr(0x80); $data .= chr(0x80); $data .= chr(0x80); $data .= chr(0x80); $data .= chr(0x0); $data .= chr(0x0); $data .= chr(0x80); $data .= chr(0x80); $data .= chr(0x0); $data .= chr(0x0); $data .= chr(0x80); $data .= chr(0x80); } for ($i = 0; $i < 2; $i++) { $data .= chr(0x0); $data .= chr(0x80); $data .= chr(0x0); $data .= chr(0x80); $data .= chr(0x0); $data .= chr(0x80); $data .= chr(0x0);
<?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");
function draw_pattern($surface_size) { global $s; $con = new CairoContext($s); $con->setSourceRgb(1, 1, 1); $con->rectangle(0, 0, $surface_size / 2, $surface_size / 2); $con->fill(); $con->setSourceRgb(1, 0, 0); $con->rectangle($surface_size / 2, 0, $surface_size / 2, $surface_size / 2); $con->fill(); $con->setSourceRgb(0, 1, 0); $con->rectangle(0, $surface_size / 2, $surface_size / 2, $surface_size / 2); $con->fill(); $con->setSourceRgb(0, 0, 1); $con->rectangle($surface_size / 2, $surface_size / 2, $surface_size / 2, $surface_size / 2); $con->fill(); // $s->writeToPng(dirname(__FILE__) . "temp1.png"); }
<?php $sur = new CairoImageSurface(CairoFormat::ARGB32, 36, 36); $con = new CairoContext($sur); $s = new CairoImageSurface(CairoFormat::ARGB32, 2, 2); $con2 = new CairoContext($s); $con2->setSourceRgb(1, 0, 0); $con2->paint(); $con2->setSourceRgb(0, 0, 1); $con2->rectangle(0, 1, 1, 1); $con2->rectangle(1, 0, 1, 1); $con2->fill(); $con->setSourceRgb(0, 0, 0); $con->paint(); $con->save(); $con->translate(3, 3); $con->scale(10, 10); $con->translate(0.5, 0.5); $con->setSourceSurface($s, 0, 0); $con->paint(); $con->restore(); $sur->writeToPng(dirname(__FILE__) . "/filter-bilinear-extents-php.png"); ?>
<?php $width = 64; $height = 64; $sur = new CairoImageSurface(CairoFormat::ARGB32, $width, $height); $con = new CairoContext($sur); $con->newPath(); $con->arc($width / 2, $height / 2, $width / 3, 0, 2 * M_PI); $con->clip(); $con->newPath(); $con->moveTo(0, 0); $con->lineTo($width / 4, $height / 2); $con->lineTo(0, $height); $con->lineTo($width, $height); $con->lineTo(3 * $width / 4, $height / 2); $con->lineTo($width, 0); $con->closePath(); $con->clip(); $con->setSourceRgb(0, 0, 0.6); $con->newPath(); $con->moveTo(0, 0); $con->lineTo(0, $height); $con->lineTo($width / 2, 3 * $height / 4); $con->lineTo($width, $height); $con->lineTo($width, 0); $con->lineTo($width / 2, $height / 4); $con->closePath(); $con->fill(); $con->newPath(); $con->arc($width / 2, $height / 2, $width / 5, 0, 2 * M_PI); $con->clip();
<?php $sur = new CairoImageSurface(CairoFormat::ARGB32, 10, 10); $con = new CairoContext($sur); $data = ""; for ($i = 0; $i < 4; $i++) { $data = $data . chr(0x80); $data = $data . chr(0x0); $data = $data . chr(0x0); $data = $data . chr(0x0); } $s = new CairoImageSurface(CairoFormat::ARGB32, 1, 1); $s->createForData(data, CairoFormat::ARGB32, 2, 2, 8); $pat = new CairoSurfacePattern($s); $con->setSourceRgb(1, 0, 0); $con->save(); $con->translate(2, 2); $con->mask($pat); $con->restore(); $mat = new CairoMatrix(); $mat->translate(-4, -4); $pat->setMatrix($mat); $con->mask($pat); $con->translate(2, 2); $con->mask($pat); $sur->writeToPng(dirname(__FILE__) . "/mask-ctm-php.png"); ?>
<?php $width = 71; $height = 28; $sur = new CairoImageSurface(CairoFormat::ARGB32, $width, $height); $con = new CairoContext($sur); $dash = array(8.0, 2.0); $con->setSourceRgb(1, 1, 1); $con->paint(); $con->setSourceRgb(0.0, 0.0, 0); $con->setLineWidth(2); /* This is vital to reproduce the bug. */ /* First check simple rectangles */ $con->rectangle(2, 2, 67, 24); $con->setDash($dash, 9.0); $con->stroke(); $sur->writeToPng(dirname(__FILE__) . '/leaky-dash.png');
<?php $size = 20; $pad = 2; $surface_size = sqrt(($size - 2 * $pad) * ($size - 2 * $pad) / 2); $sur = new CairoImageSurface(CairoFormat::ARGB32, $size, $size); $con = new CairoContext($sur); $s = new CairoImageSurface(CairoFormat::RGB24, $surface_size, $surface_size); $con2 = new CairoContext($s); $con2->setSourceRgb(1, 1, 1); $con2->rectangle(0, 0, $surface_size / 2, $surface_size / 2); $con2->fill(); $con2->setSourceRgb(1, 0, 0); $con2->rectangle($surface_size / 2, 0, $surface_size / 2, $surface_size / 2); $con2->fill(); $con2->setSourceRgb(0, 1, 0); $con2->rectangle(0, $surface_size / 2, $surface_size / 2, $surface_size / 2); $con2->fill(); $con2->setSourceRgb(0, 0, 1); $con2->rectangle($surface_size / 2, $surface_size / 2, $surface_size / 2, $surface_size / 2); $con2->fill(); /* First paint opaque background (black) so we don't need separate * ARGB32 and RGB24 reference images. */ $con->setSourceRgb(0, 0, 0); /* black */ $con->paint(); $con->translate($size / 2, $size / 2); $con->rotate(M_PI / 4.0); $con->translate(-$surface_size / 2, -$surface_size / 2); $con->setSourceSurface($s, 0, 0); $pat = $con->getSource();
<?php $starsize = 20; $sur = new CairoImageSurface(CairoFormat::ARGB32, $starsize * 2 + 2, $starsize + 2); $con = new CairoContext($sur); $con->setSourceRgb(1, 0, 0); $con->translate(1, 1); $con->save(); $con->moveTo(10, 0); $con->relLineTo(6, 20); $con->relLineTo(-16, -12); $con->relLineTo(20, 0); $con->relLineTo(-16, 12); $con->setFillRule(CairoFillRule::WINDING); $con->clip(); $con->paint(); $con->restore(); $con->translate($starsize + 1, 0); $con->save(); $con->moveTo(10, 0); $con->relLineTo(6, 20); $con->relLineTo(-16, -12); $con->relLineTo(20, 0); $con->relLineTo(-16, 12); $con->setFillRule(CairoFillRule::EVEN_ODD); $con->clip(); $con->paint(); $con->restore(); $sur->writeToPng(dirname(__FILE__) . "/clip-fill-rule-php.png"); ?>
<?php $sur = new CairoImageSurface(CairoFormat::ARGB32, 8, 8); $con = new CairoContext($sur); $con->save(); $con->setSourceRgb(0, 0, 1); $con->paint(); $con->rectangle(2, 2, 4, 4); $con->clip(); $con->setSourceRgb(1, 0, 0); $con->paint(); $con->restore(); $con->pushGroup(); $s = $con->getGroupTarget(); $con->setSourceRgb(0, 1, 0); $con->fill(); $off = $s->getDeviceOffset(); $te = $off["x"]; echo $te; $con->rectangle(2, 2, 4, 4); $con->fill(); $con->popGroupToSource(); $con->paint(); $sur->writeToPng(dirname(__FILE__) . "/get-group-target-php.png"); ?>
<?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 $size = 100; $border = 10; $linewidth = 20; $sur = new CairoImageSurface(CairoFormat::ARGB32, $size, $size); $con = new CairoContext($sur); $s = $con->getGroupTarget(); $c = new CairoContext($s); $c->moveTo($border, $border); $c->lineTo($border + $linewidth, $border); $c->lineTo($size - $border, $size - $border); $c->lineTo($size - $border - $linewidth, $size - $border); $c->clip(); $c->setSourceRgb(0, 0, 1); $c->paint(); $c->setSourceRgb(1, 1, 1); $c->rectangle($size / 2 - $linewidth / 2, $border, $linewidth, $size - 2 * $border); $c->fill(); $c2 = new CairoContext($sur); $c2->setSourceRgb(1, 1, 1); $c2->rectangle($size - $border - $linewidth, $border, $linewidth, $size - 2 * $border); $c2->fill(); $con->setSourceRgb(1, 1, 1); $con->rectangle($border, $border, $linewidth, $size - 2 * $border); $con->fill(); $sur->writeToPng(dirname(__FILE__) . "/clip-nesting-php.png");
<?php $sur = new CairoImageSurface(CairoFormat::ARGB32, 6, 6); $con = new CairoContext($sur); $data = ""; for ($i = 0; $i < 2; $i++) { $data .= chr(0xff); $data .= chr(0xff); $data .= chr(0xff); $data .= chr(0xff); $data .= chr(0xff); $data .= chr(0xff); $data .= chr(0xff); $data .= chr(0xff); $data .= chr(0x0); $data .= chr(0x0); $data .= chr(0xff); $data .= chr(0xff); $data .= chr(0x0); $data .= chr(0x0); $data .= chr(0xff); $data .= chr(0xff); } for ($i = 0; $i < 2; $i++) { $data .= chr(0x0); $data .= chr(0xff); $data .= chr(0x0); $data .= chr(0xff); $data .= chr(0x0); $data .= chr(0xff); $data .= chr(0x0);
<?php $sur = new CairoImageSurface(CairoFormat::ARGB32, 20, 20); $redmask = 0x5; $greenmask = 0x50; $con = new CairoContext($sur); $con->setSourceRgb(0, 0, 1); $con->paint(); $s = new CairoImageSurface(CairoFormat::A1, 6400, 20); $stride = $s->getStride(); $height = $s->getHeight(); $width = $s->getWidth(); $data = ""; for ($y = 0; $y < $height; $y++) { for ($x = 0; $x < ($width + 7) / 8; $x++) { $data = $data . chr(5); } } $s->createForData($data, CairoFormat::A1, $width, $height, $stride); $con->setSourceRgb(1, 0, 0); $con->maskSurface($s); $con->fill(); $s = new CairoImageSurface(CairoFormat::A1, 20, 6400); $stride = $s->getStride(); $height = $s->getHeight(); $width = $s->getWidth(); $data = ""; for ($y = 0; $y < $height; $y++) { for ($x = 0; $x < ($width + 7) / 8; $x++) { $data = $data . chr(80); }
<?php $patwidth = 120; $patheight = 120; $size = $patwidth * 2; $pad = 2; $width = $pad + $size + $pad; $height = $width; $sur = new CairoImageSurface(CairoFormat::ARGB32, $width, $height); $con = new CairoContext($sur); //$s = new CairoImageSurface(FORMATARGB32, $width, $height); $con->translate($pad, $pad); $pat_surface = $sur->createSimilar(CairoContent::COLOR_ALPHA, $patwidth, $patheight); $cr2 = new CairoContext($pat_surface); $cr2->setSourceRgba(1, 0, 1, 0.5); $cr2->rectangle($patwidth / 6.0, $patheight / 6.0, $patwidth / 4.0, $patheight / 4.0); $cr2->fill(); $cr2->setSourceRgba(0, 1, 1, 0.5); $cr2->rectangle($patwidth / 2.0, $patheight / 2.0, $patwidth / 4.0, $patheight / 4.0); $cr2->fill(); $cr2->setLineWidth(1); $cr2->moveTo($patwidth / 6.0, 0); $cr2->lineTo(0, 0); $cr2->lineTo(0, $patheight / 6.0); $cr2->setSourceRgb(1, 0, 0); $cr2->stroke(); $cr2->moveTo($patwidth / 6.0, $patheight); $cr2->lineTo(0, $patheight); $cr2->lineTo(0, 5 * $patheight / 6.0); $cr2->setSourceRgb(0, 1, 0); $cr2->stroke();
<?php $sur = new CairoImageSurface(CairoFormat::ARGB32, 12, 12); $con = new CairoContext($sur); $data = ""; for ($i = 0; $i < 2; $i++) { $data .= chr(0xff); $data .= chr(0xff); $data .= chr(0xff); $data .= chr(0xff); $data .= chr(0xff); $data .= chr(0xff); $data .= chr(0xff); $data .= chr(0xff); $data .= chr(0x0); $data .= chr(0x0); $data .= chr(0xff); $data .= chr(0xff); $data .= chr(0x0); $data .= chr(0x0); $data .= chr(0xff); $data .= chr(0xff); } for ($i = 0; $i < 2; $i++) { $data .= chr(0x0); $data .= chr(0xff); $data .= chr(0x0); $data .= chr(0xff); $data .= chr(0x0); $data .= chr(0xff); $data .= chr(0x0);
<?php $sur = new CairoImageSurface(CairoFormat::ARGB32, 53, 53); $con = new CairoContext($sur); $con->setSourceRgb(1, 0, 0); $con->translate(1, 1); $con->moveTo(0, 0); $con->lineTo(25, 50); $con->lineTo(25, 0); $con->lineTo(50, 25); $con->lineTo(0, 25); $con->closePath(); $con->fill(); $sur->writeToPng(dirname(__FILE__) . "/fill-missed-stop-php.png"); ?>
<?php $sur = new CairoImageSurface(CairoFormat::ARGB32, 256 + 32 * 2, 192 + 32 * 2); $con = new CairoContext($sur); $s = new CairoImageSurface(CairoFormat::ARGB32, 100, 100); $s->createFromPng(dirname(__FILE__) . "/romedalen.png"); $con->setSourceSurface($s, 32, 32); $pat = $con->getSource(); $pat->setExtend(CairoExtend::REPEAT); $con->setSource($pat); $con->paint(); $sur->writeToPng(dirname(__FILE__) . "/extend-repeat-php.png"); ?>
<?php $Surface = new CairoImageSurface(0, 256, 256); $ctx = new CairoContext($Surface); $ctx->setAntialias(0); $ctx->setFillRule(0); $ctx->scale(256 / 1.0, 256 / 1.0); $pat = new CairoLinearGradient(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 CairoRadialGradient(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(); $check = $ctx->getTarget(); $check->writeToPng(dirname(__FILE__) . '/sphere.png');
<?php $sur = new CairoImageSurface(CairoFormat::ARGB32, 300, 16); $con = new CairoContext($sur); $con->save(); $con->setSourceRgb(1.0, 1.0, 1.0); /* white */ $con->paint(); $con->restore(); $con->selectFontFace('Bitstream Vera Sans', CairoFontSlant::NORMAL, CairoFontWeight::NORMAL); $con->setFontSize(12); $con->setSourceRgb(0, 0, 0); /* black */ $con->moveTo(0, 12); $con->showText('Hello from the '); $con->showText('show-text-current-point-php'); $con->showText(' test.'); $sur->writeToPng(dirname(__FILE__) . '/show-text-current-point.png');
<?php $sur = new CairoImageSurface(CairoFormat::ARGB32, 25 * 60, 4 * 60); $con = new CairoContext($sur); $dash = array(20.0, 20.0); $con->setSourceRgb(0, 0, 0); $con->paint(); for ($a = 0; $a < 4; $a++) { for ($b = 0; $b < 5; $b++) { for ($c = 0; $c < 5; $c++) { $con->moveTo(($b * 5 + $c) * 60 + 10, $a * 60 + 10); $con->relCurveTo(0, $b * 10, 0, $b * 10, $c * 10, $b * 10); $con->setSourceRgb(1, 1, 1); $con->setLineWidth(8); $con->setLineCap(CairoLineCap::ROUND); $con->setDash($dash, $a * 10); $con->strokePreserve(); $con->setSourceRgb(0, 0.5, 1); $con->setLineWidth(2); $con->setLineCap(2); $ar = array(8.0, 8.0); $con->setDash($ar, 0); $con->stroke(); } } } $sur->writeToPng(dirname(__FILE__) . '/dash-curve-php.png');
<?php $sur = new CairoImageSurface(CairoFormat::ARGB32, 100, 100); $con = new CairoContext($sur); $s = new CairoImageSurface(CairoFormat::ARGB32, 1, 1); $s->createFromPng(dirname(__FILE__) . "/romedalen.png"); $con->setSourceRgb(0, 0, 0); $con->rectangle(0, 0, 100, 100); $con->fill(); $con->translate(10, 10); $con->setOperator(CairoOperator::OVER); $con->setSourceSurface($s, 0, 0); $con->rectangle(0, 0, 90, 90); $con->fill(); $sur->writeToPng(dirname(__FILE__) . "/composite-integer-translate-over-php.png"); ?>
<?php $sur = new CairoImageSurface(CairoFormat::RGB24, 2, 2); $con = new CairoContext($sur); $s = new CairoImageSurface(CairoFormat::RGB24, 2, 2); $c = array(); $color = ""; $color .= chr(0xff); $color .= chr(0xff); $color .= chr(0xff); $color .= chr(0xff); $c[0] = $color; $color = ""; $color .= chr(0x0); $color .= chr(0x0); $color .= chr(0xff); $color .= chr(0xff); $c[1] = $color; $color = ""; $color .= chr(0x0); $color .= chr(0xff); $color .= chr(0x0); $color .= chr(0xff); $c[2] = $color; $color = ""; $color .= chr(0xff); $color .= chr(0x0); $color .= chr(0x0); $color .= chr(0xff); $c[3] = $color; for ($i = 0; $i < 4; $i++) {
<?php $size = 10; $pad = 2; $sur = new CairoImageSurface(CairoFormat::ARGB32, $size, $size); $con = new CairoContext($sur); $con->setSourceRgb(0, 0, 1); $con->rectangle($pad, $pad, $size - 2 * $pad, $size - 2 * $pad); $con->fill(); $s = $con->getGroupTarget(); $c = $s->getContent(); $s1 = $s->createSimilar($c, $size / 2, $size / 2); $c = new CairoContext($s1); $c->setSourceRgb(1, 0, 0); $c->rectangle($pad, $pad, $size - 2 * $pad, $size - 2 * $pad); $c->fill(); $s1->setDeviceOffset($size / 2, $size / 2); $con->setSourceSurface($s1, $size / 2, $size / 2); $con->paint(); $sur->writeToPng(dirname(__FILE__) . "/device-offset-positive-php.png");
<?php $sur = new CairoImageSurface(CairoFormat::ARGB32, 10, 10); $con = new CairoContext($sur); $con->setSourceRgb(0, 0, 1); $con->paint(); $con->resetClip(); $con->clip(); $con->translate(0.5, 0.5); $con->setSourceRgb(0, 1, 0); $con->rectangle(0, 0, 10, 10); $con->fillPreserve(); $con->setSourceRgb(1, 0, 0); $con->stroke(); $con->selectFontFace("Bitstream Vera Sans", CairoFontSlant::NORMAL, CairoFontWeight::NORMAL); $con->moveTo(0, 10); $con->showText("cairo"); $sur->writeToPng(dirname(__FILE__) . "/clip-empty-php.png");
<?php $sur = new CairoImageSurface(CairoFormat::ARGB32, 2, 2); $con = new CairoContext($sur); $pat = new CairoLinearGradient(0, 0, 1, 1); $con->setSource($pat); $con->paint(); unset($pat); $pat = new CairoRadialGradient(0, 0, 0, 1, 1, 1); $con->setSource($pat); $con->paint(); $sur->writeToPng(dirname(__FILE__) . "/gradient-zero-stops-php.png"); ?>