rive_rs/shapes/paint/
blend_mode.rs

1// Copyright 2021 The Fuchsia Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5use crate::core::TryFromU64;
6
7#[derive(Clone, Copy, Debug, Eq, PartialEq)]
8pub enum BlendMode {
9    SrcOver,
10    Screen,
11    Overlay,
12    Darken,
13    Lighten,
14    ColorDodge,
15    ColorBurn,
16    HardLight,
17    SoftLight,
18    Difference,
19    Exclusion,
20    Multiply,
21    Hue,
22    Saturation,
23    Color,
24    Luminosity,
25}
26
27impl Default for BlendMode {
28    fn default() -> Self {
29        Self::SrcOver
30    }
31}
32
33impl TryFromU64 for BlendMode {
34    fn try_from(val: u64) -> Option<Self> {
35        match val {
36            3 => Some(Self::SrcOver),
37            14 => Some(Self::Screen),
38            15 => Some(Self::Overlay),
39            16 => Some(Self::Darken),
40            17 => Some(Self::Lighten),
41            18 => Some(Self::ColorDodge),
42            19 => Some(Self::ColorBurn),
43            20 => Some(Self::HardLight),
44            21 => Some(Self::SoftLight),
45            22 => Some(Self::Difference),
46            23 => Some(Self::Exclusion),
47            24 => Some(Self::Multiply),
48            25 => Some(Self::Hue),
49            26 => Some(Self::Saturation),
50            27 => Some(Self::Color),
51            28 => Some(Self::Luminosity),
52            _ => None,
53        }
54    }
55}