use palette::Srgba;
use piet::{Color, RenderContext};
use piet_common::kurbo::Rect;
use piet_common::Device;
use rough_piet::KurboGenerator;
use roughr::core::{LineCap, LineJoin, OptionsBuilder};
const WIDTH: usize = 192;
const HEIGHT: usize = 108;
const DPI: f32 = 96.;
fn main() {
let mut device = Device::new().unwrap();
let mut bitmap = device.bitmap_target(WIDTH, HEIGHT, 1.0).unwrap();
let mut rc = bitmap.render_context();
let options = OptionsBuilder::default()
.stroke(Srgba::from_components((114u8, 87u8, 82u8, 255u8)).into_format())
.stroke_width(5.0)
.roughness(0.0)
.stroke_line_dash(vec![])
.line_cap(LineCap::Round)
.line_join(LineJoin::Round)
.build()
.unwrap();
let generator = KurboGenerator::new(options);
let rect_width = 100.0;
let rect_height = 50.0;
let rect = generator.rectangle::<f32>(
(WIDTH as f32 - rect_width) / 2.0,
(HEIGHT as f32 - rect_height) / 2.0,
rect_width,
rect_height,
);
let background_color = Color::from_hex_str("96C0B7").unwrap();
rc.fill(
Rect::new(0.0, 0.0, WIDTH as f64, HEIGHT as f64),
&background_color,
);
rect.draw(&mut rc);
rc.finish().unwrap();
std::mem::drop(rc);
bitmap
.save_to_file("stroke_style.png")
.expect("file save error");
}