NAME
Image::Base::Wx::DC -- draw into a Wx::DC
SYNOPSIS
use Image::Base::Wx::DC;
my $image = Image::Base::Wx::DC->new
(-dc => $dc);
$image->line (0,0, 99,99, '#FF00FF');
$image->rectangle (10,10, 20,15, 'white');
CLASS HIERARCHY
Image::Base::Wx::DC
is a subclass of Image::Base
,
Image::Base
Image::Base::Wx::DC
DESCRIPTION
Image::Base::Wx::DC
extends Image::Base
to draw into a Wx::DC
.
Native Wx::DC
does much more than Image::Base
but if you have some generic pixel twiddling code for Image::Base
then this class can point it at Wx for a window or printer paint, etc.
See Image::Base::Wx::Bitmap
for a subclass drawing into Wx::Bitmap
with file loading and saving too.
Colour Names
Colour names are anything recognised by Wx::Colour->new()
, which as per its Set()
method means
"pink" names per wxColourDatabase
"#RRGGBB" 2 digit hex
"RGB(r,g,b)" decimal 0 to 255
1, 3 or 4 digit hex are platform dependent. They work under Gtk, but not under MS-Windows.
The colour is applied to the "pen" in the -dc
, and for filling to the "brush" too. The pen is also set to wxCAP_PROJECTING
to ensure the last pixel is drawn for line()
. That might be an artifact of the X11 pixel rule "on the boundary above or left", but in any case gets the right effect.
If the colour etc in the -dc
is changed elsewhere then what Image::Base::Wx::DC
thinks it has set will be invalid. Set -dc
into the $image
again to reset.
FUNCTIONS
See "FUNCTIONS" in Image::Base for the behaviour common to all Image-Base classes.
$image = Image::Base::Wx::DC->new (key=>value,...)
-
Create and return a new image object. A
-dc
parameter must be given,$image = Image::Base::Wx::DC->new (-dc => $dc);
Further parameters are applied per
set
(see "ATTRIBUTES" below). $image->xy ($x, $y, $colour)
-
Get or set the pixel at
$x
,$y
.Getting a pixel is per
Wx::DC
GetPixel()
. In the current code colours are returned in "#RRGGBB" form (wxC2S_HTML_SYNTAX
ofWx::Colour
).
ATTRIBUTES
-dc
(Wx::DC
object)-
The target dc.
-width
,-height
(read-only)-
The size of the DC's target, as per
$dc->GetSize()
.
BUGS
Wx circa 3.0.4, with Gtk at least, may have line and point fuzzing turned on by default. The effect is that individual pixels, and corners of rectangles, do not get the colour you say, but are blurred into the existing background. That sort of thing can be desirable for circles or sloping lines, but not for rectangles and pixels. Wx::Image
drawing is precise so you can draw that way for full control.
SEE ALSO
Wx, Image::Base, Image::Base::Wx::Image
HOME PAGE
http://user42.tuxfamily.org/image-base-wx/index.html
LICENSE
Copyright 2012, 2019 Kevin Ryde
Image-Base-Wx 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-Wx 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-Wx. If not, see <http://www.gnu.org/licenses/>.