ex11, plotting and Cairo ...

Vlad Dumitrescu vlad_dumitrescu@REDACTED
Wed Jul 20 11:29:01 CEST 2005


----- Original Message ----- 
From: "Joe Armstrong (AL/EAB)" <joe.armstrong@REDACTED>
> I see things the problem is more one of "programming models" than making
> an Erlang interface to X (replace X by your favourite package).

Hi,

As I've also been struggling with this, I'd like to throw in my two cents.

About programming models: One important feature of an Ernalg graphics 
package would be (for me) that it is "erlangish", and doesn't force me to 
use C-like code. A good example of what I mean is ex11, but one reason why 
it works so easily is that X itself works just like we want it to. Making a 
regular graphics package work like that is much harder.

> One thing I did find was that the only model I like is based on a canvas
> widget. To create buttons (and controls in general) I just draw rectangles 
> and lines
> onto a canvas widget and animate them on mouse clicks.

That's what all toolkits do :-) If an "erlang programming model" is to be 
enforced, then this is probably the only way, to use external code for the 
low-level drawing.

> << aside - why can't we just define a low-level API and then layer 
> graphics
> on top of this. The low level could be implemented using your favorite 
> package.
>
>      The following API would suffice
>
> mkWin(X, Y, Width, Ht) => Win
> draw(Win, rectangle, X, Y, Width, Ht, Color) => Tag
> draw(Win, line, X1, Y1, X2, Y2, Width, Color) => Tag
> draw(Win, text, X, Y, Font, Size, Text) => Tag
> draw(Win, image, X, Y, ImageFile) => Tag
> ...
> add_event_handler(Win, X, Y, Width, Ht, mouse_click, Fun) => Tag
> delete(Win, Tag) => true
>
> So you can create a window (mkWin) - draw things (draw) - add event 
> handlers
> and deleted tagged things.
>
> Given this (or something like this) then pretty fancy applications can be 
> layered on
> top of this.
> >>

First of all, agreeing on an API isn't easy at all! ;-)

That said, I think the problem is that once the basic functionality is in 
place, one will want to add more features. In this day and age, nobody will 
want to use a GUI that looks like Windows 1.0... So the API should be able 
to take in new functionality without breaking. A suggestion for such an API 
is the PS/PDF model.

One backend that is reasonably stable, reasonably portable and lends itself 
to advanced graphics use is OpenGL. Esdl is a good start, just look at 
Wings. The only drawback is that SDL only supports one top-level window, but 
I know that Dan and the esdl team are working on something.

best regards,
Vlad




More information about the erlang-questions mailing list