示例#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');
?>


示例#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');
示例#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");
示例#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");
?>


示例#5
0
$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();
$con->setSourceRgb(1, 1, 0);
$con->paint();
$sur->writeToPng(dirname(__FILE__) . "/clip-twice-php.png");
示例#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");
}
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);
    $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);
}
$con->setSourceRgb(0, 0, 0);
$con->paint();
$s = new CairoImageSurface(CairoFormat::ARGB32, 100, 100);
$s->createForData($data, CairoFormat::RGB24, 4, 4, 16);
//$con->test_paint_checkered();
$con->scale(0.5, 0.5);
$con->setSourceSurface($s, 4, 4);
$pat = $con->getSource();
$pat->setFilter(CairoFilter::NEAREST);
$con->paint();
$sur->writeToPng(dirname(__FILE__) . "/scale-down-source-surface-paint-php.png");
示例#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");
示例#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");
?>

示例#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");
?>

示例#11
0
    $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);
    $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);
}
echo $data;
$s = new CairoImageSurface(CairoFormat::ARGB32, 100, 100);
$s->createForData($data, CairoFormat::ARGB32, 4, 4, 16);
$con->scale(4, 4);
$con->setSourceSurface($s, 2, 2);
$pat = $con->getSource();
$pat->setFilter(CairoFilter::NEAREST);
$con->paint();
$sur->writeToPng(dirname(__FILE__) . "/paint-source-alpha-php.png");
示例#12
0
文件: a1-mask.php 项目: jamesan/cairo
$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);
$sur->writeToPng(dirname(__FILE__) . "/a1-mask-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");
?>

示例#14
0
        $con->clip();
        $con->setOperator(CairoOperator::CLEAR);
        //pattern_funcs[i] ($x, $y);
        switch ($i) {
            case 0:
                set_solid_pattern($x, $y);
                break;
            case 1:
                set_gradient_pattern($x, $y);
                break;
        }
        //draw_funcs[j] (cr, x, y);
        switch ($j) {
            case 0:
                draw_mask($x, $y);
                break;
            case 1:
                draw_glyphs($x, $y);
                break;
            case 2:
                draw_polygon($x, $y);
                break;
            case 3:
                draw_rects($x, $y);
                break;
        }
        $con->restore();
    }
}
$sur->writeToPng(dirname(__FILE__) . "/operator-clear-php.png");
示例#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');
示例#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");
?>

示例#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");
$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();
$pat->setFilter(CairoFilter::NEAREST);
$con->setSource($pat);
$con->paint();
$sur->writeToPng(dirname(__FILE__) . "/rotate-image-surface-paint-php.png");
示例#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');
示例#20
0
$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");
?>

示例#21
0
$cr2->setSourceRgb(0, 1, 0);
$cr2->stroke();
$cr2->moveTo(5 * $patwidth / 6.0, 0);
$cr2->lineTo($patwidth, 0);
$cr2->lineTo($patwidth, $patheight / 6.0);
$cr2->setSourceRgb(0, 0, 1);
$cr2->stroke();
$cr2->moveTo(5 * $patwidth / 6.0, $patheight);
$cr2->lineTo($patwidth, $patheight);
$cr2->lineTo($patwidth, 5 * $patheight / 6.0);
$cr2->setSourceRgb(1, 1, 0);
$cr2->stroke();
$cr2->setSourceRgb(0.5, 0.5, 0.5);
$cr2->setLineWidth($patwidth / 10.0);
$cr2->moveTo(0, $patheight / 4.0);
$cr2->lineTo($patwidth, $patheight / 4.0);
$cr2->stroke();
$cr2->moveTo($patwidth / 4.0, 0);
$cr2->lineTo($patwidth / 4.0, $patwidth);
$cr2->stroke();
$pattern = new CairoSurfacePattern($pat_surface);
$mat = new CairoMatrix();
$mat->scale(2, 1.5);
$mat->rotate(1);
$mat->translate(-$patwidth / 4.0, -$patwidth / 2.0);
$pattern->setMatrix($mat);
$pattern->setExtend(CairoExtend::NONE);
$con->setSource($pattern);
$con->paint();
$sur->writeToPng(dirname(__FILE__) . "/meta-surface-pattern-php.png");
示例#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");
?>



示例#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");
?>

示例#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');
示例#25
0
文件: dashes.php 项目: jamesan/cairo
<?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");
示例#26
0
$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);
    }
}
$s->createForData($data, CairoFormat::A1, $width, $height, $stride);
$con->setSourceRgb(0, 1, 0);
$con->maskSurface($s, 0, 0);
$sur->writeToPng(dirname(__FILE__) . "/large-source-php.png");
示例#27
0
$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++) {
    $s->createForData($c[$i], CairoFormat::RGB24, 1, 1, 4);
    $con->setSourceSurface($s, $i % 2, $i / 2);
    $con->paint();
}
$sur->writeToPng(dirname(__FILE__) . "/move-to-show-surface-php.png");
示例#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");
?>

示例#29
0
 /**
  * Finally save image
  * 
  * @param string $file Destination filename
  * @return void
  */
 public function render($file)
 {
     $this->drawAllTexts();
     $this->surface->writeToPng($file);
 }
示例#30
0
    /* these should not draw anything */
    $con->setDash($dash, 2.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();
    /* this should draw a single degenerate sub-path
     * at the end of the path */
    $con->setDash($dash_long, 6.0);
    $con->translate(0, 3 * 3);
    $con->moveTo(6 + 6.0, 6);
    $con->lineTo(6, 6);
    $con->stroke();
    /* this should draw a single degenerate sub-path
     * at the end of the path. The difference between this
     * and the above is that this ends with a degenerate sub-path*/
    $con->setDash($dash_long, 6.0);
    $con->translate(0, 3 * 3);
    $con->moveTo(6 + 6.0, 6);
    $con->lineTo(6, 6);
    $con->lineTo(6, 6);
    $con->stroke();
    $con->restore();
    $con->translate(3 + 6 + 3, 0);
}
$sur->writeToPng(dirname(__FILE__) . "/degenerate-path-php.png");