logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

G2 - A simple graphics library ported to Perl.

Authors

       Horst Wagner (wagner/users-sourceforge.net) and Ljubomir Milanovic (ljubo/users-sourceforge-net)

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
       development).  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.

Exported Constants

         G2LD
         G2_H
         G2_VERSION

Exported Functions

Creatingnewdevices
       "newX11"
            "G2::Device::newX11(width,height)" classmethod

            opens  an  X11  window  with  width  and  height of X11 window given in pixels.  returns : a new X11
            device.

       "newPS"
            "G2::Device::newPS(filename,paper,orientation)" classmethod

            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.

       "newGD"
            "G2::Device::newGD(filename,width,height,type)" classmethod

            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

       "newVD"
            G2::Device::newVD() classmethod

            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.

   DeviceFunctions
       ""   G2::Device::attach(dev) objectmethod

       ""   G2::Device::detach(dev) objectmethod

       ""   G2::Device::close() objectmethod

       "set_auto_flush"
            G2::Device::set_auto_flush(on_off) objectmethod

       "flush"
            G2::Device::flush() objectmethod

       "save"
            G2::Device::save() objectmethod

       "set_coordinate_system"
            "G2::Device::set_coordinate_system(x_origin, y_origin, x_mul, y_mul)" objectmethod

       "ld" G2::Device::ld() objectmethod

       "set_ld"
            G2::Device::set_ld( dev) objectmethod

       "ink"
            "G2::Device::ink( pd_dev, red, green, blue)" objectmethod

       "pen"
            G2::Device::pen(color) objectmethod

       "set_dash"
            "G2::Device::set_dash(N, *dashes)" objectmethod

       "set_font_size"
            G2::Device::set_font_size(size) objectmethod

       "set_line_width"
            G2::Device::set_line_width(w) objectmethod

       "clear_palette"
            G2::Device::clear_palette( dev) objectmethod

       "reset_palette"
            G2::Device::reset_palette( dev) objectmethod

       "allocate_basic_colors"
            G2::Device::allocate_basic_colors( dev) objectmethod

       "clear"
            G2::Device::clear( dev) objectmethod

       "set_background"
            G2::Device::set_background(color) objectmethodDrawingFunctions
       "move"
            "G2::Device::move(x, y)" objectmethod

       "move_r"
            "G2::Device::move_r(dx, dy)" objectmethod

       "plot"
            "G2::Device::plot(x, y)" objectmethod

       "plot_r"
            "G2::Device::plot_r(dx, dy)" objectmethod

       "line"
            "G2::Device::line(x1, y1, x2, y2)" objectmethod

       "line_r"
            "G2::Device::line_r(dx, dy)" objectmethod

       "line_to"
            "G2::Device::line_to(x, y)" objectmethod

       "poly_line"
            "G2::Device::poly_line(N_pt, *pos)" objectmethod

       "triangle"
            "G2::Device::triangle(x1, y1, x2, y2, x3, y3)" objectmethod

       "filled_triangle"
            "G2::Device::filled_triangle(x1, y1, x2, y2, x3, y3)" objectmethod

       "rectangle"
            "G2::Device::rectangle(x1, y1, x2, y2)" objectmethod

       "filled_rectangle"
            "G2::Device::filled_rectangle(x1, y1, x2, y2)" objectmethod

       "polygon"
            "G2::Device::polygon(N_pt, *pos)" objectmethod

       "filled_polygon"
            "G2::Device::filled_polygon(N_pt, *pos)" objectmethod

       "circle"
            "G2::Device::circle(x, y, r)" objectmethod

       "filled_circle"
            "G2::Device::filled_circle(x, y, r)" objectmethod

       "ellipse"
            "G2::Device::ellipse(x, y, r1, r2)" objectmethod
                      Draw an ellipse on device dev
                      x,y: center point
                      r1,r2: x and y radius

       "filled_ellipse"
            "G2::Device::filled_ellipse(x, y, r1, r2)" objectmethod
                      Draw a filled ellipse on device dev
                      x,y: center point
                      r1,r2: x and y radius

       "arc"
            "G2::Device::arc(x, y, r1, r2, a1, a2)" objectmethod

            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

       "filled_arc"
            "G2::Device::filled_arc(x, y, r1, r2, a1, a2)" objectmethod
                      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

       "string"
            "G2::Device::string(x, y, char *text)" objectmethod

       ""   "G2::Device::set_QP(d, enum QPshape shape)" objectmethod

       ""   "G2::Device::plot_QP(x, y)" objectmethod

Name

       G2 - A simple graphics library ported to Perl.

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");

See Also