Wiki
Download
Manual
Eggs
API
Tests
Bugs
show
edit
history
You can edit this page using
wiki syntax
for markup.
Article contents:
[[tags:egg]] [[toc:]] == ezxdisp === Description A simple graphics library for X11. === Author n-sibata and Morihiko Tamai, packaged for CHICKEN by [[/users/felix winkelmann|felix winkelmann]]. === Repository This egg is hosted on the CHICKEN Subversion repository: [[https://anonymous@code.call-cc.org/svn/chicken-eggs/release/5/ezxdisp|https://anonymous@code.call-cc.org/svn/chicken-eggs/release/5/ezxdisp]] If you want to check out the source code repository of this egg and you are not familiar with Subversion, see [[/egg-svn-checkout|this page]]. === Documentation ezxdisp is a simple graphics library for 2D/3D graphical applications. (The official distribution can be found [[http://morihit.net/ezxdisp/|here]]). ==== Initialize/Finalize a window <procedure>(ezx-init SIZE_X SIZE_Y WINDOW_NAME)</procedure> This procedure returns a {{EZX}} object all other procedures accept. <procedure>(ezx-quit EZX)</procedure> ==== Update the graphics in the window <procedure>(ezx-redraw EZX)</procedure> ==== Erase the graphics in the window/layer <procedure>(ezx-wipe EZX)</procedure> <procedure>(ezx-wipe-layer EZX LAYER)</procedure> {{LAYER}} should be an exact integer between 0 and 8. ==== Get the pointer coordinates <procedure>(ezx-sensebutton EZX)</procedure> Returns the current pointer coordinates as three values: {{BUTTON}}, {{X}} and {{Y}} <procedure>(ezx-pushbutton EZX)</procedure> 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-point-2d EZX X Y COLOR)</procedure> <procedure>(ezx-line-2d EZX X0 Y0 X1 Y1 COLOR WIDTH)</procedure> <procedure>(ezx-lines-2d EZX POINTS COLOR WIDTH)</procedure> <procedure>(ezx-poly-2d EZX POINTS COLOR)</procedure> The {{POINTS}} argument should be an SRFI-4 {{s32vector}} of the form [X1 Y1 ... Xn Yn] where X and Y are the coordinates of each point. <procedure>(ezx-rect-2d EZX X0 Y0 X1 Y1 COLOR WIDTH)</procedure> <procedure>(ezx-fillrect-2d EZX X0 Y0 X1 Y1 COLOR)</procedure> <procedure>(ezx-circle-2d EZX X0 Y0 R COLOR WIDTH)</procedure> <procedure>(ezx-fillcircle-2d EZX X0 Y0 R COLOR)</procedure> <procedure>(ezx-str-2d EZX X0 Y0 STRING COLOR)</procedure> ==== Draw 3D graphics <procedure>(ezx-set-light-3d EZX EX EY EZ)</procedure> <procedure>(ezx-set-view-3d EZX EX EY EZ VX VY VZ M)</procedure> <procedure>(ezx-c3d-to-2d EZX SX SY SZ)</procedure> Returns two values, {{DX}} and {{DY}}. <procedure>(ezx-line-3d EZX X0 Y0 Z0 X1 Y1 Z1 COLOR WIDTH)</procedure> <procedure>(ezx-str-3d EZX X0 Y0 Z0 STRING COLOR)</procedure> <procedure>(ezx-poly-3d EZX POINTS HX HY HZ COLOR)</procedure> <procedure>(ezx-circle-3d EZX X0 Y0 Z0 R COLOR)</procedure> The {{POINTS}} argument should be a SRFI-4 {{f64vector}} containing the X, Y and Z coordinates of each point. ==== Event handling <procedure>(ezx-next-event EZX)</procedure> Removes the next event from the event queue and returns the event-specific information. If there is no event data in the event queue, this function blocks until the next event occurs. The procedure returns 5 values: the type of the event, the X- and Y-coordinates of the mouse pointer at the time of the event, the button- or keyboard-state mask and the button- or key-code of the event. The following variables contain the event-types that may occur: * {{ezx:BUTTON-PRESS}} or {{ezx:BUTTON-RELEASE}} * {{ezx:KEY-PRESS}} or {{ezx:KEY-RELEASE}} * {{ezx:MOTION-NOTIFY}} * {{ezx:CLOSE}} These button-codes are defined: <table> <tr><th>Code</th><th>Button</th></tr> <tr><td>1</td><td>left</td></tr> <tr><td>2</td><td>middle</td></tr> <tr><td>3</td><td>right</td></tr> <tr><td>4</td><td>wheel up</td></tr> <tr><td>5</td><td>wheel down</td></tr> </table> State mask values that may be returned: <table> <tr><th>Mask</th><th>State</th></tr> <tr><td>1</td><td>shift key</td></tr> <tr><td>2</td><td>control key</td></tr> <tr><td>4</td><td>left button</td></tr> <tr><td>8</td><td>middle button</td></tr> <tr><td>16</td><td>right button</td></tr> </table> For keyboard events, some special keys will return a platform independent keycode: <table> <tr><td>Home</td><td>#xff50</td></tr> <tr><td>Left</td><td>#xff51</td></tr> <tr><td>Up</td><td>#xff52</td></tr> <tr><td>Right</td><td>#xff53</td></tr> <tr><td>Down</td><td>#xff54</td></tr> </table> The result values will be undefined for events for which they are not used. This table summarizes what results are valid: <table> <tr><th>Event</th><th>Results</th></tr> <tr><td>ezx:CLOSE</td><td></td></tr> <tr><td>ezx:BUTTON-PRESS ezx:BUTTON-RELEASE</td><td>x, y, state, k/b</td></tr> <tr><td>ezx:KEY-PRESS ezx:KEY-RELEASE</td><td>x, y, state, k/b</td></tr> <tr><td>ezx:MOTION-NOTIFY</td><td>x, y, state</td></tr> </table> ==== Miscellaneous functions <procedure>(ezx-select-layer EZX LAYER)</procedure> Focuses on the layer. <procedure>(ezx-raise-window EZX)</procedure> Raises the window. <procedure>(ezx-window-name EZX STRING)</procedure> Sets a name of the window. <procedure>(ezx-set-background EZX COLOR)</procedure> Sets the background color of the window. ==== Colors <procedure>(make-ezx-color R G B)</procedure> 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 <enscript highlight="scheme"> (import ezxdisp) (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)) (ezx-redraw ezx) (let loop () (let-values (((b _ _) (ezx-pushbutton ezx))) (loop))) (ezx-quit ezx) </enscript> A more elaborate example is in the egg distribution in a file named {{3d_clock.scm}}, which displays an animated 3D-clock. === Changelog * 3.1 Compatibility with GCC 14 [patch by Mario Domenech Goulart] * 3.0 Ported to CHICKEN 5 * 2.9 simplified the API of ezx-lines-2d, ezx-poly-2d, ezx-poly-3d [thanks to Wim Lewis] * 2.5 fixed use of removed {{pointer}} type * 2.4 added {{ezx-resize}} * 2.3 Added win32 support; ezx-next-event always returns 5 values * 2.1 Fixed srfi-4 use issue [reported by Christian Kellermann] * 2.0 Ported to Chicken 4; updated to upstream version 0.1.4 * 1.3 Added {{ezx-event-pending}} * 1.2 Adapted to externalized {{easyffi}} extension * 1.1 {{ezx-set-background}} wasn't documented * 1.0 Initial release === License This program 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 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
Description of your changes:
I would like to authenticate
Authentication
Username:
Password:
Spam control
What do you get when you subtract 3 from 1?