This example found in the ‘antiryadgx/workspaces/fractal/’ directory show how to display pixel on screen by drawing a fractal using the Gel language.
To run this example, launch Antiryad Gx, run the ‘Tools/Execute Gel’ menu and select the file ‘antiryadgx/workspaces/fractal/fractal.gel’.
An other way is to launch the ‘Tools/Text editor’ menu, load the file ‘antiryadgx/workspaces/fractal/fractal.gel’ then launch the ‘Gel/Run’ menu.
Here is the Gel source code of the program (init.gel):
/* ======================================================================= */
/* Fractal example - Copyright (c) Antoine Guillon from Arkham Development */
/* ======================================================================= */
class fractal
import antiryadgx.gx_screen
import antiryadgx.gx_keyboard
import antiryadgx.gx_bitmap
declarefunction nothing,main,nothing
/* ---- */
/* main */
/* ---- */
function main
dim x,y,sizex,sizey,iteration,int
dim cr,ci,zr,zi,oldzr,float
dim winrm,winrn,winim,winin,winr,wini,float
dim deltax,deltay,counterx,countery,float
dim zoom,float
winrm=1.5
winrn=-2.4
winim=1.5
winin=-1.5
winr=winrm-winrn
wini=winim-winin
sizex=gx_screen::getsizex()
sizey=gx_screen::getsizey()
zoom=1.0
/* Infinite frame loop, break when escape key is pressed */
do
deltax=zoom/sizex
deltay=zoom/sizey
countery=0.4273-(zoom/2.34)
/* Y lines loop */
for(y,0,<,sizey,1)
counterx=0.4273-(zoom/2.34)
/* X pixels loop */
for(x,0,<,sizex,1)
iteration=0
cr=((counterx*winr)-2.4)
zr=cr
ci=((countery*wini)-1.5)
zi=ci
/* Iterations loop, 32 maximum */
do
if(iteration,>=,31)
break
elseif((zi*zi)+(zr*zr),>,4.0)
break
endif
iteration+=1
oldzr=zr
zr=(zr*zr)-(zi*zi)+cr
zi=(2.0*zi*oldzr)+ci
loopwhile(1,==,1)
/* Draw one pixel result to screen, 2d color format are in 16 bits rrrrrggggggbbbbb */
/* Here, we use only 5 bits of color component (32 values maximum) */
gx_screen::setpixel(x,y,iteration<1,iteration<2,iteration<3)
counterx+=deltax
next
/* Flush video buffer to screen once per 8 lines drawn */
if(y&0x7,==,7)
gx_screen::flush()
if(gx_keyboard::inkey(),==,gx_keyboard_keyesc)
return(0)
endif
endif
countery+=deltay
next
zoom/=1.1
loopwhile(1,==,1)
return(0)
endfunction