GdkPixbuf::fill_area

fill_area(int x, int y, int width, int height, int pixel or red [, int green [, int blue [, int alpha]]]);

Fills the area specified by (x, y - width, height) with the specified color.

The color is either a pixel specification or a tuple of red, green, blue and alpha values (ranging from 0 to 255).

A pixel specification is an integer with the bits of red, green, blue and alpha shifted by 8. See the example how to create one.

An alpha value of 0 means completely transparent, while 255 means totally opaque.

Example 8. Filling an areas of a pixbuf with color

<?php
//Create a new pixbuf of size 320x240
$pixbuf = new GdkPixbuf(Gdk::COLORSPACE_RGB, true, 8, 320, 240);

//fill area at (10,10) of size (20,50) with color
//(rgba = 255, 255, 255, 255)
//the alpha value of 255 makes it opaque
$pixbuf->fill_area(10, 10, 20, 50, 255, 255, 255, 255);


//Create a pixel specification:
//First, we define the RGBA values we need
$r = 255;
$g = 128;
$b = 0;
$a = 128;

//Now create the pixel
$pixel = 0;
$pixel += $r << 24;
$pixel += $g << 16;
$pixel += $b << 8;
$pixel += $a;

//And fill another area with the pixel color
$pixbuf->fill_area(50, 50, 30, 40, $pixel);


//Display the pixbuf by using a GtkImage widget
$wnd = new GtkWindow();
$wnd->connect_simple('destroy', array('Gtk', 'main_quit'));
$wnd->add(GtkImage::new_from_pixbuf($pixbuf));
$wnd->show_all();
Gtk::main();
?>