shingles.net.nz

Shingles Consulting

graphex.ew


graphex simple graphics library for win32lib
 
Euphoria Page
This page has moved. Redirecting in 5 seconds. If that doesn't work, click here

graphex.ew is a Euphoria language library for drawing simple double buffered line oriented graphics and images in a win32lib program.

 
>> with canvas
gcanvas.ew is a graphex based canvas (scrollable object management).

Screenshots:

LINKS

win32lib - the current cornerstone of my interest in Euphoria


Euphoria - the best RAD language I've seen in a long time, and it has been around a long time ... another gem :)


EXAMPLES
(bound versions not in archive )

Depending on what kind of security you are running you may or may not be able to run or download these.

demo1-simple src
demo2-shapes src
demo3-asteroid src
source of demo4
demo5-sizing src

 


The name "graphex" is both a play on the word "graphics" and an indication of the "Ex"-ness of the functionality this provides on top of win32lib (eg like createEx, etc)


graphex.ew is released under the same terms as win32lib.
Copyright (c) 2006 Gary Shingles


graphex.ew
The idea behind graphex.ew is to create a 'pseudo control' in a win32lib program which maintains its own double buffered drawing, event handling, and geometry management1.

Synopsis:

integer gfx -- image stored in a 'gfx' sequence
-- assume Window1 created big enough for a 600x400 gfx
gfx = newGfx(Window1, 0, 0, 600, 400)
-- create a gfx in the window
gfx_draw(gfx, GP_ELLIPSE_SOLID, Red, {0, 0, 600, 400})
-- draw a big red solid ellipse the size of the gfx
gfxTextOutAt(gfx, 320, 240, "Euphoria", BrightWhite)

-- write "Euphoria" (near) the middle of the ellipse
-- in the default line font.

Now whatever else you add to the window, the graphic will look after itself. You can either rely on it to display anything else you draw later on, or update the whole thing first and call the drawing routine whenever you like.


gcanvas.ew
The idea behind a graphex canvas is to allow a much larger graphex to be viewed through a smaller "view port" with scroll bars etc. You can attach events to to the canvas, and add a basic dot grid.
 
Synopsis:
 
integer canvas,  -- id of canvas to be created
        object1_id, -- id of object 1
        object2_id -- id of object 2
canvas = newGfxCanvas(Window1, 0, 0, 100, 100) -- create a canvas at 0,0 in (win32lib id) Window1 of size 100 x 100 pixels
 
-- add a 30x30 green gfx rectangle outline at 10, 10
object1_id = gfxCanvasAddObject(canvas, 10, 10, Green, GP_RECT, {10, 10, 40, 40})
 
-- add a 50x50 blue solid rectangle off the canvas (scroll bars will appear unless suppressed)
object2_id = gfxCanvasAddObject(canvas, 150, 150, Blue, GP_RECT_SOLID, {150, 150, 200, 200})
 
drawGfxCanvas(canvas) -- make it show
 
As an extenstion to graphex the documentation is referenced from below and its development will probably remain linked to the graphex system itself.

Documentation

Download
graphex.zip v0.10.5 27-Dec-2006 814,867 bytes changelog

previous version 0.10.0 24-June-2006 78,881 bytes

SCREENSHOT:
Demo #4:
wave form display using the shape system, lines, and font.


1. By "geometry management" I mean, using gfx_draw(...) at {10, 10} always means {10,10} in the image. Coordinates from a mouse event of {10,10} always means {10,10} in the image, etc. Eg in Demo4 above, the three coloured areas are made up of three gfx objects, so drawing the waveforms is much easier. Point it to the starting point and let the gfx_draw(.."shape") draw it.

graphex.ew
Demo #1: Stepwise demonstration of the system and a brief overview of its drawing capabilities.

graphex.ew
Demo #2:
The "shape" pen based system

graphex.ew
Demo #7:
Updated "Asteroids"-type game using images, mouse events, and crude bounding-box collision detection.

gcanvas.ew
Canvas Demo: A simple canvas with random objects and scroll bars.

Content Copyright © 2006 Gary Shingles