simple display (from: GUI library for D)

bearophile bearophileHUGS at lycos.com
Sat Apr 9 15:58:47 PDT 2011


Adam D. Ruppe:

> Here's the D version using the direct to screen functions.

On Windows Vista the window often doesn't close when I hit the close window click at the top right.

Probably quite more people will have to comment and think about this module and its API before adopting it.

The length=150 too is better to be set as immutable. Most of the auto variables (but "painter") are better set to immutable.

The delegate inside eventLoop doesn't need the ().

Color(255, 255, 255) ==> Color.white
Color(0, 0, 0) ==> Color.black

painter.drawRectangle(0, 0, win.width, win.height) painter.clearAll(), or painter.clearAll(Color.white) or something similar.

auto win = new SimpleWindow(512, 512);
==>
auto win = new SimpleWindow(512, 512, "Pendulum");

win.eventLoop(10, {...})  does this semantics work with more than one window too?

        auto painter = win.draw();
        painter.fillColor = Color(255, 255, 255);
==> sometimes a bit better:
        auto painter = win.draw();
        with (painter) {
            fillColor = ...
            ...

drawRectangle => rectangle or even "box"
drawLine ==> line
drawEllipse ==> ellipse
circle
fillColor ==> filling?
outline => pen?


> This struct is necessary to handle some state
> and cleanup that the native APIs require.

This is not so nice...


> I agree with what Michel said earlier about it being a lot of
> fairly pointless effort to go further than this.

Reading keyboard chars, and mouse clicks & movements is very useful.
Another useful thing is to plot a matrix of rgb or int or ubyte in grey shades, to speed up some basic usage. In PyGame/Numpy there is surfarray for this.

Bye,
bearophile


More information about the Digitalmars-d mailing list