Kevin Ryde > Image-Base-Prima > Image::Base::Prima::Drawable

Download:
Image-Base-Prima-8.tar.gz

Dependencies

Annotate this POD

Website

View/Report Bugs
Module Version: 8   Source  

NAME ^

Image::Base::Prima::Drawable -- draw into Prima window, image, etc

SYNOPSIS ^

 use Image::Base::Prima::Drawable;
 my $image = Image::Base::Prima::Drawable->new
               (-drawable => $d);
 $image->line (0,0, 99,99, '#FF00FF');
 $image->rectangle (10,10, 20,15, 'white');

CLASS HIERARCHY ^

Image::Base::Prima::Drawable is a subclass of Image::Base,

    Image::Base
      Image::Base::Prima::Drawable

DESCRIPTION ^

Image::Base::Prima::Drawable extends Image::Base to draw into a Prima::Drawable drawable, meaning a widget window, off-screen image, printer, postscript accumulator, etc.

The native Prima drawing has many more features, but this module can point some Image::Base style code at a Prima image etc.

X,Y coordinates are the usual Image::Base style 0,0 at the top-left corner. Prima works from 0,0 as the bottom-left but Image::Base::Prima::Drawable converts. No attention is paid to the Prima translate() origin change, which ends up meaning the top-left shifts up etc with the translate. That seems reasonably logical, is it the best way though?

None of the drawing functions here do a $drawable->begin_paint() or a $drawable->begin_doc() (for Prima::PS::Drawable). That's left to the application. A begin_paint() of course happens automatically in an onPaint handler call. The symptom of forgetting a begin_paint() is generally that lines, rectangles and ellipses don't draw anything, though xy() might come out because it uses $drawable->pixel (but don't rely on that). Forgetting a begin_doc() for PS output may cause various warnings about undef.

Colours

Colour names for drawing are

    Blue             Prima colour constants cl::Blue etc
    #RRGGBB          hex
    #RRRRGGGGBBBB    hex

Internally Prima works in 8-bit RGB components though drawables with less than 24-bits per pixel then reduce further. See "Color space" in Prima::Drawable for details and the cl:: colour constant names.

FUNCTIONS ^

See "FUNCTIONS" in Image::Base for the behaviour common to all Image-Base classes.

$image = Image::Base::Prima::Drawable->new (key=>value,...)

Create and return a new image object. A Prima::Drawable object must be given.

    $image = Image::Base::Prima::Drawable->new
               (-drawable => $d);
$colour = $image->xy ($x, $y)
$image->xy ($x, $y, $colour)

Get or set the pixel at $x,$y.

Currently colours returned by a get are always 2-digit hex #RRGGBB. Would names "Blue" for cl::Blue etc be better for those particular colours?

ATTRIBUTES ^

-drawable (Prima::Drawable object)

The target drawable.

-width (integer)
-height (integer)

The width and height of the underlying drawable. Setting these resizes the drawable (as per $drawable->size, see "Other properties" in Prima::Drawable).

SEE ALSO ^

Image::Base, Prima::Drawable, Image::Base::Prima::Image

Image::Base::Gtk2::Gdk::Drawable, Image::Base::X11::Protocol::Drawable

HOME PAGE ^

http://user42.tuxfamily.org/image-base-prima/index.html

LICENSE ^

Image-Base-Prima is Copyright 2010, 2011 Kevin Ryde

Image-Base-Prima 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-Prima 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-Prima. If not, see <http://www.gnu.org/licenses/>.

syntax highlighting: