Ejemplo n.º 1
0
<?php

$points = 10.0;
$step = 1.0 / $points;
$pad = 1.0;
$width = $pad + $points * 2 + $pad;
$height = $width;
$sur = new CairoImageSurface(CairoFormat::ARGB32, $width, $height);
$con = new CairoContext($sur);
$con->setSourceRgb(1, 1, 1);
$con->paint();
$con->setSourceRgb(0, 0, 0);
$con->translate($pad, $pad);
$con->setAntialias(CairoAntialias::MODE_NONE);
for ($i = 0; $i < $points; $i++) {
    for ($j = 0; $j < $points; $j++) {
        $t1 = 2 * $i * 1.0 + $i * $step * 2.0;
        $t2 = 2 * $j * 1.0 + $j * $step * 1.0;
        $con->rectangle($t1, $t2, 1, 1);
        $con->fill();
    }
}
$sur->writeToPng(dirname(__FILE__) . '/a1-traps-sample-php.png');
?>


Ejemplo n.º 2
0
<?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');
Ejemplo n.º 3
0
<?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");
Ejemplo n.º 4
0
<?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");
?>


Ejemplo n.º 5
0
<?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();
Ejemplo n.º 6
0
<?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, 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);
Ejemplo n.º 8
0
<?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");
Ejemplo n.º 9
0
<?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");
?>

Ejemplo n.º 10
0
<?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");
?>

Ejemplo n.º 11
0
<?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);
Ejemplo n.º 12
0
<?php

$width = 10;
$height = 8;
$sur = new CairoImageSurface(CairoFormat::ARGB32, $width, $height);
$con = new CairoContext($sur);
$s = new CairoImageSurface(CairoFormat::A1, $width, $height);
$str = "";
$stride = $s->getStride();
echo "Stride: " . $stride . "\n";
for ($i = 0; $i < 8; $i++) {
    $str = $str . chr(0x14);
    $str = $str . chr(0xaa);
    /*$str=$str . chr(255);
    
    	$str=$str . chr(0);
    
    	$str=$str . chr(255);
    
    	$str=$str . chr(0);
    
    	$str=$str . chr(0);
    
    	$str=$str . chr(0);*/
}
echo $str;
$s->createForData($str, CairoFormat::A1, $width, $height);
$con->setSourceRgb(0, 0, 1);
$con->paint();
$con->setSourceRgb(1, 0, 0);
$con->maskSurface($s, 0, 0);
<?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");
?>

Ejemplo n.º 14
0
{
    global $con, $width, $height;
    $block_width = floor(0.33 * $width + 0.5);
    $block_height = floor(0.33 * $height + 0.5);
    for ($i = 0; $i < 3; $i++) {
        for ($j = 0; $j < 3; $j++) {
            if (($i + $j) % 2 == 0) {
                $con->rectangle($x + $block_width * $i, $y + $block_height * $j, $block_width, $block_height);
            }
        }
    }
    $con->fill();
}
$imwidth = 2 * ($width + $pad) + $pad;
$imheight = 4 * ($height + $pad) + $pad;
$sur = new CairoImageSurface(CairoFormat::ARGB32, $imwidth, $imheight);
$con = new CairoContext($sur);
$con->selectFontFace("Bitstream Vera Sans", CairoFontSlant::NORMAL, CairoFontWeight::NORMAL);
for ($j = 0; $j < 4; $j++) {
    for ($i = 0; $i < 2; $i++) {
        $x = $i * ($width + $pad) + $pad;
        $y = $j * ($height + $pad) + $pad;
        $con->save();
        $pat = new CairoLinearGradient($x + $width, $y, $x, $y + $height);
        $pat->addColorStopRgba(0.2, 0.0, 0.0, 1.0, 1.0);
        /* Solid blue */
        $pat->addColorStopRgba(0.8, 0.0, 0.0, 1.0, 0.0);
        /* Transparent blue */
        $con->setSource($pat);
        $con->rectangle($x, $y, $width, $height);
        $con->fillPreserve();
Ejemplo n.º 15
0
<?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');
Ejemplo n.º 16
0
<?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");
?>

Ejemplo n.º 17
0
<?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");
Ejemplo n.º 18
0
<?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();
Ejemplo n.º 19
0
<?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');
Ejemplo n.º 20
0
<?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");
?>
Ejemplo n.º 21
0
<?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();
Ejemplo n.º 22
0
<?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");
?>



Ejemplo n.º 23
0
<?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");
?>

Ejemplo n.º 24
0
<?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');
Ejemplo n.º 25
0
<?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");
Ejemplo n.º 26
0
<?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);
    }
Ejemplo n.º 27
0
<?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++) {
Ejemplo n.º 28
0
<?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");
?>

Ejemplo n.º 29
0
 /**
  * Finally save image
  * 
  * @param string $file Destination filename
  * @return void
  */
 public function render($file)
 {
     $this->drawAllTexts();
     $this->surface->writeToPng($file);
 }
Ejemplo n.º 30
0
<?php

$sur = new CairoImageSurface(CairoFormat::ARGB32, 3 * (3 + 6 + 3), 8 * (6 + 3) + 3);
$con = new CairoContext($sur);
$cap = array(CairoLineCap::ROUND, CairoLineCap::SQUARE, CairoLineCap::BUTT);
$dash = array(2.0, 2.0);
$dash_long = array(6.0, 6.0);
$con->setSourceRgb(1, 0, 0);
for ($i = 0; $i < 3; $i++) {
    $con->save();
    $con->setLineCap($cap[$i]);
    /* simple degenerate paths */
    $con->setLineWidth(6);
    $con->moveTo(6, 6);
    $con->lineTo(6, 6);
    $con->stroke();
    $con->translate(0, 3 * 3);
    $con->moveTo(6, 6);
    $con->closePath();
    $con->stroke();
    /* degenerate paths starting with dash on */
    $con->setDash($dash, 0.0);
    $con->translate(0, 3 * 3);
    $con->moveTo(6, 6);
    $con->lineTo(6, 6);
    $con->stroke();
    $con->translate(0, 3 * 3);
    $con->moveTo(6, 6);
    $con->closePath();
    $con->stroke();
    /* degenerate paths starting with dash off */