figma_api/models/
boolean_operation_node.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 BooleanOperationNode {
16    /// A string uniquely identifying this node within the document.
17    #[serde(rename = "id")]
18    pub id: String,
19    /// The name given to the node by the user in the tool.
20    #[serde(rename = "name")]
21    pub name: String,
22    /// Whether or not the node is visible on the canvas.
23    #[serde(rename = "visible", skip_serializing_if = "Option::is_none")]
24    pub visible: Option<bool>,
25    /// If true, layer is locked and cannot be edited
26    #[serde(rename = "locked", skip_serializing_if = "Option::is_none")]
27    pub locked: Option<bool>,
28    /// Whether the layer is fixed while the parent is scrolling
29    #[serde(rename = "isFixed", skip_serializing_if = "Option::is_none")]
30    pub is_fixed: Option<bool>,
31    /// How layer should be treated when the frame is resized
32    #[serde(rename = "scrollBehavior")]
33    pub scroll_behavior: ScrollBehavior,
34    /// The rotation of the node, if not 0.
35    #[serde(rename = "rotation", skip_serializing_if = "Option::is_none")]
36    pub rotation: Option<f64>,
37    /// A mapping of a layer's property to component property name of component properties attached to this node. The component property name can be used to look up more information on the corresponding component's or component set's componentPropertyDefinitions.
38    #[serde(rename = "componentPropertyReferences", skip_serializing_if = "Option::is_none")]
39    pub component_property_references: Option<std::collections::HashMap<String, String>>,
40    #[serde(rename = "pluginData", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
41    pub plugin_data: Option<Option<serde_json::Value>>,
42    #[serde(rename = "sharedPluginData", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
43    pub shared_plugin_data: Option<Option<serde_json::Value>>,
44    #[serde(rename = "boundVariables", skip_serializing_if = "Option::is_none")]
45    pub bound_variables: Option<Box<models::IsLayerTraitBoundVariables>>,
46    /// A mapping of variable collection ID to mode ID representing the explicitly set modes for this node.
47    #[serde(rename = "explicitVariableModes", skip_serializing_if = "Option::is_none")]
48    pub explicit_variable_modes: Option<std::collections::HashMap<String, String>>,
49    /// How this node blends with nodes behind it in the scene (see blend mode section for more details)
50    #[serde(rename = "blendMode")]
51    pub blend_mode: models::BlendMode,
52    /// Opacity of the node
53    #[serde(rename = "opacity", skip_serializing_if = "Option::is_none")]
54    pub opacity: Option<f64>,
55    /// An array of nodes that are direct children of this node
56    #[serde(rename = "children")]
57    pub children: Vec<models::SubcanvasNode>,
58    /// Keep height and width constrained to same ratio.
59    #[serde(rename = "preserveRatio", skip_serializing_if = "Option::is_none")]
60    pub preserve_ratio: Option<bool>,
61    /// Horizontal and vertical layout constraints for node.
62    #[serde(rename = "constraints", skip_serializing_if = "Option::is_none")]
63    pub constraints: Option<Box<models::LayoutConstraint>>,
64    /// A transformation matrix is standard way in computer graphics to represent translation and rotation. These are the top two rows of a 3x3 matrix. The bottom row of the matrix is assumed to be [0, 0, 1]. This is known as an affine transform and is enough to represent translation, rotation, and skew.  The identity transform is [[1, 0, 0], [0, 1, 0]].  A translation matrix will typically look like:  ``` [[1, 0, tx],   [0, 1, ty]] ```  and a rotation matrix will typically look like:  ``` [[cos(angle), sin(angle), 0],   [-sin(angle), cos(angle), 0]] ```  Another way to think about this transform is as three vectors:  - The x axis (t[0][0], t[1][0]) - The y axis (t[0][1], t[1][1]) - The translation offset (t[0][2], t[1][2])  The most common usage of the Transform matrix is the `relativeTransform property`. This particular usage of the matrix has a few additional restrictions. The translation offset can take on any value but we do enforce that the axis vectors are unit vectors (i.e. have length 1). The axes are not required to be at 90° angles to each other.
65    #[serde(rename = "relativeTransform", skip_serializing_if = "Option::is_none")]
66    pub relative_transform: Option<Vec<Vec<f64>>>,
67    /// Width and height of element. This is different from the width and height of the bounding box in that the absolute bounding box represents the element after scaling and rotation. Only present if `geometry=paths` is passed.
68    #[serde(rename = "size", skip_serializing_if = "Option::is_none")]
69    pub size: Option<Box<models::Vector>>,
70    ///  Determines if the layer should stretch along the parent's counter axis. This property is only provided for direct children of auto-layout frames.  - `INHERIT` - `STRETCH`  In previous versions of auto layout, determined how the layer is aligned inside an auto-layout frame. This property is only provided for direct children of auto-layout frames.  - `MIN` - `CENTER` - `MAX` - `STRETCH`  In horizontal auto-layout frames, \"MIN\" and \"MAX\" correspond to \"TOP\" and \"BOTTOM\". In vertical auto-layout frames, \"MIN\" and \"MAX\" correspond to \"LEFT\" and \"RIGHT\".
71    #[serde(rename = "layoutAlign", skip_serializing_if = "Option::is_none")]
72    pub layout_align: Option<LayoutAlign>,
73    /// This property is applicable only for direct children of auto-layout frames, ignored otherwise. Determines whether a layer should stretch along the parent's primary axis. A `0` corresponds to a fixed size and `1` corresponds to stretch.
74    #[serde(rename = "layoutGrow", skip_serializing_if = "Option::is_none")]
75    pub layout_grow: Option<f64>,
76    /// Determines whether a layer's size and position should be determined by auto-layout settings or manually adjustable.
77    #[serde(rename = "layoutPositioning", skip_serializing_if = "Option::is_none")]
78    pub layout_positioning: Option<LayoutPositioning>,
79    /// The minimum width of the frame. This property is only applicable for auto-layout frames or direct children of auto-layout frames.
80    #[serde(rename = "minWidth", skip_serializing_if = "Option::is_none")]
81    pub min_width: Option<f64>,
82    /// The maximum width of the frame. This property is only applicable for auto-layout frames or direct children of auto-layout frames.
83    #[serde(rename = "maxWidth", skip_serializing_if = "Option::is_none")]
84    pub max_width: Option<f64>,
85    /// The minimum height of the frame. This property is only applicable for auto-layout frames or direct children of auto-layout frames.
86    #[serde(rename = "minHeight", skip_serializing_if = "Option::is_none")]
87    pub min_height: Option<f64>,
88    /// The maximum height of the frame. This property is only applicable for auto-layout frames or direct children of auto-layout frames.
89    #[serde(rename = "maxHeight", skip_serializing_if = "Option::is_none")]
90    pub max_height: Option<f64>,
91    /// The horizontal sizing setting on this auto-layout frame or frame child. - `FIXED` - `HUG`: only valid on auto-layout frames and text nodes - `FILL`: only valid on auto-layout frame children
92    #[serde(rename = "layoutSizingHorizontal", skip_serializing_if = "Option::is_none")]
93    pub layout_sizing_horizontal: Option<LayoutSizingHorizontal>,
94    /// The vertical sizing setting on this auto-layout frame or frame child. - `FIXED` - `HUG`: only valid on auto-layout frames and text nodes - `FILL`: only valid on auto-layout frame children
95    #[serde(rename = "layoutSizingVertical", skip_serializing_if = "Option::is_none")]
96    pub layout_sizing_vertical: Option<LayoutSizingVertical>,
97    /// An array of fill paints applied to the node.
98    #[serde(rename = "fills")]
99    pub fills: Vec<models::Paint>,
100    /// A mapping of a StyleType to style ID (see Style) of styles present on this node. The style ID can be used to look up more information about the style in the top-level styles field.
101    #[serde(rename = "styles", skip_serializing_if = "Option::is_none")]
102    pub styles: Option<std::collections::HashMap<String, String>>,
103    /// An array of stroke paints applied to the node.
104    #[serde(rename = "strokes", skip_serializing_if = "Option::is_none")]
105    pub strokes: Option<Vec<models::Paint>>,
106    /// The weight of strokes on the node.
107    #[serde(rename = "strokeWeight", skip_serializing_if = "Option::is_none")]
108    pub stroke_weight: Option<f64>,
109    /// Position of stroke relative to vector outline, as a string enum  - `INSIDE`: stroke drawn inside the shape boundary - `OUTSIDE`: stroke drawn outside the shape boundary - `CENTER`: stroke drawn centered along the shape boundary
110    #[serde(rename = "strokeAlign", skip_serializing_if = "Option::is_none")]
111    pub stroke_align: Option<StrokeAlign>,
112    /// A string enum with value of \"MITER\", \"BEVEL\", or \"ROUND\", describing how corners in vector paths are rendered.
113    #[serde(rename = "strokeJoin", skip_serializing_if = "Option::is_none")]
114    pub stroke_join: Option<StrokeJoin>,
115    /// An array of floating point numbers describing the pattern of dash length and gap lengths that the vector stroke will use when drawn.  For example a value of [1, 2] indicates that the stroke will be drawn with a dash of length 1 followed by a gap of length 2, repeated.
116    #[serde(rename = "strokeDashes", skip_serializing_if = "Option::is_none")]
117    pub stroke_dashes: Option<Vec<f64>>,
118    /// Only specified if parameter `geometry=paths` is used. An array of paths representing the object fill.
119    #[serde(rename = "fillGeometry", skip_serializing_if = "Option::is_none")]
120    pub fill_geometry: Option<Vec<models::Path>>,
121    /// Only specified if parameter `geometry=paths` is used. An array of paths representing the object stroke.
122    #[serde(rename = "strokeGeometry", skip_serializing_if = "Option::is_none")]
123    pub stroke_geometry: Option<Vec<models::Path>>,
124    /// A string enum describing the end caps of vector paths.
125    #[serde(rename = "strokeCap", skip_serializing_if = "Option::is_none")]
126    pub stroke_cap: Option<StrokeCap>,
127    /// Only valid if `strokeJoin` is \"MITER\". The corner angle, in degrees, below which `strokeJoin` will be set to \"BEVEL\" to avoid super sharp corners. By default this is 28.96 degrees.
128    #[serde(rename = "strokeMiterAngle", skip_serializing_if = "Option::is_none")]
129    pub stroke_miter_angle: Option<f64>,
130    /// An array of export settings representing images to export from the node.
131    #[serde(rename = "exportSettings", skip_serializing_if = "Option::is_none")]
132    pub export_settings: Option<Vec<models::ExportSetting>>,
133    /// An array of effects attached to this node (see effects section for more details)
134    #[serde(rename = "effects")]
135    pub effects: Vec<models::Effect>,
136    /// Does this node mask sibling nodes in front of it?
137    #[serde(rename = "isMask", skip_serializing_if = "Option::is_none")]
138    pub is_mask: Option<bool>,
139    /// If this layer is a mask, this property describes the operation used to mask the layer's siblings. The value may be one of the following:  - ALPHA: the mask node's alpha channel will be used to determine the opacity of each pixel in the masked result. - VECTOR: if the mask node has visible fill paints, every pixel inside the node's fill regions will be fully visible in the masked result. If the mask has visible stroke paints, every pixel inside the node's stroke regions will be fully visible in the masked result. - LUMINANCE: the luminance value of each pixel of the mask node will be used to determine the opacity of that pixel in the masked result.
140    #[serde(rename = "maskType", skip_serializing_if = "Option::is_none")]
141    pub mask_type: Option<MaskType>,
142    /// True if maskType is VECTOR. This field is deprecated; use maskType instead.
143    #[serde(rename = "isMaskOutline", skip_serializing_if = "Option::is_none")]
144    pub is_mask_outline: Option<bool>,
145    /// Node ID of node to transition to in prototyping
146    #[serde(rename = "transitionNodeID", skip_serializing_if = "Option::is_none")]
147    pub transition_node_id: Option<String>,
148    /// The duration of the prototyping transition on this node (in milliseconds). This will override the default transition duration on the prototype, for this node.
149    #[serde(rename = "transitionDuration", skip_serializing_if = "Option::is_none")]
150    pub transition_duration: Option<f64>,
151    /// The easing curve used in the prototyping transition on this node.
152    #[serde(rename = "transitionEasing", skip_serializing_if = "Option::is_none")]
153    pub transition_easing: Option<models::EasingType>,
154    /// A string enum indicating the type of boolean operation applied.
155    #[serde(rename = "booleanOperation")]
156    pub boolean_operation: BooleanOperation,
157}
158
159impl BooleanOperationNode {
160    pub fn new(id: String, name: String, scroll_behavior: ScrollBehavior, blend_mode: models::BlendMode, children: Vec<models::SubcanvasNode>, fills: Vec<models::Paint>, effects: Vec<models::Effect>, boolean_operation: BooleanOperation) -> BooleanOperationNode {
161        BooleanOperationNode {
162            id,
163            name,
164            visible: None,
165            locked: None,
166            is_fixed: None,
167            scroll_behavior,
168            rotation: None,
169            component_property_references: None,
170            plugin_data: None,
171            shared_plugin_data: None,
172            bound_variables: None,
173            explicit_variable_modes: None,
174            blend_mode,
175            opacity: None,
176            children,
177            preserve_ratio: None,
178            constraints: None,
179            relative_transform: None,
180            size: None,
181            layout_align: None,
182            layout_grow: None,
183            layout_positioning: None,
184            min_width: None,
185            max_width: None,
186            min_height: None,
187            max_height: None,
188            layout_sizing_horizontal: None,
189            layout_sizing_vertical: None,
190            fills,
191            styles: None,
192            strokes: None,
193            stroke_weight: None,
194            stroke_align: None,
195            stroke_join: None,
196            stroke_dashes: None,
197            fill_geometry: None,
198            stroke_geometry: None,
199            stroke_cap: None,
200            stroke_miter_angle: None,
201            export_settings: None,
202            effects,
203            is_mask: None,
204            mask_type: None,
205            is_mask_outline: None,
206            transition_node_id: None,
207            transition_duration: None,
208            transition_easing: None,
209            boolean_operation,
210        }
211    }
212}
213/// How layer should be treated when the frame is resized
214#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
215pub enum ScrollBehavior {
216    #[serde(rename = "SCROLLS")]
217    Scrolls,
218    #[serde(rename = "FIXED")]
219    Fixed,
220    #[serde(rename = "STICKY_SCROLLS")]
221    StickyScrolls,
222}
223
224impl Default for ScrollBehavior {
225    fn default() -> ScrollBehavior {
226        Self::Scrolls
227    }
228}
229///  Determines if the layer should stretch along the parent's counter axis. This property is only provided for direct children of auto-layout frames.  - `INHERIT` - `STRETCH`  In previous versions of auto layout, determined how the layer is aligned inside an auto-layout frame. This property is only provided for direct children of auto-layout frames.  - `MIN` - `CENTER` - `MAX` - `STRETCH`  In horizontal auto-layout frames, \"MIN\" and \"MAX\" correspond to \"TOP\" and \"BOTTOM\". In vertical auto-layout frames, \"MIN\" and \"MAX\" correspond to \"LEFT\" and \"RIGHT\".
230#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
231pub enum LayoutAlign {
232    #[serde(rename = "INHERIT")]
233    Inherit,
234    #[serde(rename = "STRETCH")]
235    Stretch,
236    #[serde(rename = "MIN")]
237    Min,
238    #[serde(rename = "CENTER")]
239    Center,
240    #[serde(rename = "MAX")]
241    Max,
242}
243
244impl Default for LayoutAlign {
245    fn default() -> LayoutAlign {
246        Self::Inherit
247    }
248}
249/// Determines whether a layer's size and position should be determined by auto-layout settings or manually adjustable.
250#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
251pub enum LayoutPositioning {
252    #[serde(rename = "AUTO")]
253    Auto,
254    #[serde(rename = "ABSOLUTE")]
255    Absolute,
256}
257
258impl Default for LayoutPositioning {
259    fn default() -> LayoutPositioning {
260        Self::Auto
261    }
262}
263/// The horizontal sizing setting on this auto-layout frame or frame child. - `FIXED` - `HUG`: only valid on auto-layout frames and text nodes - `FILL`: only valid on auto-layout frame children
264#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
265pub enum LayoutSizingHorizontal {
266    #[serde(rename = "FIXED")]
267    Fixed,
268    #[serde(rename = "HUG")]
269    Hug,
270    #[serde(rename = "FILL")]
271    Fill,
272}
273
274impl Default for LayoutSizingHorizontal {
275    fn default() -> LayoutSizingHorizontal {
276        Self::Fixed
277    }
278}
279/// The vertical sizing setting on this auto-layout frame or frame child. - `FIXED` - `HUG`: only valid on auto-layout frames and text nodes - `FILL`: only valid on auto-layout frame children
280#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
281pub enum LayoutSizingVertical {
282    #[serde(rename = "FIXED")]
283    Fixed,
284    #[serde(rename = "HUG")]
285    Hug,
286    #[serde(rename = "FILL")]
287    Fill,
288}
289
290impl Default for LayoutSizingVertical {
291    fn default() -> LayoutSizingVertical {
292        Self::Fixed
293    }
294}
295/// Position of stroke relative to vector outline, as a string enum  - `INSIDE`: stroke drawn inside the shape boundary - `OUTSIDE`: stroke drawn outside the shape boundary - `CENTER`: stroke drawn centered along the shape boundary
296#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
297pub enum StrokeAlign {
298    #[serde(rename = "INSIDE")]
299    Inside,
300    #[serde(rename = "OUTSIDE")]
301    Outside,
302    #[serde(rename = "CENTER")]
303    Center,
304}
305
306impl Default for StrokeAlign {
307    fn default() -> StrokeAlign {
308        Self::Inside
309    }
310}
311/// A string enum with value of \"MITER\", \"BEVEL\", or \"ROUND\", describing how corners in vector paths are rendered.
312#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
313pub enum StrokeJoin {
314    #[serde(rename = "MITER")]
315    Miter,
316    #[serde(rename = "BEVEL")]
317    Bevel,
318    #[serde(rename = "ROUND")]
319    Round,
320}
321
322impl Default for StrokeJoin {
323    fn default() -> StrokeJoin {
324        Self::Miter
325    }
326}
327/// A string enum describing the end caps of vector paths.
328#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
329pub enum StrokeCap {
330    #[serde(rename = "NONE")]
331    None,
332    #[serde(rename = "ROUND")]
333    Round,
334    #[serde(rename = "SQUARE")]
335    Square,
336    #[serde(rename = "LINE_ARROW")]
337    LineArrow,
338    #[serde(rename = "TRIANGLE_ARROW")]
339    TriangleArrow,
340    #[serde(rename = "DIAMOND_FILLED")]
341    DiamondFilled,
342    #[serde(rename = "CIRCLE_FILLED")]
343    CircleFilled,
344    #[serde(rename = "TRIANGLE_FILLED")]
345    TriangleFilled,
346    #[serde(rename = "WASHI_TAPE_1")]
347    WashiTape1,
348    #[serde(rename = "WASHI_TAPE_2")]
349    WashiTape2,
350    #[serde(rename = "WASHI_TAPE_3")]
351    WashiTape3,
352    #[serde(rename = "WASHI_TAPE_4")]
353    WashiTape4,
354    #[serde(rename = "WASHI_TAPE_5")]
355    WashiTape5,
356    #[serde(rename = "WASHI_TAPE_6")]
357    WashiTape6,
358}
359
360impl Default for StrokeCap {
361    fn default() -> StrokeCap {
362        Self::None
363    }
364}
365/// If this layer is a mask, this property describes the operation used to mask the layer's siblings. The value may be one of the following:  - ALPHA: the mask node's alpha channel will be used to determine the opacity of each pixel in the masked result. - VECTOR: if the mask node has visible fill paints, every pixel inside the node's fill regions will be fully visible in the masked result. If the mask has visible stroke paints, every pixel inside the node's stroke regions will be fully visible in the masked result. - LUMINANCE: the luminance value of each pixel of the mask node will be used to determine the opacity of that pixel in the masked result.
366#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
367pub enum MaskType {
368    #[serde(rename = "ALPHA")]
369    Alpha,
370    #[serde(rename = "VECTOR")]
371    Vector,
372    #[serde(rename = "LUMINANCE")]
373    Luminance,
374}
375
376impl Default for MaskType {
377    fn default() -> MaskType {
378        Self::Alpha
379    }
380}
381/// A string enum indicating the type of boolean operation applied.
382#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
383pub enum BooleanOperation {
384    #[serde(rename = "UNION")]
385    Union,
386    #[serde(rename = "INTERSECT")]
387    Intersect,
388    #[serde(rename = "SUBTRACT")]
389    Subtract,
390    #[serde(rename = "EXCLUDE")]
391    Exclude,
392}
393
394impl Default for BooleanOperation {
395    fn default() -> BooleanOperation {
396        Self::Union
397    }
398}
399