meo-skia-canvas
    Preparing search index...

    Class Window

    An on-screen window displaying a Canvas, with mouse and keyboard events delivered as they arrive.

    A window draws its canvas's current page every frame, so animating means redrawing in a frame handler rather than pushing images anywhere. Opening one schedules App.launch on the next tick, so a script that creates a window keeps running until every window is closed.

    const win = new Window(400, 300, { title: "hello" })
    win.on("frame", ({ frame }) => {
    let { ctx } = win
    ctx.fillStyle = "skyblue"
    ctx.fillRect(0, 0, 100 + frame, 100)
    })

    🧪 Not in the HTML Canvas standard.

    Hierarchy

    • EventEmitter<
          {
              [EventName in keyof WindowEvents]: [
                  { target: Window; type: EventName } & WindowEvents[EventName],
              ]
          },
      >
      • Window
    Index
    • Parameters

      Returns Window

    • Parameters

      Returns Window

    background: string

    Color drawn behind the canvas, filling any part of the window the canvas does not cover under the current Window.fit.

    borderless: boolean

    Whether the title bar and frame are hidden.

    canvas: Canvas

    The canvas being displayed. Assigning another one swaps what the window shows without reopening it.

    closed: boolean

    Whether Window.close has run.

    The drawing context of the canvas page this window is showing.

    cursor: CursorStyle

    Pointer shape over the window, using the CSS cursor keywords. An unrecognized name is ignored and the current cursor kept.

    How the canvas is scaled into the window when the two disagree in size or aspect -- see FitStyle. An unrecognized name is ignored.

    fullscreen: boolean

    Whether the window occupies the whole screen.

    height: number

    Height of the window, in points. Non-finite assignments are ignored.

    left: number

    Position of the window's left edge on screen, in points.

    page: number

    Which page of the canvas is on display, numbered from 1. A negative number counts from the end, and the window resizes its canvas to that page's dimensions. Assigning a page that does not exist is ignored.

    resizable: boolean

    Whether the user may resize the window.

    title: string

    Title-bar text. Assigning null clears it rather than printing "null".

    top: number

    Position of the window's top edge on screen, in points.

    visible: boolean

    Whether the window is mapped on screen. Set false to hide it.

    width: number

    Width of the window, in points. Non-finite assignments are ignored.

    • Close the window and emit its close event. When the last window closes, the event loop ends and App.launch's promise resolves.

      Returns void

    • Queue the window for display. Nothing appears until the event loop starts, which App.launch does -- scheduled automatically on the next tick, so this is usually all a script has to call.

      Returns void