Description
The canvas API currently supports canvas_rect, canvas_circle, canvas_line, and canvas_text — but there's no way to draw a rounded rectangle. This is one of the most commonly needed primitives for building UIs (cards, buttons, panels).
This is listed in the roadmap under Phase 2 (GPU & Graphics).
What to implement
Host side (oxide-browser)
-
capabilities.rs: Register a new host function api_canvas_rounded_rect with parameters:
x, y, w, h (f32) — position and size
r, g, b, a (u32) — fill color
radius (f32) — corner radius
-
ui.rs: Add a new DrawCommand::RoundedRect variant and handle it in the canvas painter using egui's Rounding support (painter.rect_filled already supports Rounding)
SDK side (oxide-sdk)
oxide-sdk/src/lib.rs: Add the FFI import and a safe wrapper:
pub fn canvas_rounded_rect(x: f32, y: f32, w: f32, h: f32, radius: f32, r: u8, g: u8, b: u8, a: u8) { ... }
Docs
- Update
DOCS.md with the new function in the Canvas API table
References
- See existing
canvas_rect implementation for the pattern to follow
- egui supports rounded rects natively:
Rect + Rounding
Difficulty
Beginner to Intermediate — follow the existing pattern for canvas_rect. Touches 4 files but the changes are mechanical.
Description
The canvas API currently supports
canvas_rect,canvas_circle,canvas_line, andcanvas_text— but there's no way to draw a rounded rectangle. This is one of the most commonly needed primitives for building UIs (cards, buttons, panels).This is listed in the roadmap under Phase 2 (GPU & Graphics).
What to implement
Host side (
oxide-browser)capabilities.rs: Register a new host functionapi_canvas_rounded_rectwith parameters:x, y, w, h(f32) — position and sizer, g, b, a(u32) — fill colorradius(f32) — corner radiusui.rs: Add a newDrawCommand::RoundedRectvariant and handle it in the canvas painter using egui'sRoundingsupport (painter.rect_filledalready supportsRounding)SDK side (
oxide-sdk)oxide-sdk/src/lib.rs: Add the FFI import and a safe wrapper:Docs
DOCS.mdwith the new function in the Canvas API tableReferences
canvas_rectimplementation for the pattern to followRect+RoundingDifficulty
Beginner to Intermediate — follow the existing pattern for
canvas_rect. Touches 4 files but the changes are mechanical.