Crates.io | direct2d |
lib.rs | direct2d |
version | 0.3.0-alpha1 |
source | src |
created_at | 2015-12-12 01:11:32.349922 |
updated_at | 2019-02-24 22:15:54.038887 |
description | A safe abstraction for drawing with Direct2D |
homepage | |
repository | https://github.com/Connicpu/direct2d-rs |
max_upload_size | |
id | 3614 |
size | 181,315 |
Safe abstractions for drawing on Windows using Direct2D
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!"),
}
}