Note: This is taken from the Chicken Wiki, where a more recent version could be available.

g2

Description

An interface to the g2 graphics library.

Author

felix winkelmann

Requirements

easyffi

Download

g2.egg

Documentation

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

<constant>qpcirc</constant> <constant>qprect</constant>

Part of enum QPSHAPE.

<procedure>(g2:poly-line DEVICE NUM F64VECTOR)</procedure> <procedure>(g2:set-background DEVICE COLOR)</procedure> <procedure>(g2:arc DEVICE X Y R1 R2 A1 A2)</procedure> <procedure>(g2:filled-arc DEVICE X Y R1 R2 A1 A2)</procedure>

<procedure>(g2:ld DEVICE)</procedure>

(returns LD)

<procedure>(g2:set-ld DEVICE)</procedure> <procedure>(g2:string DEVICE X Y STRING)</procedure> <procedure>(g2:set-qp DEVICE D QPSHAPE)</procedure> <procedure>(g2:set-coordinate-system DEVICE XORIGIN YORIGIN XMUL YMUL)</procedure> <procedure>(g2:set-dash DEVICE NUM F64FECTOR)</procedure> <procedure>(g2:close DEVICE)</procedure> <procedure>(g2:move-r DEVICE DX DY)</procedure> <procedure>(g2:line-to DEVICE X Y)</procedure> <procedure>(g2:pen DEVICE COLOR)</procedure> <procedure>(g2:flush DEVICE)</procedure> <procedure>(g2:set-line-width DEVICE WIDTH)</procedure> <procedure>(g2:clear DEVICE)</procedure> <procedure>(g2:set-auto-flush DEVICE BOOL)</procedure> <procedure>(g2:allocate-basic-colors DEVICE)</procedure> <procedure>(g2:image DEVICE X Y XSIZE YSIZE S32VECTOR)</procedure> <procedure>(g2:detach VDEVICE DEVICE)</procedure> <procedure>(g2:polygon DEVICE NUM F64VECTOR)</procedure> <procedure>(g2:filled-polygon DEVICE NUM F64VECTOR)</procedure>

<procedure>(g2:open-vd)</procedure>

Returns a VDEVICE

<procedure>(g2:plot DEVICCE X Y)</procedure> <procedure>(g2:reset-palette DEVICE)</procedure> <procedure>(g2:clear-palette DEVICE)</procedure> <procedure>(g2:spline DEVICE NUM F64VECTOR O)</procedure> <procedure>(g2:b-spline DEVICE NUM F64VECTOR O)</procedure> <procedure>(g2:filled-spline DEVICE NUM F64VECTOR O)</procedure> <procedure>(g2:filled-b-spline DEVICE NUM F64VECTOR O)</procedure> <procedure>(g2:set-font-size DEVICE SIZE)</procedure> <procedure>(g2:plot-r DEVICE DX DY)</procedure> <procedure>(g2:save DEVICE)</procedure> <procedure>(g2:move DEVICE X Y)</procedure>

<procedure>(g2:ink DEVICE RED GREEN BLUE)</procedure>

Returns a COLOR

<procedure>(g2:raspln DEVICE NUM F64VECTOR)</procedure> <procedure>(g2:filled-raspln DEVICE NUM F64VECTOR)</procedure> <procedure>(g2:attach VDEVICE DEVICE)</procedure> <procedure>(g2:line DEVICE X1 Y1 X2 Y2)</procedure> <procedure>(g2:triangle DEVICE X1 Y1 X2 Y2 X3 Y3)</procedure> <procedure>(g2:filled-triangle DEVICE X1 Y1 X2 Y2 X3 Y3)</procedure> <procedure>(g2:circle DEVICE X Y R)</procedure> <procedure>(g2:filled-circle DEVICE X Y R)</procedure> <procedure>(g2:rectangle DEVICE X1 Y1 X2 Y2)</procedure> <procedure>(g2:filled-rectangle DEVICE X1 Y1 X2 Y2)</procedure> <procedure>(g2:ellipse DEVICE X Y R1 R2)</procedure> <procedure>(g2:filled-ellipse DEVICE X Y R1 R2)</procedure> <procedure>(g2:line DEVICE DX DY)</procedure> <procedure>(g2:para-3 DEVICE NUM F64VECTOR)</procedure> <procedure>(g2:para-5 DEVICE NUM F64VECTOR)</procedure> <procedure>(g2:filled-para-3 DEVICE NUM F64VECTOR)</procedure> <procedure>(g2:filled-para-5 DEVICE NUM F64VECTOR)</procedure> <procedure>(g2:plot-qp DEVICE X Y)</procedure>

<procedure>(g2:query-pointer DEVICE)</procedure>

Returns X, Y and BUTTON

<constant>g2:ps-land</constant> <constant>g2:ps-port</constant>

Part of enum PS-ORIENTATION

<constant>g2:a0</constant> <constant>g2:a1</constant> <constant>g2:a2</constant> <constant>g2:a3</constant> <constant>g2:a4</constant> <constant>g2:a5</constant> <constant>g2:a6</constant> <constant>g2:a7</constant> <constant>g2:a8</constant> <constant>g2:a9</constant> <constant>g2:b0</constant> <constant>g2:b1</constant> <constant>g2:b2</constant> <constant>g2:b3</constant> <constant>g2:b4</constant> <constant>g2:b5</constant> <constant>g2:b6</constant> <constant>g2:b7</constant> <constant>g2:b8</constant> <constant>g2:b9</constant> <constant>g2:b10</constant> <constant>g2:dl-envelope</constant> <constant>g2:c5-envelope</constant> <constant>g2:comm-10-envelope</constant> <constant>g2:folio</constant> <constant>g2:executive</constant> <constant>g2:legal</constant> <constant>g2:letter</constant> <constant>g2:ledger</constant> <constant>g2:tabloid</constant>

Part of enum PS-PAPER.

<constant>g2:ps-epsf</constant> <constant>g2:ps-epsf-clip</constant> <constant>g2:ps-post-script</constant>

Part of enum PS-FORMAT.

<procedure>(g2:open-ps FILENAME PS-PAPER PS-ORIENTATION)</procedure> <procedure>(g2:open-epsf FILENAME)</procedure> <procedure>(g2:open-epsf-clip FILENAME WIDTH HEIGHT)</procedure> <procedure>(g2:open-fig FILENAME)</procedure>

Return a DEVICE object.

GD integration

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

<constant>g2:gd-jpeg</constant> <constant>g2:gd-png</constant>

Part of enum GD-TYPE

<procedure>(g2:open-gd FILENAME WIDTH HEIGHT GD-TYPE)</procedure>

Returns a DEVICE object.

X11 integration

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

<procedure>(g2:open-x11 WIDTH HEIGHT)</procedure> <procedure>(g2:open-x11x WIDTH HEIGHT X Y WINDOWNAME ICONNAME U8VECTOR ICONWIDTH ICONHEIGHT)</procedure>

Both procedures return a DEVICE object.

Example

<example> <init>(require-extension g2)</init> <expr> (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) </expr> </example>

Changelog

License

 Copyright (c) 2005, 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.