piet_test/
lib.rs

1//! Test code for piet.
2
3// Right now, this is just code to generate sample images.
4
5use piet::{Error, RenderContext};
6mod picture_0;
7mod picture_1;
8mod picture_2;
9mod picture_3;
10mod picture_4;
11mod picture_5;
12
13use crate::picture_0::draw as draw_picture_0;
14use crate::picture_1::draw as draw_picture_1;
15use crate::picture_2::draw as draw_picture_2;
16use crate::picture_3::draw as draw_picture_3;
17use crate::picture_4::draw as draw_picture_4;
18use crate::picture_5::draw as draw_picture_5;
19
20/// Draw a test picture, by number.
21///
22/// There are a few test pictures here now, and hopefully it will grow into
23/// a full suite, suitable for both benchmarking and correctness testing.
24pub fn draw_test_picture(rc: &mut impl RenderContext, number: usize) -> Result<(), Error> {
25    match number {
26        0 => draw_picture_0(rc),
27        1 => draw_picture_1(rc),
28        2 => draw_picture_2(rc),
29        3 => draw_picture_3(rc),
30        4 => draw_picture_4(rc),
31        5 => draw_picture_5(rc),
32        _ => {
33            eprintln!(
34                "Don't have test picture {} yet. Why don't you make it?",
35                number
36            );
37            // TODO: error?
38            Ok(())
39        }
40    }
41}