source: project/wiki/eggref/4/ezxdisp @ 14802

Last change on this file since 14802 was 14802, checked in by Ivan Raikov, 11 years ago

added information about event handling procedure to ezxdisp
documentation

File size: 5.5 KB
Line 
1[[tags: egg]]
2
3== ezxdisp
4
5[[toc:]]
6
7=== Description
8
9A simple graphics library for X11.
10
11=== Author
12
13n-sibata and Morihiko Tamai, packaged for CHICKEN by [[/users/felix
14winkelmann|felix winkelmann]].
15
16=== Requirements
17
18[[easyffi]]
19
20=== Download
21
22[[http://www.call-with-current-continuation.org/eggs/ezxdisp.egg|ezxdisp.egg]]
23
24=== Documentation
25
26ezxdisp is a simple graphics library for 2D/3D graphical applications.
27(The official distribution can be found [[http://mimi.aist-nara.ac.jp/~morihi-t/ezxdisp|here]]).
28
29==== Initialize/Finalize a window
30
31<procedure>(ezx-init SIZE_X SIZE_Y WINDOW_NAME)</procedure>
32
33This procedure returns a {{EZX}} object all other procedures accept.
34
35<procedure>(ezx-quit EZX)</procedure>
36
37==== Update the graphics in the window
38
39<procedure>(ezx-redraw EZX)</procedure>
40
41==== Erase the graphics in the window/layer
42
43<procedure>(ezx-wipe EZX)</procedure>
44<procedure>(ezx-wipe-layer EZX LAYER)</procedure>
45
46{{LAYER}} should be an exact integer between 0 and 8.
47
48==== Get the pointer coordinates
49
50<procedure>(ezx-sensebutton EZX)</procedure>
51
52Returns the current pointer coordinates as three values:
53{{BUTTON}}, {{X}} and {{Y}}
54
55
56<procedure>(ezx-pushbutton EZX)</procedure>
57
58Block until an event is received.  Returns three values:
59{{BUTTON}}, {{X}} and {{Y}}
60
61The BUTTON result is 1, 2 or 3 for the first, second and third mouse
62button, respectively. The button number is additionally bitwise OR'd
63with 8 if the shift key is pressed and with 16 if the control key is
64pressed.
65
66==== Draw 2D graphics
67
68<procedure>(ezx-point-2d EZX X Y COLOR)</procedure>
69<procedure>(ezx-line-2d EZX X0 Y0 X1 Y1 COLOR WIDTH)</procedure>
70<procedure>(ezx-lines-2d EZX POINTS NPOINTS COLOR WIDTH)</procedure>
71<procedure>(ezx-poly-2d EZX POINTS NPOINTS COLOR)</procedure>
72
73The {{POINTS}} argument should be an SRFI-4 {{s32vector}} containing
74the X and Y coordinates of each point.
75
76<procedure>(ezx-rect-2d EZX X0 Y0 X1 Y1 COLOR WIDTH)</procedure>
77<procedure>(ezx-fillrect-2d EZX X0 Y0 X1 Y1 COLOR)</procedure>
78<procedure>(ezx-circle-2d EZX X0 Y0 R COLOR WIDTH)</procedure>
79<procedure>(ezx-fillcircle-2d EZX X0 Y0 R COLOR)</procedure>
80<procedure>(ezx-str-2d EZX X0 Y0 STRING COLOR)</procedure>
81
82==== Draw 3D graphics
83
84<procedure>(ezx-set-light-3d EZX EX EY EZ)</procedure>
85<procedure>(ezx-set-view-3d EZX EX EY EZ VX VY VZ M)</procedure>
86
87<procedure>(ezx-c3d-to-2d EZX SX SY SZ)</procedure>
88
89Returns two values, {{DX}} and {{DY}}.
90
91<procedure>(ezx-line-3d EZX X0 Y0 Z0 X1 Y1 Z1 COLOR WIDTH)</procedure>
92<procedure>(ezx-str-3d EZX X0 Y0 Z0 STRING COLOR)</procedure>
93<procedure>(ezx-poly-3d EZX POINTS HX HY HZ N COLOR)</procedure>
94<procedure>(ezx-circle-3d EZX X0 Y0 Z0 R COLOR)</procedure>
95
96The {{POINTS}} argument should be a SRFI-4 {{f64vector}} containing
97the X, Y and Z coordinates of each point.
98
99==== Event handling
100
101<procedure>(ezx-next-event EZX)</procedure>
102
103Removes the next event from the event queue and returns the
104event-specific information.  If there is no event data in the event
105queue, this function blocks until the next event occurs. The procedure
106returns the type of the event, followed by several event-specific
107values. Depending on the type of the event, the following values can
108be returned:
109
110; {{ezx:BUTTON_PRESS}} or {{ezx:BUTTON_RELEASE}}: the returned values are
111  {{(TYPE X Y STATE BUTTON)}}
112; {{ezx:KEY_PRESS}} or {{ezx:KEY_RELEASE}}: the returned values are
113  {{(TYPE X Y STATE KEY)}}
114; {{ezx:MOTION_NOTIFY}}: the returned values are
115  {{(TYPE X Y STATE)}}
116; {{ezx:CLOSE}}: the returned values are
117  {{(TYPE)}}
118
119<procedure>(ezx-event-pending EZX)</procedure>
120
121Returns true if events are pending, false otherwise.
122
123==== Miscellaneous functions
124
125<procedure>(ezx-select-layer EZX LAYER)</procedure>
126
127Focuses on the layer.
128
129<procedure>(ezx-raise-window EZX)</procedure>
130
131Raises the window.
132
133<procedure>(ezx-window-name EZX STRING)</procedure>
134
135Sets a name of the window.
136
137<procedure>(ezx-set-background EZX COLOR)</procedure>
138
139Sets the background color of the window.
140
141==== Colors
142
143<procedure>(make-ezx-color R G B)</procedure>
144
145This procedure returns a "color object", which is internally encoded
146as a {{f64vector}}. The red, green and blue components should
147be between 0 and 1.
148
149=== Examples
150
151<examples><example>
152<expr>
153(define ezx (ezx-init 100 100 "Hello, ezxdisp"))
154(ezx-set-background ezx (make-ezx-color 1 1 1))
155(ezx-fillcircle-2d ezx 50 50 25 (make-ezx-color 1 0 0) 1)
156(ezx-redraw ezx)
157
158(let loop ()
159  (let-values ([(b _ _) (ezx-pushbutton ezx)])
160    (when (zero? b) (loop)) ) )
161
162(ezx-quit ezx)
163</expr>
164</example></examples>
165
166A more elaborate example is in the egg distribution in a file named
167{{3d_clock.scm}}, which displays an animated 3D-clock.
168
169=== Changelog
170
171* 2.0 Ported to Chicken 4; updated to upstream version 0.1.4
172* 1.3 Added {{ezx-event-pending}}
173* 1.2 Adapted to externalized {{easyffi}} extension
174* 1.1 {{ezx-set-background}} wasn't documented
175* 1.0 Initial release
176
177=== License
178
179  This program is free software; you can redistribute it and/or modify
180  it under the terms of the GNU General Public License as published by
181  the Free Software Foundation; either version 2 of the License, or
182  (at your option) any later version.
183 
184  This program is distributed in the hope that it will be useful,
185  but WITHOUT ANY WARRANTY; without even the implied warranty of
186  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
187  GNU General Public License for more details.
188 
189  You should have received a copy of the GNU General Public License
190  along with this program; if not, write to the Free Software
191  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
192
Note: See TracBrowser for help on using the repository browser.