2D Primitives
Functions for the 2D batch renderer. All primitives are z-sorted and flushed with vio_draw_2d().
vio_rect
void vio_rect(VioContext $ctx, float $x, float $y, float $w, float $h, ?array $opts = null)Draw a filled or outlined rectangle.
Options:
| Key | Type | Default | Description |
|---|---|---|---|
color / fill | int | 0xFFFFFFFF | AARRGGBB color |
outline | bool | false | Draw outline only |
z | float | 0.0 | Z-order for sorting |
vio_rounded_rect
void vio_rounded_rect(VioContext $ctx, float $x, float $y, float $w, float $h, float $radius, ?array $opts = null)Draw a rectangle with rounded corners.
Options: Same as vio_rect.
vio_circle
void vio_circle(VioContext $ctx, float $cx, float $cy, float $radius, ?array $opts = null)Draw a filled or outlined circle.
Options:
| Key | Type | Default | Description |
|---|---|---|---|
color / fill | int | 0xFFFFFFFF | AARRGGBB color |
outline | bool | false | Draw outline only |
segments | int | auto | Number of circle segments |
z | float | 0.0 | Z-order |
vio_line
void vio_line(VioContext $ctx, float $x1, float $y1, float $x2, float $y2, ?array $opts = null)Draw a line segment.
Options:
| Key | Type | Default | Description |
|---|---|---|---|
color | int | 0xFFFFFFFF | AARRGGBB color |
z | float | 0.0 | Z-order |
WARNING
Line rendering may produce no visible pixels on some GPU/driver configurations.
vio_sprite
void vio_sprite(VioContext $ctx, VioTexture $texture, ?array $opts = null)Draw a textured quad.
Options:
| Key | Type | Default | Description |
|---|---|---|---|
x | float | 0.0 | X position |
y | float | 0.0 | Y position |
width | float | texture width | Display width |
height | float | texture height | Display height |
scale_x | float | 1.0 | Horizontal scale |
scale_y | float | 1.0 | Vertical scale |
color | int | 0xFFFFFFFF | Tint color (white = no tint) |
z | float | 0.0 | Z-order |
vio_draw_2d
void vio_draw_2d(VioContext $context)Flush the 2D batch. Sorts all queued primitives by z-value, batches by texture, and renders in a single pass. Call this before vio_end().
Maximum batch size: 4096 items per frame.
vio_push_transform
void vio_push_transform(VioContext $ctx, float $a, float $b, float $c, float $d, float $e, float $f)Push a 2x3 affine transformation matrix onto the transform stack. Affects all subsequent 2D primitives.
Matrix layout:
| a c e |
| b d f |
| 0 0 1 |vio_pop_transform
void vio_pop_transform(VioContext $context)Pop the top transformation matrix from the stack.
vio_push_scissor
void vio_push_scissor(VioContext $ctx, float $x, float $y, float $w, float $h)Push a scissor rectangle. Only pixels within this rect are rendered. Nested scissors are intersected.
vio_pop_scissor
void vio_pop_scissor(VioContext $context)Pop the top scissor rectangle.
Color Format
Colors are 32-bit unsigned integers in 0xAARRGGBB order:
| Bits | Channel |
|---|---|
| 24–31 | Alpha |
| 16–23 | Red |
| 8–15 | Green |
| 0–7 | Blue |
0xFFFF0000 // Red, opaque
0xFF00FF00 // Green, opaque
0xFF0000FF // Blue, opaque
0xFFFFFFFF // White, opaque
0x80FFFFFF // White, 50% alpha
0x00000000 // TransparentA literal with alpha 00 draws nothing: 0x00FF00FF is fully transparent magenta, not green.