| Crates.io | gravita-renderer |
| lib.rs | gravita-renderer |
| version | 0.1.0 |
| created_at | 2025-12-25 22:14:04.378834+00 |
| updated_at | 2025-12-25 22:14:04.378834+00 |
| description | Minimal CPU-based 2D rendering utilities for prototyping and simple games |
| homepage | |
| repository | https://github.com/cantoramann/gravita |
| max_upload_size | |
| id | 2005002 |
| size | 27,313 |
Minimal CPU-based 2D rendering utilities.
&mut [u8])use gravita_renderer::{clear, draw_circle, draw_line, draw_axes};
use gravita_math::Vec2;
// Create a frame buffer (800x600, RGBA)
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), // center
50.0, // radius
[0xff, 0xff, 0xff, 0xff], // color (RGBA)
800, 600 // frame dimensions
);
// Draw a red line
draw_line(
&mut frame,
Vec2::new(100.0, 100.0), // start
Vec2::new(700.0, 500.0), // end
[0xff, 0x00, 0x00, 0xff], // color
800, 600
);
// Draw debug axes
draw_axes(&mut frame, Vec2::new(400.0, 300.0), [0x80; 4], 800, 600);
The renderer works in screen coordinates where:
For physics integration, you typically need to flip Y:
let screen_y = screen_height - world_y;
MIT OR Apache-2.0