raylib.bend relies on unsafe/foreign
raw source on the hub · import gralha-raylib@0.1.0.0/raylib.bend as Raylib
gralha-raylib: a raylib window for Bend programs, driven by command lists. A frame is a List<U32> of draw commands built with the helpers below and joined with List.append; input comes back as words. Native (C) only: see README.md for the build flags.
1 import
import Base
Definitions
def words source · line 28 · raw
@s:String -> List<&1, U32>
A string as its code points.
def sized.step source · line 35 · raw
@h:U32 -> @r:Pair(U32, List<&1, U32>) -> Pair(U32, List<&1, U32>)
def sized source · line 41 · raw
@xs:List<&1, U32> -> Pair(U32, List<&1, U32>)
A list beside its length.
def counted.of source · line 48 · raw
@r:Pair(U32, List<&1, U32>) -> List<&1, U32>
def counted source · line 54 · raw
@xs:List<&1, U32> -> List<&1, U32>
The length of xs, then xs.
def first source · line 58 · raw
@ws:List<&1, U32> -> U32
The first word of a reply, or 0.
def is_one source · line 65 · raw
@+w:U32 -> Bool
def clear source · line 73 · raw
@color:U32 -> List<&1, U32>
def rect source · line 76 · raw
@x:U32 -> @y:U32 -> @w:U32 -> @h:U32 -> @color:U32 -> List<&1, U32>
def rect_lines source · line 79 · raw
@x:U32 -> @y:U32 -> @w:U32 -> @h:U32 -> @color:U32 -> List<&1, U32>
def text source · line 83 · raw
@x:U32 -> @y:U32 -> @size:U32 -> @color:U32 -> @s:String -> List<&1, U32>
ASCII text (other code points draw as '?'), in the loaded font if any.
def circle source · line 86 · raw
@x:U32 -> @y:U32 -> @r:U32 -> @color:U32 -> List<&1, U32>
def line source · line 89 · raw
@x1:U32 -> @y1:U32 -> @x2:U32 -> @y2:U32 -> @color:U32 -> List<&1, U32>
def sprite source · line 94 · raw
@id:U32 -> @sx:U32 -> @sy:U32 -> @sw:U32 -> @sh:U32 -> @dx:U32 -> @dy:U32 -> @scale:U32 -> @flip:U32 -> @tint:U32 -> List<&1, U32>
Draws the (sx, sy, sw, sh) part of texture id at (dx, dy), scaled by
scale/256, mirrored when flip is 1, multiplied by tint.
def play source · line 97 · raw
@id:U32 -> List<&1, U32>
def frame source · line 104 · raw
@cmds:List<&1, U32> -> IO(Unit)
Draws one frame.
def input source · line 108 · raw
IO(List<&1, U32>)
This frame's input: [held, mouse, events..].
def query source · line 112 · raw
@cmds:List<&1, U32> -> IO(U32)
Sends commands whose last one asks for a reply, and answers it.
def texture source · line 120 · raw
@w:U32 -> @h:U32 -> @rgba:List<&1, U32> -> IO(U32)
Uploads a w*h RGBA texture (four bytes per pixel, one byte per word); answers its id, or 0xFFFFFFFF if it does not fit.
def sound source · line 124 · raw
@samples:List<&1, U32> -> IO(U32)
Uploads an 8-bit mono 22050 Hz sound (one sample per word); answers its id.
def font source · line 128 · raw
@path:String -> IO(Bool)
Loads a TrueType font for text; answers whether it loaded.
def clipboard source · line 133 · raw
@s:String -> IO(Unit)
def screenshot source · line 136 · raw
@path:String -> IO(Unit)
def should_close source · line 140 · raw
IO(Bool)
Whether the user asked to close the window.
def text_width source · line 146 · raw
@size:U32 -> @s:String -> IO(U32)
The width in pixels of s drawn at size.
def close source · line 150 · raw
IO(Unit)
Closes the window and the audio device.
def mouse_x source · line 157 · raw
@+m:U32 -> U32
The mouse word: x in bits 0-11, y in 12-23, then the buttons.
def mouse_y source · line 160 · raw
@+m:U32 -> U32
def bit source · line 164 · raw
@+w:U32 -> @+b:Nat -> Bool
Whether bit b of a word is set (a held key, a mouse button).
Effects (foreign code)
effect open source · line 11 · raw
@title:String -> @w:U32 -> @h:U32 -> IO(Unit)
Opens the window (and the audio device). One window per program.
foreign: effs/raylib.c
effect send source · line 16 · raw
@cmds:List<&1, U32> -> IO(Unit)
Runs a command list: draws are presented as one frame, meta commands (uploads, queries, close) are applied in order.
foreign: effs/raylib.c
effect poll source · line 21 · raw
IO(List<&1, U32>)
The pending query replies if there are any, else this frame's input: [held, mouse, events..] (see README.md).
foreign: effs/raylib.c