This is is more me thinking out loud, rather than a coherently thought through analysis, so you'll have to either bear with me, or move along.
Update: Please also see Re^2: The browser as a (simple) window manager. for what I hope will be a clearer explanation of what I'm looking for and proposing.
I plot a lot of graphs. Not 'pretty' graphs to impress customers, vulture capatalists or web2.0reaers, but simply points and lines and blobs as a means of visualising data. For the most part GD (not even GD::Graph), output to a file and viewed in an image viewer, serves my needs. But every now and again I have a need for something interactive.
Something whereby I can either tweak a few parameters via UI and have it re-plot as I do so; or put it into a loop and watch as the exploration unfolds. Perhaps tweaking settings as it continues.
In the past I've (pretty unsuccessfully) done this using Tk. Programming Tk is a pain of digging around trying to find the appropriate piece of documentation, or someone who knows how to do what you want. Also, the architecture of the Tk.Canvas is such that it is all too easy to fill memory with unwanted graphics objects. I did post a thread here trying to find an efficient way of throwing an image onto the screen, so that I could do the drawing using GD and just update the screen with the image every 30th of second or so, but the Tk's inability to accept an image in raw binary makes that a non-starter. Forcing me to convert the raw image into base64, so that it can convert it back is just symptomatic of the whole architecture.
Besides, the whole inverted control flow of global state with callbacks and throw it into an event loop, is just such a pain to program. Which neatly deals with Win32::GUI and other similar windowing toolkits.
I've done a little with OpenGL, which is nice when it works, but as often as not it will suddenly present you with a blank screen for no apparent reason, despite that the program is still running; or just crash. The documentation leaves a lot to be desired and the denizens of the few sources of help are so full of themselves that you might just as well ask if any of them would like to offer up their mothers & daughters for some kind of black magic ritual, as dare to ask if any of them use OpenGL on windows. The reaction wouldn't be less hostile I'm sure.
I've looked at the graphics capabilities of PDL, which are extensive and probably fast; but there is so much of it, and the documentation is so scattered, disjointed and couched in lingo-isms--both PDL specific; and pure math oriented--that working out how to simply draw a few pixels, lines or circles and put the results on screen seems to require a higher math degree and several months deep immersion in PDL itself, before you can do anything.
Besides, both of these are overkill for my needs.
Of course there are other language options Java and Swing; or ActionScript and Flash; or Silverlight; or C++ and AWT; or C#; etc. But we all know why we use Perl, and that excludes those for the same reasons.
Recently, my thoughts have been turning towards HTML5 and the new Canvas control. This seems to support all the functionality I would ever need; and with sufficient performance in modern browsers. But, I'm not interested in running a web-server; or programming to the HTTP connectionless model or via the CGI interface. (CGI will have to be there to some degree, but bear with me!)
The thought, as far as it goes, it relatively simple.
You call a API passing in a static html page containing the 'view area' canvas and whatever other controls that sit around it, and references to a bunch of shared variables to receive the values produced by those controls. That api starts a thread, which creates a listening socket; it then invokes the browser with a localhost:portnum "url", and feeds it the html page plus just enough javascript to cause changes to the controls to be sent (via XMLhttprequests?) back to the socket, where the listener uses them to update the shared variables. The javascript would also poll the listener for updates to the displayed image.
The calling code simply uses the values of the shared variables in its calculations as it needs them and updates the image as and when needed.
And that, as they say, is all he wrote. The main program just loops around drawing whatever it is drawing, using the user modifiable, shared values in its calculations, and periodically updating the (shared?) image. The thread talks to the browser, accepting modifications to the shared variables and sending the updated image when requested.
It's easy to see many ways this simple model can be improved. For example, a simple differencing of the old and new images might be used to cut down the volume of image data that needs to be transferred. But such things are far less critical when both 'server' and browser are communicating within the same box.
Anyway, that's about as far as the thought goes for now. This meditation is to ask:
Note: I'm not looking to write a dynastic suite of modules; nor a 3D shoot'em up toolkit; nor an all singin'n'dancing browser application framework; nor a high-def image editor or high-quality graphing tool. Just a simple way of putting some basic graphics on the screen and updating them in real time.
I'll be writing this for my purposes, but if there is anyone with HTML5/Canvas/Javascript/XMLHttpRequest skills that can help me put together the minimal requirements for this purpose, it would be very helpful.
|
|---|