direct2d

Crates.iodirect2d
lib.rsdirect2d
version0.3.0-alpha1
sourcesrc
created_at2015-12-12 01:11:32.349922
updated_at2019-02-24 22:15:54.038887
descriptionA safe abstraction for drawing with Direct2D
homepage
repositoryhttps://github.com/Connicpu/direct2d-rs
max_upload_size
id3614
size181,315
Connie Hilarides (Connicpu)

documentation

https://docs.rs/direct2d/*/x86_64-pc-windows-msvc/direct2d/

README

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!"),
    }
}
Commit count: 101

cargo fmt