Home /Examples/examples/gui/COMPONENT-canvas-view.sleela

COMPONENT-canvas-view.sleela

examples/gui/COMPONENT-canvas-view.sleela · 19 line(s) · sleela

#sleela 2.5
// CanvasView is the animated drawing surface. A draw handler must be bound
// by the host/VM using the documented draw-handler ordinal contract.
class CanvasViewSurface {
  int main() {
    SLUserInterface ui = new SLUserInterface(); ui.configure("com.mearvk.examples.CanvasView");
    if (!ui.open()) { return 1; }
    SLTheme theme = new SLTheme(); theme.defaultTheme();
    SLWindow win = ui.openWindow("Canvas View Surface", 640, 420, theme.handle());
    SLWidget root = win.rootWidget();
    SLBox col = new SLBox(); col.vertical(root, 12); col.setMarginAll(18);
    SLHeading heading = new SLHeading(); heading.createIn(col, "Animated canvas", 22);
    SLCanvasView canvas = new SLCanvasView(); canvas.createIn(col, 560, 260);
    canvas.setFps(30.0);
    SLLabel note = new SLLabel(); note.createIn(col, "Canvas created at 560 x 260, target 30 FPS. Drawing requires a host-bound draw handler.");
    win.show(); return ui.run();
  }
}