NAME
App::MathImage::Image::Base::Gtk::Gdk::Drawable -- draw into a Gdk window or pixmap
SYNOPSIS
use App::MathImage::Image::Base::Gtk::Gdk::Drawable;
my $image = App::MathImage::Image::Base::Gtk::Gdk::Drawable->new
(-drawable => $win_or_pixmap);
$image->line (0,0, 99,99, '#FF00FF');
$image->rectangle (10,10, 20,15, 'white');
CLASS HIERARCHY
App::MathImage::Image::Base::Gtk::Gdk::Drawable
is a subclass of Image::Base
,
Image::Base
App::MathImage::Image::Base::Gtk::Gdk::Drawable
DESCRIPTION
In progress ...
App::MathImage::Image::Base::Gtk::Gdk::Drawable
extends Image::Base
to draw into a Gdk drawable, meaning either a window or a pixmap.
Colour names are anything recognised by Gtk::Gdk::Color->parse_color()
, which means various names like "pink" plus hex #RRGGBB or #RRRRGGGGBBB. Special names "set" and "clear" mean pixel values 1 and 0 for use with bitmaps.
The Image::Base::Gtk::Gdk::Pixmap
subclass has some specifics for creating pixmaps, but this base Drawable is enough to draw into an existing one.
Native Gdk drawing does much more than Image::Base
but if you have some generic pixel twiddling code for Image::Base
then this Drawable class lets you point it at a Gdk window etc. Drawing into a window is a good way to show slow drawing progressively, rather than drawing into a pixmap or image file and only displaying when complete. See Image::Base::Multiplex
for a way to do both simultaneously.
FUNCTIONS
See "FUNCTIONS" in Image::Base for the behaviour common to all Image-Base classes.
$image = App::MathImage::Image::Base::Gtk::Gdk::Drawable->new (key=>value,...)
-
Create and return a new image object. A
-drawable
parameter must be given,$image = App::MathImage::Image::Base::Gtk::Gdk::Drawable->new (-drawable => $win_or_pixmap);
Further parameters are applied per
set
(see "ATTRIBUTES" below). $image->xy ($x, $y, $colour)
-
Get or set the pixel at
$x
,$y
.In the current code colours are returned in #RRGGBB form and require a colormap. Perhaps in the future it will be #RRRRGGGGBBBB form since under X there's 16-bit resolution. Generally a colormap is required, though bitmaps without a colormap give 0 and 1. The intention is probably to have pixmaps without colormaps give back raw pixel values. Maybe bitmaps could give back "set" and "clear" as an option.
Fetching a pixel is an X server round-trip and reading out a big region will be slow. The server can give a region or the entire drawable in one go, so some function for that would be better if much fetching is needed.
ATTRIBUTES
-drawable
(Gtk::Gdk::Drawable
object)-
The target drawable.
-width
(integer)-height
(integer)-
The size of the drawable per
$drawable->get_size()
. -colormap
(Gtk::Gdk::Colormap
, orundef
)-
The colormap in the underlying
-drawable
per$drawable->get_colormap
. Windows always have a colormap, but pixmaps may or may not. -depth
(integer, read-only)-
The number of bits per pixel in the drawable, from
$drawable->get_depth
.