MCPcopy Create free account
hub / github.com/bedroombuilds/python2rust / main

Function main

25_vector_graphics/rust/cairodraw/src/main.rs:39–54  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

37}
38
39fn main() -> Result<(), Box<dyn std::error::Error>> {
40 let png_output_fn = "output.png";
41 let img_surface = cairo::ImageSurface::create(cairo::Format::ARgb32, 200, 200).unwrap();
42 let svg_fn = std::path::Path::new("output.svg");
43 let svg_surface = cairo::SvgSurface::new(200., 200., Some(svg_fn)).unwrap();
44 let img_ctx = cairo::Context::new(&img_surface)?;
45 let svg_ctx = cairo::Context::new(&svg_surface)?;
46
47 draw_box(&img_ctx, 0., 0., 32., 32.)?;
48 draw_box(&svg_ctx, 0., 0., 32., 32.)?;
49 draw(&img_ctx)?;
50 draw(&svg_ctx)?;
51 let mut file = std::fs::File::create(png_output_fn)?;
52 img_surface.write_to_png(&mut file).unwrap();
53 Ok(())
54}

Callers

nothing calls this directly

Calls 2

draw_boxFunction · 0.70
drawFunction · 0.70

Tested by

no test coverage detected