figma_api/models/gradient_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 GradientPaint {
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 representing the paint's type. Always check the `type` before reading other properties.
26 #[serde(rename = "type")]
27 pub r#type: Type,
28 /// This field contains three vectors, each of which are a position in normalized object space (normalized object space is if the top left corner of the bounding box of the object is (0, 0) and the bottom right is (1,1)). The first position corresponds to the start of the gradient (value 0 for the purposes of calculating gradient stops), the second position is the end of the gradient (value 1), and the third handle position determines the width of the gradient.
29 #[serde(rename = "gradientHandlePositions")]
30 pub gradient_handle_positions: Vec<models::Vector>,
31 /// Positions of key points along the gradient axis with the colors anchored there. Colors along the gradient are interpolated smoothly between neighboring gradient stops.
32 #[serde(rename = "gradientStops")]
33 pub gradient_stops: Vec<models::ColorStop>,
34}
35
36impl GradientPaint {
37 pub fn new(blend_mode: models::BlendMode, r#type: Type, gradient_handle_positions: Vec<models::Vector>, gradient_stops: Vec<models::ColorStop>) -> GradientPaint {
38 GradientPaint {
39 visible: None,
40 opacity: None,
41 blend_mode,
42 r#type,
43 gradient_handle_positions,
44 gradient_stops,
45 }
46 }
47}
48/// The string literal representing the paint's type. Always check the `type` before reading other properties.
49#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
50pub enum Type {
51 #[serde(rename = "GRADIENT_LINEAR")]
52 GradientLinear,
53 #[serde(rename = "GRADIENT_RADIAL")]
54 GradientRadial,
55 #[serde(rename = "GRADIENT_ANGULAR")]
56 GradientAngular,
57 #[serde(rename = "GRADIENT_DIAMOND")]
58 GradientDiamond,
59}
60
61impl Default for Type {
62 fn default() -> Type {
63 Self::GradientLinear
64 }
65}
66