| 37 | } |
| 38 | |
| 39 | fn 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 | } |