This reminds me a bit of my proof-of-concept project called fpBASCON which is a BASIC to Pascal translator. Using the SDL based game engine I wrote one can do something like this (simple mandelbrot):
Code:
IMPORT egslengine
DIM x, y, c, pow,time1,time2 AS integer
DIM a, b, z, a2, b2, x2, y2, przesx, przesy, przelx, przely AS real
MAIN
openwindow (800,600,32,"Mandelbrot")
backcolour (0,0,0)
drawtext (0, 20, "MANDELBROT SET")
drawtext (0, 40, "Press any key to start.")
redraw
inkey
clearscreen
time1=timerticks()
pow = 1
przesx = 0
przesy = 0
przelx = 3 / (800 * pow)
przely = 2 / (600 * pow)
FOR x = 0 TO 799
FOR y = 0 TO 599
a = 0
b = 0
c = 0
x2 = (przelx * (x + (przesx * pow))) - 2
y2 = (przely * (y + (przesy * pow))) - 1
WHILE c < 255
a2 = a * a - b * b
b2 = 2 * a * b
a = a2 + x2
b = b2 + y2
z = a * a + b * b
IF z >= 4 THEN
BREAK
END IF
c = c + 1
WEND
IF c = 50 THEN
colour (0, 0, 0)
ELSE
colour (255 - c, 255 - c, 255 - c)
END IF
dot (x, y)
NEXT
redraw
NEXT
time2=timerticks()
colour (0,0,0)
drawtext (0,0,STR$(time2-time1)+" ms")
redraw
inkey
closewindow
With the keyword IMPORT one can include all fpc units. All keywords are in uppercase, procedures and functions from the used units are in lowercase.
Bookmarks