mirror of
https://github.com/danbulant/cushy
synced 2026-06-14 20:11:04 +00:00
This commit adds my first take at creating a harness for a user's guide using the new capture functionality. The example has tests that ensure the align widget creates the expected results.
30 lines
699 B
Rust
30 lines
699 B
Rust
use cushy::widget::MakeWidget;
|
|
use figures::Size;
|
|
|
|
fn ui() -> impl MakeWidget {
|
|
"Hello World".into_button().centered()
|
|
}
|
|
|
|
fn main() {
|
|
// The default recorder generated solid, rgb images.
|
|
let recorder = ui()
|
|
.build_recorder()
|
|
.size(Size::new(320, 240))
|
|
.finish()
|
|
.unwrap();
|
|
recorder.image().save("examples/offscreen.png").unwrap();
|
|
|
|
// Creating a recorder with alpha makes the virtual window transparent.
|
|
let recorder = ui()
|
|
.build_recorder()
|
|
.with_alpha()
|
|
.size(Size::new(320, 240))
|
|
.finish()
|
|
.unwrap();
|
|
recorder.image().save("examples/offscreen.png").unwrap();
|
|
}
|
|
|
|
#[test]
|
|
fn runs() {
|
|
main();
|
|
}
|