CairoContext::fill

(PECL cairo >= 0.1.0)
Fills the current path
public void CairoContext::fill ( void )

Object oriented style (method):

Procedural style:

void cairo_fill ( CairoContext $context )

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.

Parameters:
context

A valid CairoContext object created with CairoContext::__construct() or cairo_create()

Returns:

No value is returned.

Examples:
Object oriented style
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?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');
 
?>

The above example will output something similar to:

...
Procedural style
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?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');
 
?>

The above example will output something similar to:

...
See also:

CairoContext::setFillRule() -

CairoFillRule -

doc_php
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.