libraryextensions/canvas/lib/Canvas.xtl

Canvas.xtl -- the facade of the canvas extension: a native window showing X_eTaL arrays as pixels, with keys, clicks and frame ticks back. Import: "cv:" u_se< "Canvas" Run with xetal-x, which links canvas and serves its windows on the main thread (xetal-x --ext DIR puts this directory on XETAL_PATH). Each signature line is written out by the binding macro (lib/Ffi.xtlm).

source · imports ffi: lib/Ffi.xtlm

ˡo̲pen! : Num a => Char -> a -> Int

function · line 11

title cv:o_pen! width height: a window that size (in points); its id.

"o_pen! : text int -> int"      ᶠᶠⁱb̲ind< "canvas/open"
ᶠᶠⁱb̲ind< expands to
ˡo̲pen! ← { a b →
  pa ← a ⎕N̲PUT "ext:canvas/open?text"
  pb ← (f̲ormat r̲avel f̲loor b) ⎕N̲PUT "ext:canvas/open?int=" c̲at f̲ormat s̲hape b
  f̲loor f̲irst n̲umbers ⎕N̲GET "ext:canvas/open"
}
Used in: w, w

ˡs̲how! : (Num a, Num b) => a -> b -> Int

function · line 15

id cv:s_how! pixels: draw an n by m matrix (gray) or an n by m by 3 array (red, green, blue), each from 0 (dark) to 1 (bright); a Bool matrix draws its 1s white. Scaled to the window; the id.

"s_how! : int float -> int"     ᶠᶠⁱb̲ind< "canvas/show"
ᶠᶠⁱb̲ind< expands to
ˡs̲how! ← { a b →
  pa ← (f̲ormat r̲avel f̲loor a) ⎕N̲PUT "ext:canvas/show?int=" c̲at f̲ormat s̲hape a
  pb ← (f̲ormat r̲avel f̲loat b) ⎕N̲PUT "ext:canvas/show?float=" c̲at f̲ormat s̲hape b
  f̲loor f̲irst n̲umbers ⎕N̲GET "ext:canvas/show"
}

ˡn̲ext! : Num a => a -> Char

function · line 19

cv:n_ext! id: the next event, waiting at most a frame (1/60 s): "frame", "key Space", "key q", "key ArrowLeft", "click ROW COL" (where in the array shown, from 1), or "close".

"n_ext! : int -> text"          ᶠᶠⁱb̲ind< "canvas/next"
ᶠᶠⁱb̲ind< expands to
ˡn̲ext! ← { a →
  pa ← (f̲ormat r̲avel f̲loor a) ⎕N̲PUT "ext:canvas/next?int=" c̲at f̲ormat s̲hape a
  ⎕N̲GET "ext:canvas/next"
}

ˡc̲lose! : Num a => a -> Int

function · line 21

cv:c_lose! id: close the window; 1.

"c_lose! : int -> int"          ᶠᶠⁱb̲ind< "canvas/close"
ᶠᶠⁱb̲ind< expands to
ˡc̲lose! ← { a →
  pa ← (f̲ormat r̲avel f̲loor a) ⎕N̲PUT "ext:canvas/close?int=" c̲at f̲ormat s̲hape a
  f̲loor f̲irst n̲umbers ⎕N̲GET "ext:canvas/close"
}

ˡpackage : Char

value · line 24

The native package behind these functions.

ˡpackage ← "canvas"