| Crates.io | mltg |
| lib.rs | mltg |
| version | 0.22.1 |
| created_at | 2021-05-18 05:14:03.37797+00 |
| updated_at | 2023-08-17 23:40:37.274831+00 |
| description | Direct2D wrapper library |
| homepage | |
| repository | https://github.com/LNSEAB/mltg |
| max_upload_size | |
| id | 398850 |
| size | 21,868,206 |
Direct2D wrapper library
mltg::Context and a mltg::Factorylet ctx = mltg::Context::new(mltg::Direct2D::new()?)?;
let factory = ctx.create_factory();
In the case of using winit.
let window_size = window.inner_size().to_logical::<f32>(window.scale_factor());
let mut render_target = ctx.create_render_target(
window.raw_window_handle(), // winit window
(window_size.width, window_size.height),
)?;
For example, create the solid color brush.
let brush = factory.create_solid_color_brush((1.0, 1.0, 1.0, 1.0))?;
For example, draw the rectangle of filled color.
ctx.set_scale_factor(window.scale_factor() as _);
ctx.draw(&render_target, |cmd| {
cmd.clear((0.0, 0.0, 0.3, 0.0));
cmd.fill(
&mltg::Rect::from_points((10.0, 10.0), (100.0, 100.0)),
&brush,
);
});
Copyright (c) 2021 LNSEAB