figma_api/models/
pattern_paint.rs

1/*
2 * Figma API
3 *
4 * This is the OpenAPI specification for the [Figma REST API](https://www.figma.com/developers/api).  Note: we are releasing the OpenAPI specification as a beta given the large surface area and complexity of the REST API. If you notice any inaccuracies with the specification, please [file an issue](https://github.com/figma/rest-api-spec/issues).
5 *
6 * The version of the OpenAPI document: 0.31.0
7 * Contact: support@figma.com
8 * Generated by: https://openapi-generator.tech
9 */
10
11use crate::models;
12use serde::{Deserialize, Serialize};
13
14#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
15pub struct PatternPaint {
16    /// Is the paint enabled?
17    #[serde(rename = "visible", skip_serializing_if = "Option::is_none")]
18    pub visible: Option<bool>,
19    /// Overall opacity of paint (colors within the paint can also have opacity values which would blend with this)
20    #[serde(rename = "opacity", skip_serializing_if = "Option::is_none")]
21    pub opacity: Option<f64>,
22    /// How this node blends with nodes behind it in the scene
23    #[serde(rename = "blendMode")]
24    pub blend_mode: models::BlendMode,
25    /// The string literal \"PATTERN\" representing the paint's type. Always check the `type` before reading other properties.
26    #[serde(rename = "type")]
27    pub r#type: Type,
28    /// The node id of the source node for the pattern
29    #[serde(rename = "sourceNodeId")]
30    pub source_node_id: String,
31    /// The tile type for the pattern
32    #[serde(rename = "tileType")]
33    pub tile_type: TileType,
34    /// The scaling factor for the pattern
35    #[serde(rename = "scalingFactor")]
36    pub scaling_factor: f64,
37    /// The spacing for the pattern
38    #[serde(rename = "spacing")]
39    pub spacing: Box<models::Vector>,
40    /// The horizontal alignment for the pattern
41    #[serde(rename = "horizontalAlignment")]
42    pub horizontal_alignment: HorizontalAlignment,
43    /// The vertical alignment for the pattern
44    #[serde(rename = "verticalAlignment")]
45    pub vertical_alignment: VerticalAlignment,
46}
47
48impl PatternPaint {
49    pub fn new(blend_mode: models::BlendMode, r#type: Type, source_node_id: String, tile_type: TileType, scaling_factor: f64, spacing: models::Vector, horizontal_alignment: HorizontalAlignment, vertical_alignment: VerticalAlignment) -> PatternPaint {
50        PatternPaint {
51            visible: None,
52            opacity: None,
53            blend_mode,
54            r#type,
55            source_node_id,
56            tile_type,
57            scaling_factor,
58            spacing: Box::new(spacing),
59            horizontal_alignment,
60            vertical_alignment,
61        }
62    }
63}
64/// The string literal \"PATTERN\" representing the paint's type. Always check the `type` before reading other properties.
65#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
66pub enum Type {
67    #[serde(rename = "PATTERN")]
68    Pattern,
69}
70
71impl Default for Type {
72    fn default() -> Type {
73        Self::Pattern
74    }
75}
76/// The tile type for the pattern
77#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
78pub enum TileType {
79    #[serde(rename = "RECTANGULAR")]
80    Rectangular,
81    #[serde(rename = "HORIZONTAL_HEXAGONAL")]
82    HorizontalHexagonal,
83    #[serde(rename = "VERTICAL_HEXAGONAL")]
84    VerticalHexagonal,
85}
86
87impl Default for TileType {
88    fn default() -> TileType {
89        Self::Rectangular
90    }
91}
92/// The horizontal alignment for the pattern
93#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
94pub enum HorizontalAlignment {
95    #[serde(rename = "START")]
96    Start,
97    #[serde(rename = "CENTER")]
98    Center,
99    #[serde(rename = "END")]
100    End,
101}
102
103impl Default for HorizontalAlignment {
104    fn default() -> HorizontalAlignment {
105        Self::Start
106    }
107}
108/// The vertical alignment for the pattern
109#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
110pub enum VerticalAlignment {
111    #[serde(rename = "START")]
112    Start,
113    #[serde(rename = "CENTER")]
114    Center,
115    #[serde(rename = "END")]
116    End,
117}
118
119impl Default for VerticalAlignment {
120    fn default() -> VerticalAlignment {
121        Self::Start
122    }
123}
124