GdkPixbuf::fill

fill(int pixel or red [, int green [, int blue [, int alpha]]]);

Fills the whole image with the specified color.

You can either supply one parameter, a pixel specification or four parameters that represent values from 0-255 for red, green, blue and alpha. An alpha value of 255 means opaque, while 0 means fully transparent.

Example 7. Filling the whole image with one color

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

//Create a pixel specification:
$pixel = 0;
$pixel += 255 << 24;//red
$pixel += 128 << 16;//green
$pixel += 0   <<  8;//blue
$pixel += 128;      //alpha

//And fill another area with the pixel color
$pixbuf->fill($pixel);


//Alternative:
//green, half-transparent
//overwrites the previously set color
$pixbuf->fill(128, 255, 0, 128);


//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();
?>