15 unstable releases (3 breaking)

0.3.0-alpha1 Feb 24, 2019
0.2.0 Oct 23, 2018
0.1.4 Sep 26, 2018
0.1.2 Apr 27, 2018
0.0.2 Dec 13, 2015

#435 in Graphics APIs

Download history 169/week @ 2025-12-11 230/week @ 2025-12-18 184/week @ 2025-12-25 215/week @ 2026-01-01 112/week @ 2026-01-08 207/week @ 2026-01-15 181/week @ 2026-01-22 194/week @ 2026-01-29 139/week @ 2026-02-05 137/week @ 2026-02-12 209/week @ 2026-02-19 287/week @ 2026-02-26 242/week @ 2026-03-05 225/week @ 2026-03-12 314/week @ 2026-03-19 306/week @ 2026-03-26

1,164 downloads per month
Used in 6 crates (via druid-win-shell)

MIT/Apache

145KB
4.5K SLoC

Safe abstractions for drawing on Windows using Direct2D

Example

extern crate direct2d;

use direct2d::{DeviceContext, RenderTarget};
use direct2d::brush::SolidColorBrush;
use direct2d::image::Bitmap;

fn draw(context: &mut DeviceContext, target: &Bitmap) {
    let brush = SolidColorBrush::create(&context)
        .with_color(0xFF_7F_7F)
        .build().unwrap();

    context.begin_draw();
    context.set_target(target);
    context.clear(0xFF_FF_FF);
    
    context.draw_line((10.0, 10.0), (20.0, 20.0), &brush, 2.0, None);
    context.draw_line((10.0, 20.0), (20.0, 10.0), &brush, 2.0, None);

    match context.end_draw() {
        Ok(_) => {/* cool */},
        Err(_) => panic!("Uh oh, rendering failed!"),
    }
}

Dependencies

~0–0.8MB
~13K SLoC