Expand description
Minimal 2D rendering helpers shared across examples.
This crate intentionally stays lightweight: it provides simple drawing primitives on top of a raw RGBA frame buffer. Higher-level scene logic lives in the individual examples.
§Design Philosophy
- CPU-based: All rendering happens on the CPU, no GPU required
- Frame buffer: Works with any
&mut [u8]RGBA buffer - Coordinate system: Y increases upward (world space), caller handles conversion
§Available Primitives
clear— Fill the entire frame with a solid colordraw_circle— Draw a filled circledraw_line— Draw a 1-pixel wide line (Bresenham’s algorithm)draw_axes— Draw X/Y debug axes
§Example
ⓘ
use gravita_renderer::{clear, draw_circle, draw_line};
use gravita_math::Vec2;
let mut frame = vec![0u8; 800 * 600 * 4];
// Clear to dark blue
clear(&mut frame, [0x20, 0x20, 0x40, 0xff]);
// Draw a white circle
draw_circle(&mut frame, Vec2::new(400.0, 300.0), 50.0, [0xff; 4], 800, 600);Functions§
- clear
- Clear the entire frame to a solid color (RGBA).
- draw_
axes - Draw simple X/Y axes crossing at
origin, useful for debugging. - draw_
circle - Draw a filled circle into the frame.
- draw_
line - Draw a 1‑pixel wide line between two points using Bresenham’s algorithm.