chickadee » g2

g2

Description

An interface to the g2 graphics library.

Author

felix winkelmann

Requirements

easyffi

Documentation

The following definitions are exported from this extension. Consult the g2 documentation for more information.

qpcircconstant
qprectconstant

Part of enum QPSHAPE.

g2:poly-line DEVICE NUM F64VECTORprocedure
g2:set-background DEVICE COLORprocedure
g2:arc DEVICE X Y R1 R2 A1 A2procedure
g2:filled-arc DEVICE X Y R1 R2 A1 A2procedure
g2:ld DEVICEprocedure

(returns LD)

g2:set-ld DEVICEprocedure
g2:string DEVICE X Y STRINGprocedure
g2:set-qp DEVICE D QPSHAPEprocedure
g2:set-coordinate-system DEVICE XORIGIN YORIGIN XMUL YMULprocedure
g2:set-dash DEVICE NUM F64FECTORprocedure
g2:close DEVICEprocedure
g2:move-r DEVICE DX DYprocedure
g2:line-to DEVICE X Yprocedure
g2:pen DEVICE COLORprocedure
g2:flush DEVICEprocedure
g2:set-line-width DEVICE WIDTHprocedure
g2:clear DEVICEprocedure
g2:set-auto-flush DEVICE BOOLprocedure
g2:allocate-basic-colors DEVICEprocedure
g2:image DEVICE X Y XSIZE YSIZE S32VECTORprocedure
g2:detach VDEVICE DEVICEprocedure
g2:polygon DEVICE NUM F64VECTORprocedure
g2:filled-polygon DEVICE NUM F64VECTORprocedure
g2:open-vdprocedure

Returns a VDEVICE

g2:plot DEVICCE X Yprocedure
g2:reset-palette DEVICEprocedure
g2:clear-palette DEVICEprocedure
g2:spline DEVICE NUM F64VECTOR Oprocedure
g2:b-spline DEVICE NUM F64VECTOR Oprocedure
g2:filled-spline DEVICE NUM F64VECTOR Oprocedure
g2:filled-b-spline DEVICE NUM F64VECTOR Oprocedure
g2:set-font-size DEVICE SIZEprocedure
g2:plot-r DEVICE DX DYprocedure
g2:save DEVICEprocedure
g2:move DEVICE X Yprocedure
g2:ink DEVICE RED GREEN BLUEprocedure

Returns a COLOR

g2:raspln DEVICE NUM F64VECTORprocedure
g2:filled-raspln DEVICE NUM F64VECTORprocedure
g2:attach VDEVICE DEVICEprocedure
g2:line DEVICE X1 Y1 X2 Y2procedure
g2:triangle DEVICE X1 Y1 X2 Y2 X3 Y3procedure
g2:filled-triangle DEVICE X1 Y1 X2 Y2 X3 Y3procedure
g2:circle DEVICE X Y Rprocedure
g2:filled-circle DEVICE X Y Rprocedure
g2:rectangle DEVICE X1 Y1 X2 Y2procedure
g2:filled-rectangle DEVICE X1 Y1 X2 Y2procedure
g2:ellipse DEVICE X Y R1 R2procedure
g2:filled-ellipse DEVICE X Y R1 R2procedure
g2:line DEVICE DX DYprocedure
g2:para-3 DEVICE NUM F64VECTORprocedure
g2:para-5 DEVICE NUM F64VECTORprocedure
g2:filled-para-3 DEVICE NUM F64VECTORprocedure
g2:filled-para-5 DEVICE NUM F64VECTORprocedure
g2:plot-qp DEVICE X Yprocedure
g2:query-pointer DEVICEprocedure

Returns X, Y and BUTTON

g2:ps-landconstant
g2:ps-portconstant

Part of enum PS-ORIENTATION

g2:a0constant
g2:a1constant
g2:a2constant
g2:a3constant
g2:a4constant
g2:a5constant
g2:a6constant
g2:a7constant
g2:a8constant
g2:a9constant
g2:b0constant
g2:b1constant
g2:b2constant
g2:b3constant
g2:b4constant
g2:b5constant
g2:b6constant
g2:b7constant
g2:b8constant
g2:b9constant
g2:b10constant
g2:dl-envelopeconstant
g2:c5-envelopeconstant
g2:comm-10-envelopeconstant
g2:folioconstant
g2:executiveconstant
g2:legalconstant
g2:letterconstant
g2:ledgerconstant
g2:tabloidconstant

Part of enum PS-PAPER.

g2:ps-epsfconstant
g2:ps-epsf-clipconstant
g2:ps-post-scriptconstant

Part of enum PS-FORMAT.

g2:open-ps FILENAME PS-PAPER PS-ORIENTATIONprocedure
g2:open-epsf FILENAMEprocedure
g2:open-epsf-clip FILENAME WIDTH HEIGHTprocedure
g2:open-fig FILENAMEprocedure

Return a DEVICE object.

GD integration

If the GD library is installed on your system, the following definitions are available:

g2:gd-jpegconstant
g2:gd-pngconstant

Part of enum GD-TYPE

g2:open-gd FILENAME WIDTH HEIGHT GD-TYPEprocedure

Returns a DEVICE object.

X11 integration

If X11 is available, you can also create X11 Window devices:

g2:open-x11 WIDTH HEIGHTprocedure
g2:open-x11x WIDTH HEIGHT X Y WINDOWNAME ICONNAME U8VECTOR ICONWIDTH ICONHEIGHTprocedure

Both procedures return a DEVICE object.

Example

(require-extension g2 extras)

(define d (g2:open-x11 50 50))
(g2:line d 5 5 45 45)
(g2:circle d 25 25 20)

(let loop ()
  (let-values (((_ _ b) (g2:query-pointer d)))
    (when (< b 256) (loop))))

(g2:close d)

Assorted tips

On Debian and Debian-derived systems (e.g., Ubuntu), you'll need the following packages: libg2-dev and libgd2-xpm-dev

Changelog

License

Copyright (c) 2011, Felix L. Winkelmann
All rights reserved.
 
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:

Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.

Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
 
Neither the name of the author nor the names of its contributors may
be used to endorse or promote products derived from this software
without specific prior written permission.
  
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.

Contents »