Image::Base::Gtk2::Gdk::Drawable -- draw into a Gdk window or pixmap
use Image::Base::Gtk2::Gdk::Drawable; my $image = Image::Base::Gtk2::Gdk::Drawable->new (-drawable => $win_or_pixmap); $image->line (0,0, 99,99, '#FF00FF'); $image->rectangle (10,10, 20,15, 'white');
Image::Base::Gtk2::Gdk::Drawable is a subclass of
Image::Base to draw into a Gdk drawable, meaning either a window or a pixmap.
Colour names are anything recognised by
Gtk2::Gdk::Color->parse, which means various names like "pink" plus hex #RRGGBB or #RRRRGGGGBBB. As of Gtk 2.20 the colour names are the Pango compiled-in copy of the X11 rgb.txt. Special names "set" and "clear" mean pixel values 1 and 0 for use with bitmaps.
Image::Base::Gtk2::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.
See "FUNCTIONS" in Image::Base for the behaviour common to all Image-Base classes.
$image = Image::Base::Gtk2::Gdk::Drawable->new (key=>value,...)
Create and return a new image object. A
-drawable parameter must be given,
$image = Image::Base::Gtk2::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
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.
The target drawable.
The size of the drawable per
The colormap in the underlying
$drawable->get_colormap. Windows always have a colormap, but pixmaps may or may not.
The number of bits per pixel in the drawable, from
The screen of the underlying drawable (
Copyright 2010, 2011, 2012 Kevin Ryde
Image-Base-Gtk2 is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.
Image-Base-Gtk2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with Image-Base-Gtk2. If not, see http://www.gnu.org/licenses/.