[Grace-core] Grace Graphics API?

Michael Homer mwh at ecs.vuw.ac.nz
Thu May 23 00:13:05 PDT 2013


On Thu, May 23, 2013 at 6:55 PM, James Noble <kjx at ecs.vuw.ac.nz> wrote:
> On 22/05/2013, at 23:46 PM, Michael Homer <Michael.Homer at ecs.vuw.ac.nz> wrote:
>> No it doesn't, it uses a canvas, which is implicitly double-buffered.
>> The GTK one isn't, but it could be (patches welcome!). See
>> sample/js/simplegraphics.grace and grace-gtk:simplegraphics.grace. The
>> actual API is fundamentally the same up to spelling. There are no
>> elements added and it does the drawing itself.
>
> the simplegraphics API surely is retained: in the GTK version the simplegraphics
> module itself maintains a display list ("instructions") that is drawn by the module in response to
> "draw" events; there doesn't seem to be a "clear" command but there could be....
>
> The JS api (again, I assume) just adds things to the canvas (OK so they're not DOM "elements"?
> or am I missing something?)   but doesn't have to worry about redrawing
> (or, again, about clearing)
It paints onto the canvas, using a fairly standard 2D drawing API that
maps almost directly onto Cairo, which is what GTK uses. There are no
elements and no adding, but it is double-buffered, so it survives
being obscured. There's no reason you couldn't have the GTK version
paint onto an off-screen pixbuf and then the draw event handler just
paint that pixbuf onto the DrawingArea; I just didn't do that.

The problems of interaction and starting the synchronous event loop
remain though.
-Michael


More information about the Grace-core mailing list