Convert a structural RGBA value at an adapter boundary into roc-ray's color.
Draw
:= []
Immediate-mode 2D drawing, text, textures, cameras, and render effects.
The host owns the outer frame scope and passes an opaque Frame capability
to render!. Draw through that receiver so drawing cannot happen before
BeginDrawing or after EndDrawing. Nested helpers keep raylib's begin/end state
transitions paired. Create host-owned fonts, render textures, and shaders
during initialization and keep them in the model; per-frame drawing and
uniform updates do not allocate.
alpha_blend : BlendMode
Conventional source-alpha compositing.
additive_blend : BlendMode
Add source and destination colors, useful for light and glow effects.
multiplied_blend : BlendMode
Multiply source and destination colors.
add_colors_blend : BlendMode
Add source and destination color channels.
subtract_colors_blend : BlendMode
Subtract source color channels from the destination.
premultiplied_alpha_blend : BlendMode
Alpha compositing for textures whose RGB channels are premultiplied.
Create a fill-only shape style.
Create a stroke with color and thickness in logical pixels.
Create a stroke-only shape style.
filled_and_outlined : Color, Color, F32 -> ShapeStyle
Create a shape style with both fill and outline.
default_font : Font
The built-in font, which requires no loading or host-owned resource.
Default text glyph spacing in logical pixels.
align_top_left : TextAlign
Top-left text anchor.
align_top_center : TextAlign
Top-center text anchor.
align_top_right : TextAlign
Top-right text anchor.
align_center : TextAlign
Centered text anchor.
align_middle_left : TextAlign
Middle-left text anchor.
align_middle_right : TextAlign
Middle-right text anchor.
align_bottom_left : TextAlign
Bottom-left text anchor.
align_bottom_center : TextAlign
Bottom-center text anchor.
align_bottom_right : TextAlign
Bottom-right text anchor.
align_offset : TextSize, TextAlign -> Vector2
Convert a measured size and alignment into an anchor offset.
origin_for : Vector2, TextSize, TextAlign -> Vector2
Find the top-left text origin for an anchored position.
align_factor : TextAlign -> Vector2
Convert text alignment into horizontal and vertical factors from 0 to 1.
center_in_rect : Rectangle, TextSize -> Vector2
Find the top-left position that centers measured text in a rectangle.
Clear the active drawing target to a solid color.
rectangle_gradient_v! : Frame, RectangleGradientV => { }
Draw a vertical rectangle gradient.
rectangle_gradient_h! : Frame, RectangleGradientH => { }
Draw a horizontal rectangle gradient.
circle_gradient! : Frame, CircleGradient => { }
Draw a radial circle gradient.
fps! : Frame, Fps => { }
Draw raylib's current frames-per-second counter.
rectangle! : Frame, Rectangle => { }
Draw a filled and/or outlined axis-aligned rectangle.
rounded_rectangle! : Frame, RoundedRectangle => { }
Draw a filled and/or outlined rounded rectangle.
circle! : Frame, Circle => { }
Draw a filled and/or outlined circle.
line! : Frame, Line => { }
Draw a stroked line segment. NoStroke performs no drawing.
triangle! : Frame, Triangle => { }
Draw a filled and/or outlined triangle.
polygon! : Frame, Polygon => { }
Compatibility alias for convex_polygon!.
convex_polygon! : Frame, ConvexPolygon => { }
Draw a convex filled polygon and/or an ordered polygon outline. The host triangulates the fill without allocating; fewer than three points do not fill.
measure_text! : MeasureText => TextSize
Measure text without drawing it, using the selected font and spacing.
load_font! : LoadFont => Try(Font, [FontLoadFailed, ResourceLimit, ..])
Load a host-owned font from disk at the requested base size.
texture_draw : Texture -> TextureDraw
Create a draw configuration covering the whole texture at the origin.
texture_at : Texture, Vec2 -> TextureDraw
Create a draw configuration covering the whole texture at pos.
texture_view_draw : TextureView -> TextureDraw
Create a draw configuration covering a read-only sampled view.
texture_view_at : TextureView, Vec2 -> TextureDraw
Create a sampled-view draw configuration at pos.
texture! : Frame, TextureDraw => { }
Draw a texture with explicit source, destination, origin, rotation, and tint.
draw_texture! : Frame, TextureDraw => { }
Compatibility alias for texture!.
projective_texture! : Frame, ProjectiveTexture => { }
Project a texture onto a validated planar quad with exact homogeneous UV interpolation. This remains one hosted call and preserves active shaders.
projective_texture_view! : Frame, ProjectiveTextureView => { }
Project a sampled texture view onto a validated planar quad.
load_render_texture! : RenderTextureSize => Try(RenderTexture, [RenderTextureLoadFailed, ResourceLimit, ..])
Allocate an offscreen framebuffer. Do this during initialization, not per frame; creation allocates GPU resources and one fixed host-heap slot.
render_texture : RenderTexture -> TextureView
View the color attachment as a sampled texture without allocating or copying. The returned reference keeps the owning framebuffer alive.
render_texture_source : RenderTexture -> Rect
Render textures use OpenGL framebuffer coordinates, so their color attachment is vertically inverted when sampled on screen.
load_shader! : LoadShader => Try(Shader, [ShaderLoadFailed, ResourceLimit, ..])
Load shader stages from files. Pass an empty string to use raylib's default vertex or fragment stage.
load_shader_source! : LoadShaderSource => Try(Shader, [ShaderLoadFailed, ResourceLimit, ..])
Compile shader stages from source strings. Empty strings select the default stage, which is useful for fragment-only 2D post-processing.
with_render_texture! : Frame, RenderTexture, (Frame => Try(result, [ScopeLimit, ScopeUnavailable, ..errors])) => Try(result, [ScopeLimit, ScopeUnavailable, ..errors])
Scope offscreen rendering so BeginTextureMode/EndTextureMode stay paired. Callback errors are returned only after the native target has been restored.
with_shader! : Frame, Shader, (Frame => Try(result, [ScopeLimit, ScopeUnavailable, ..errors])) => Try(result, [ScopeLimit, ScopeUnavailable, ..errors])
Scope shader application so the default shader is always restored. Callback errors are returned only after the previous shader has been restored.
with_blend_mode! : Frame, BlendMode, (Frame => Try(result, [ScopeLimit, ..errors])) => Try(result, [ScopeLimit, ..errors])
Scope one of raylib's built-in blend equations. Custom blend factors are deliberately excluded until they can be represented without global state.
with_camera! : Frame, CameraMode, (Frame => Try(result, [ScopeLimit, ..errors])) => Try(result, [ScopeLimit, ..errors])
Draw the callback in world space using this camera.
with_mode_2d! : Frame, CameraMode, (Frame => Try(result, [ScopeLimit, ..errors])) => Try(result, [ScopeLimit, ..errors])
Compatibility alias for with_camera!.
with_scissor! : Frame, Rect, (Frame => Try(result, [ScopeLimit, ..errors])) => Try(result, [ScopeLimit, ..errors])
Restrict callback drawing to screen-space bounds, then always close the
scissor before returning. Use this instead of manually pairing the raw effects.
text! : Frame, Text => { }
Draw text using explicit font, spacing, color, and anchor alignment.
debug_text! : Frame, DebugText => { }
Draw top-left aligned text with the built-in font and default spacing.
text_at! : Frame, SimpleText => { }
Draw simple top-left aligned text with the built-in font.
text_centered! : Frame, SimpleText => { }
Draw simple text centered on its position.
Frame
Draw.Frame :: # (opaque)
Opaque, zero-sized authority supplied only while the host is running
render!. It prevents drawing during initialization, but Roc does not yet
enforce affine use or encode a frame epoch; do not retain it in the model.
from_host : Frame -> Frame
Two-dimensional vector used by drawing records.
Axis-aligned rectangle used by drawing records.
Pure 2D camera settings.
Optional shape fill.
Optional shape outline with color and thickness.
ShapeStyle : {
fill : Fill,
stroke : Stroke,
}
Combined fill and outline applied by shape helpers.
Axis-aligned rectangle and its style.
RoundedRectangle : {
x : F32,
y : F32,
width : F32,
height : F32,
radius : F32,
segments : I32,
style : ShapeStyle,
}
Rounded rectangle; radius and segment count control corner tessellation.
RectangleGradientV : {
x : F32,
y : F32,
width : F32,
height : F32,
color_top : Color,
color_bottom : Color,
}
Vertical rectangle gradient from top to bottom.
RectangleGradientH : {
x : F32,
y : F32,
width : F32,
height : F32,
color_left : Color,
color_right : Color,
}
Horizontal rectangle gradient from left to right.
Circle and its style.
CircleGradient : {
center : Vector2,
radius : F32,
color_inner : Color,
color_outer : Color,
}
Radial gradient from inner to outer color.
Line : {
start : Vector2,
end : Vector2,
stroke : Stroke,
}
Line segment and stroke.
Triangle : {
a : Vector2,
b : Vector2,
c : Vector2,
style : ShapeStyle,
}
Triangle vertices and style.
ConvexPolygon : {
points : List(Vector2),
style : ShapeStyle,
}
A simple convex polygon. Points must be ordered around the boundary (clockwise or counter-clockwise). Filled concave or self-intersecting polygons are not supported; outlines accept any ordered point path.
Polygon : ConvexPolygon
Compatibility alias for ConvexPolygon. Prefer ConvexPolygon and
convex_polygon! in new code so the fill constraint is visible at call sites.
Position, size, and color for the FPS counter.
Font : Font
The built-in font is allocation-free. A loaded font is an opaque host-owned resource whose final reference unloads its texture automatically.
HAlign : [Left, Center, Right]
Horizontal text anchor.
VAlign : [Top, Middle, Bottom]
Vertical text anchor.
TextAlign : {
horizontal : HAlign,
vertical : VAlign,
}
Horizontal and vertical text anchor.
Measured text dimensions in logical pixels.
Text : {
pos : Vector2,
text : Str,
size : F32,
spacing : F32,
color : Color,
font : Font,
align : TextAlign,
}
Fully configured text draw.
Built-in-font text intended for quick diagnostics.
SimpleText : {
pos : Vector2,
text : Str,
size : F32,
color : Color,
}
Built-in-font text with default spacing.
MeasureText : {
text : Str,
size : F32,
spacing : F32,
font : Font,
}
Text measurement configuration.
Font path and base pixel size.
TextureDraw : TextureDrawConfig
Resolved texture draw configuration.
ProjectiveQuadCorners : {
top_left : Vec2,
bottom_left : Vec2,
bottom_right : Vec2,
top_right : Vec2,
}
Four ordered corners of a projected planar surface.
ProjectiveQuad
Draw.ProjectiveQuad :: # (opaque)
A finite, convex planar projection with a bounded homography. Construct it
with ProjectiveQuad.from_corners; the opaque representation carries the
homogeneous weights needed for exact perspective-correct interpolation.
from_corners : ProjectiveQuadCorners -> Try(ProjectiveQuad, [NonFiniteQuad, DegenerateQuad, NonConvexQuad, ProjectiveHorizon, ..])
Validate four boundary-ordered corners and solve their projective weights. A single homography cannot represent a concave, self-intersecting, or horizon-crossing destination, so those states are rejected here.
Project a unit-square coordinate onto the destination surface. This uses the same homography as rendering and is useful for aligned overlays.
ProjectiveTexture : {
texture : Texture,
source : Rect,
quad : ProjectiveQuad,
tint : Color,
}
Texture and source region projected exactly onto a validated planar quad.
ProjectiveTextureView : {
texture : TextureView,
source : Rect,
quad : ProjectiveQuad,
tint : Color,
}
Sampled texture view projected exactly onto a validated planar quad.
CameraMode : Camera2D
Camera accepted by scoped 2D drawing.
RenderTexture
Draw.RenderTexture :: # (opaque)
Host-owned framebuffer. Its texture-shaped box has a distinct host kind; the host rejects ordinary textures before entering an offscreen scope. Releasing the final reference unloads the framebuffer and both attachments.
Allocate an offscreen framebuffer.
texture : RenderTexture -> TextureView
Read-only view of this render target's color attachment.
Vertically inverted full-source rectangle for drawing the color attachment.
RenderTextureSize : {
width : I32,
height : I32,
}
Pixel dimensions for a new offscreen render target.
Shader
Draw.Shader :: # (opaque)
Host-owned GPU shader. Empty vertex/fragment strings select raylib's default stage. Keep this value alive for every cached Uniform derived from it.
Load shader stages from files.
from_source! : LoadShaderSource => Try(Shader, [ShaderLoadFailed, ResourceLimit, ..])
Compile shader stages from source strings.
uniform_f32! : Shader, Str => Try(F32Uniform, [UniformNotFound, ..])
Resolve a scalar floating-point uniform once.
uniform_i32! : Shader, Str => Try(I32Uniform, [UniformNotFound, ..])
Resolve a scalar integer uniform once.
uniform_vec2! : Shader, Str => Try(Vec2Uniform, [UniformNotFound, ..])
Resolve a two-component vector uniform once.
uniform_vec3! : Shader, Str => Try(Vec3Uniform, [UniformNotFound, ..])
Resolve a three-component vector uniform once.
uniform_vec4! : Shader, Str => Try(Vec4Uniform, [UniformNotFound, ..])
Resolve a four-component vector uniform once.
uniform_color! : Shader, Str => Try(ColorUniform, [UniformNotFound, ..])
Resolve a color-valued vec4 uniform once.
uniform_texture! : Shader, Str => Try(TextureUniform, [UniformNotFound, ..])
Resolve a sampled-texture uniform once.
LoadShader : {
vertex_path : Str,
fragment_path : Str,
}
File paths for shader stages. An empty path selects the default stage.
LoadShaderSource : {
vertex_source : Str,
fragment_source : Str,
}
Shader source strings. An empty string selects the default stage.
F32Uniform
Draw.F32Uniform :: # (opaque)
Typed uniform handles are zero-cost nominal wrappers over the cached host location plus its owning shader. Their distinct types prevent using the wrong setter without adding a tag, allocation, or host lookup.
I32Uniform
Draw.I32Uniform :: # (opaque)
Vec2Uniform
Draw.Vec2Uniform :: # (opaque)
set! : Vec2Uniform, Vector2 => { }
Vec3Uniform
Draw.Vec3Uniform :: # (opaque)
set! : Vec3Uniform, Vec3 => { }
Vec4Uniform
Draw.Vec4Uniform :: # (opaque)
set! : Vec4Uniform, Vec4 => { }
ColorUniform
Draw.ColorUniform :: # (opaque)
TextureUniform
Draw.TextureUniform :: # (opaque)
set! : TextureUniform, TextureView => { }
Bind any sampled texture view, including a render-target attachment.
set_texture! : TextureUniform, Texture => { }
Convenience setter for an ordinary mutable texture.
Three-component shader uniform value.
Four-component shader uniform value.
BlendMode : [
Alpha,
Additive,
Multiplied,
AddColors,
SubtractColors,
AlphaPremultiply,
]
Built-in blend equations with scoped application through with_blend_mode!.
ScopeError : [ScopeLimit, ScopeUnavailable]
A scoped renderer could not be opened because its bounded native stack is full or a transferred host resource no longer resolves.