- PHP 手册
- 函数参考
- 图像生成和处理
- Cairo
- CairoContext
CairoContext::fill
cairo_fill
(PECL cairo >= 0.1.0)
CairoContext::fill -- cairo_fill — Fills the current path
说明
面向对象风格 (method):
public CairoContext::fill ( void ) : void过程化风格:
cairo_fill ( CairoContext$context
) : void
A drawing operator that fills the current path according to the current CairoFillRule, (each sub-path is implicitly closed before being filled). After CairoContext::fill() or cairo_fill(), the current path will be cleared from the CairoContext.
参数
-
context
-
A valid CairoContext object created with CairoContext::__construct() or cairo_create()
返回值
没有返回值。
范例
Example #1 面向对象风格
<?php
$s = new CairoImageSurface(CairoFormat::ARGB32, 100, 100);
$c = new CairoContext($s);
$c->setSourceRgb(0, 0, 0);
$c->paint();
$c->setSourceRgb(1, 1, 1);
$c->rectangle(0, 0, 50, 50);
$c->fill();
$c->setSourceRgb(0, 1, 0);
$c->rectangle(50, 50, 50, 50);
$c->fill();
$s->writeToPng(dirname(__FILE__) . '/CairoContext_fill.png');
?>
以上例程的输出类似于:
...
Example #2 过程化风格
<?php
$s = cairo_image_surface_create(CAIRO_SURFACE_TYPE_IMAGE, 100, 100);
$c = cairo_create($s);
cairo_set_source_rgb($c, 0, 0, 0);
cairo_paint($c);
cairo_set_source_rgb($c, 1, 1, 1);
cairo_rectangle($c, 0, 0, 50, 50);
cairo_fill($c);
cairo_set_source_rgb($c, 0, 1, 0);
cairo_rectangle($c, 50, 50, 50, 50);
cairo_fill($c);
cairo_surface_write_to_png($s, dirname(__FILE__) . '/cairo_fill.png');
?>
以上例程的输出类似于:
...
参见
- CairoContext::setFillRule() - The setFillRule purpose
- ContextContext::fillPreserve()
- CairoFillRule
User Contributed Notes
There are no user contributed notes for this page.官方地址:https://www.php.net/manual/en/cairocontext.fill.php