package G2; use strict; use Carp; use vars qw($VERSION @ISA @EXPORT @EXPORT_OK $AUTOLOAD); require Exporter; require DynaLoader; require AutoLoader; use strict; @ISA = qw(Exporter DynaLoader); # Items to export into callers namespace by default. Note: do not export # names by default without a very good reason. Use EXPORT_OK instead. # Do not simply export all your public functions/methods/constants. @EXPORT = qw( G2LD G2_H G2_VERSION ); $VERSION = '0.01'; sub AUTOLOAD { # This AUTOLOAD is used to 'autoload' constants from the constant() # XS function. If a constant is not found then control is passed # to the AUTOLOAD in AutoLoader. my $constname; ($constname = $AUTOLOAD) =~ s/.*:://; my $val = constant($constname, @_ ? $_[0] : 0); if ($! != 0) { if ($! =~ /Invalid/) { $AutoLoader::AUTOLOAD = $AUTOLOAD; goto &AutoLoader::AUTOLOAD; } else { croak "Your vendor has not defined G2 macro $constname"; } } eval "sub $AUTOLOAD { $val }"; goto &$AUTOLOAD; } bootstrap G2 $VERSION; # Preloaded methods go here. # Autoload methods go after =cut, and are processed by the autosplit program. 1; __END__ # Below is the stub of documentation for your module. You better edit it! =head1 NAME G2 - A simple graphics library ported to Perl. =head1 SYNOPSIS use G2; $dev1 = newX11 G2::Device(775, 575); $dev2 = newGD G2::Device("test.png",600,200); $dev1->rectangle(20,20,150,150); $dev1->circle(100,150,60); $dev2->circle(100,150,60); $dev2->string(100,50,"A circle in a PNG file"); =head1 DESCRIPTION g2 is a simple to use graphics library for 2D graphical applications. This library provides a comprehensive set of functions for simultaneous generation of graphical output on different types of devices. Presently, following devices are currently supported by g2: X11, PNG, PostScript (xfig is in developement). One major feature of the g2_library is the concept of virtual devices. An arbitrary number of physical devices (such as PNG, or X11) can be grouped to create a so-called virtual device. Commands sent to such a virtual devices will automatically issued to all attached physical devices. This allows for example simultaneous output to a PNG file and a Postscript file. A virtual device in turn can be attached to another virtual device, allowing to construct trees of devices. Virtual devices can also be useful when using different user-coordinate systems. E.g. one X11 window showing an overview of a graphical output, and a second window showing a zoom of a more detailed area of the graphic. Drawing in both windows is performed by one single command to the virtual device. Please see g2 documentation (C interface) for up to date version. =head1 Exported constants G2LD G2_H G2_VERSION =head1 Exported functions =head2 Creating new devices =over 5 =item C C I opens an X11 window with width and height of X11 window given in pixels. returns : a new X11 device. =item C C I opens a new PostScript device. file_name: name of PostScript file paper: Paper size (e.g. g2_A4, g2_Letter). See PostScript paper sizes for a full list of supported sizes. orientation: paper orientation. Either g2_PS_land for landscape or g2_PS_port for portrait returns : a new PostScript device. =item C C I open a new GD device width,height: width and height of the image in pixels filename: name of the output file. type: file type, 0-jpeg, 1-png returns : a new GD device =item C C I Create a new Virtual Device. An arbitrary number of physical devices (such as PNG, or X11) can be grouped to create a so-called virtual device. Commands sent to such a virtual devices will automatically issued to all attached physical devices. This allows for example simultaneous output to a PNG file and a Postscript file. A virtual device in turn can be attached to another virtual device, allowing to construct trees of devices. Virtual devices can also be useful when using different user-coordinate systems. E.g. one X11 window showing an overview of a graphical output, and a second window showing a zoom of a more detailed area of the graphic. Drawing in both windows is performed by one single command to the virtual device. =head2 Device Functions =item C<> C I =item C<> C I =item C<> C I =item C C I =item C C I =item C C I =item C C I =item C C I =item C C I =item C C I =item C C I =item C C I =item C C I =item C C I =item C C I =item C C I =item C C I =item C C I =item C C I =head2 Drawing Functions =item C C I =item C C I =item C C I =item C C I =item C C I =item C C I =item C C I =item C C I =item C C I =item C C I =item C C I =item C C I =item C C I =item C C I =item C C I =item C C I =item C C I Draw an ellipse on device dev x,y: center point r1,r2: x and y radius =item C C I Draw a filled ellipse on device dev x,y: center point r1,r2: x and y radius =item C C I Draw an arc with center point at (x,y), x and y radius given by r1,r2 and starting and ending angle in radians a1,a2 =item C C I Draw a filled arc on device dev x,y: center point r1,r2: x and y radius a1,a2: starting and ending angle in radians =item C C I =item C<> C I =item C<> C I =head1 AUTHORS Horst Wagner (wagner/users-sourceforge.net) and Ljubomir Milanovic (ljubo/users-sourceforge-net) =head1 COPYRIGHT Copyright (C) 1998-2001 Ljubomir Milanovic & Horst Wagner This file is part of the g2 library This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA =cut