ex11, plotting and Cairo ...
Joe Armstrong (AL/EAB)
Wed Jul 20 13:47:45 CEST 2005
Vlad Dumitrescu wrote
> From: "Joe Armstrong (AL/EAB)" <>
> > I see things the problem is more one of "programming
> models" than making
> > an Erlang interface to X (replace X by your favourite package).
> 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! ;-)
Why not? - given the above I can program a wide range of apps.
Much better to have a stable well defined low-level than nothing.
Actually to make a "drop-dead-beautiful" interface all I need is
anti-aliased fonts and alpha-blending of all display objects.
If we could agree on a set of stable cross-platform low-level primitives
then life would be much easier.
> 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.
YES * 10000 - Then I could take my erlguten code and put it into the GUIs
proper kerning and ligatures in the text in the menus!!!
> 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.
Go Dan, go ...
> best regards,
More information about the erlang-questions