img_gen_spec/validators/layers/
rectangle.rs1use super::{Border, ColorKind};
2
3#[cfg(feature = "pyo3")]
4use pyo3::prelude::*;
5
6use serde::{Deserialize, Serialize};
7
8#[cfg_attr(
10 feature = "pyo3",
11 pyclass(eq, eq_int, module = "img_gen", from_py_object)
12)]
13#[derive(Debug, PartialEq, Clone, Copy, Serialize, Deserialize)]
14pub enum Corners {
15 #[serde(alias = "top left")]
17 TopLeft,
18
19 #[serde(alias = "top right")]
21 TopRight,
22
23 #[serde(alias = "bottom left")]
25 BottomLeft,
26
27 #[serde(alias = "bottom right")]
29 BottomRight,
30}
31
32impl Corners {
33 pub const ALL: [Self; 4] = [
35 Corners::TopLeft,
36 Corners::TopRight,
37 Corners::BottomLeft,
38 Corners::BottomRight,
39 ];
40}
41
42#[cfg_attr(
46 feature = "pyo3",
47 pyclass(module = "img_gen", get_all, set_all, from_py_object)
48)]
49#[derive(Debug, Clone, Default, Serialize, Deserialize)]
50pub struct Rectangle {
51 pub border: Option<Border>,
53
54 #[serde(
56 default = "ColorKind::transparent_default",
57 alias = "linear_gradient",
58 alias = "radial_gradient",
59 alias = "conical_gradient",
60 alias = "linear-gradient",
61 alias = "radial-gradient",
62 alias = "conical-gradient"
63 )]
64 pub color: ColorKind,
65
66 #[serde(default)]
72 pub radius: f32,
73
74 #[serde(default)]
78 pub corners: Vec<Corners>,
79}