Outdated egg!

This is an egg for CHICKEN 3, the unsupported old release. You're almost certainly looking for the CHICKEN 4 version of this egg, if it exists.

If it does not exist, there may be equivalent functionality provided by another egg; have a look at the egg index. Otherwise, please consider porting this egg to the current version of CHICKEN.

ezxdisp

  1. Outdated egg!
  2. ezxdisp
    1. Description
    2. Author
    3. Requirements
    4. Download
    5. Documentation
      1. Initialize/Finalize a window
      2. Update the graphics in the window
      3. Erase the graphics in the window/layer
      4. Get the pointer coordinates
      5. Draw 2D graphics
      6. Draw 3D graphics
      7. Miscellaneous functions
      8. Colors
    6. Examples
    7. Changelog
    8. License

Description

A simple graphics library for X11.

Author

n-sibata and Morihiko Tamai, packaged for CHICKEN by felix winkelmann.

Requirements

Requires the easyffi egg.

Download

ezxdisp.egg

Documentation

ezxdisp is a simple graphics library for 2D/3D graphical applications. (The official distribution can be found here).

Initialize/Finalize a window

[procedure] (ezx-init SIZE_X SIZE_Y WINDOW_NAME)

This procedure returns a EZX object all other procedures accept.

[procedure] (ezx-quit EZX)

Update the graphics in the window

[procedure] (ezx-redraw EZX)

Erase the graphics in the window/layer

[procedure] (ezx-wipe EZX)
[procedure] (ezx-wipe-layer EZX LAYER)

LAYER should be an exact integer between 0 and 8.

Get the pointer coordinates

[procedure] (ezx-sensebutton EZX)

Returns the current pointer coordinates as three values: BUTTON, X and Y

[procedure] (ezx-pushbutton EZX)

Block until an event is received. Returns three values: BUTTON, X and Y

The BUTTON result is 1, 2 or 3 for the first, second and third mouse button, respectively. The button number is additionally bitwise OR'd with 8 if the shift key is pressed and with 16 if the control key is pressed.

Draw 2D graphics

[procedure] (ezx-line-2d EZX X0 Y0 X1 Y1 COLOR WIDTH)
[procedure] (ezx-circle-2d EZX X0 Y0 R COLOR WIDTH)
[procedure] (ezx-fillcircle-2d EZX X0 Y0 R COLOR WIDTH)
[procedure] (ezx-str-2d EZX X0 Y0 STRING COLOR)
[procedure] (ezx-fillrect-2d EZX X0 Y0 X1 Y1 COLOR)

Draw 3D graphics

[procedure] (ezx-set-light-3d EZX EX EY EZ)
[procedure] (ezx-set-view-3d EZX EX EY EZ VX VY VZ M)
[procedure] (ezx-c3d-to-2d EZX SX SY SZ)

Returns two values, DX and DY.

[procedure] (ezx-line-3d EZX X0 Y0 Z0 X1 Y1 Z1 COLOR WIDTH)
[procedure] (ezx-str-3d EZX X0 Y0 Z0 STRING COLOR WIDTH)
[procedure] (ezx-poly-3d EZX POINTS HX HY HZ N COLOR)
[procedure] (ezx-circle-3d EZX X0 Y0 Z0 R COLOR)

The POINTS argument should be a SRFI-4 f64vector containing X, Y and Z coordinates.

Miscellaneous functions

[procedure] (ezx-select-layer EZX LAYER)

Focuses on the layer.

[procedure] (ezx-raise-window EZX)

Raises the window.

[procedure] (ezx-window-name EZX STRING)

Sets a name of the window.

[procedure] (ezx-set-background EZX COLOR)

Sets the background color of the window.

Colors

[procedure] (make-ezx-color R G B)

This procedure returns a "color object", which is internally encoded as a f64vector. The red, green and blue components should be between 0 and 1.

Examples

(define ezx (ezx-init 100 100 "Hello, ezxdisp"))
(ezx-set-background ezx (make-ezx-color 1 1 1))
(ezx-fillcircle-2d ezx 50 50 25 (make-ezx-color 1 0 0) 1)
(ezx-redraw ezx)

(let loop ()
  (let-values ([(b _ _) (ezx-pushbutton ezx)])
    (when (zero? b) (loop)) ) )

(ezx-quit ezx)

A more elaborate example is in the egg distribution in a file named 3d_clock.scm, which displays an animated 3D-clock.

Changelog

License

 This program 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 2 of the License, or
 (at your option) any later version.
 
 This program 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 this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA