Expand description
Denise’s software rasteriser.
Rectangles, rounded rectangles, circles, arcs, stars, lines, image blitting,
rectangular clipping and source-over alpha blending, straight into a
denise::Frame. No GPU, no
path builder, no allocator: this crate needs neither std nor alloc, and
every operation writes through a borrowed slice the caller already owns.
let mut canvas = Canvas::new(frame);
for region in damage {
// Everything inside this borrow is confined to `region`.
let mut c = canvas.with_clip(*region);
c.clear(Color::from_rgb888(0x1E1E2E));
c.fill_rounded_rect(Rect::new(40, 40, 200, 64), 12, Color::rgba(255, 255, 255, 32));
c.draw_line(Point::new(40, 120), Point::new(240, 121), Color::WHITE);
// A 70% progress ring. Angles are binary turns: 0 is twelve o'clock,
// clockwise positive, no radians and no floats anywhere.
c.stroke_arc(Point::new(300, 90), 40, 8, 0, 70 * denise_render::TURN / 100, Color::WHITE);
}§No floating point
The rasteriser is integer throughout, including anti-aliasing coverage. That
avoids a libm dependency on no_std targets and keeps output bit-identical
between x86 and ARM, so the reference tests mean the same thing on a developer’s
desktop and on the Pi.
§No unsafe
Deliberately, for now. Bounds checks are hoisted by working through row slices rather than indexing pixel by pixel. If the benches ever show that costing real time, that is the evidence needed to justify unchecked access — not before.
Re-exports§
pub use canvas::Canvas;pub use font::BitmapFont;
Modules§
- blend
- Pixel arithmetic.
- blit
- Drawing somebody else’s pixels: the positioned, blended blit.
- canvas
- The drawing target: a borrowed frame plus a clip rectangle.
- coverage
- Compositing 8-bit coverage masks.
- font
- The built-in bitmap font.
- icon
- Shapes a widget can draw when the font has no glyph for them.
- painter
Canvaswearing the painting contract.
Structs§
- Clip
Token - Proof that a clip was narrowed, and the only way to widen one back.
- Clipped
- A painter with a narrowed clip, which it restores when dropped.
- Mask
- A borrowed 8-bit coverage mask:
0transparent,255fully covered. - Paint
- A colour prepared for drawing.
- Pen
- The pen widgets draw with: a
&mut dyn Painterwearing the ergonomics the trait cannot have. - Pixel
View - A read-only view of somebody else’s pixels, for
Canvas::copy_from.
Constants§
- MAX_
ICON_ VERTICES - The most vertices one shape of an
Iconmay have. - TURN
- One full revolution, in the angle unit every arc call takes.
Traits§
- Painter
- A clipped drawing target.
- Painter
Ext - The part of the painting API that cannot be object-safe.