Skip to content

`direct2d` is trying to be a safe, thin abstraction for Direct2D to let you easily write 2D drawing on Windows

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

Connicpu/direct2d-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

direct2d-rs Crates.io

Documentation

Safe abstractions for drawing on Windows using Direct2D

To use it, add this to your Cargo.toml:

[dependencies]
direct2d = "0.1"

Example

extern crate direct2d;

use direct2d::device_context::{DeviceContext, IDeviceContext};
use direct2d::render_target::IRenderTarget;
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.into());
    
    context.draw_line((10.0, 10.0).into(), (20.0, 20.0).into(), &brush, 2.0, None);
    context.draw_line((10.0, 20.0).into(), (20.0, 10.0).into(), &brush, 2.0, None);

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

About

`direct2d` is trying to be a safe, thin abstraction for Direct2D to let you easily write 2D drawing on Windows

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages