eruption_sdk/color.rs
1/*
2 This file is part of Eruption.
3
4 Eruption is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
8
9 Eruption is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with Eruption. If not, see <http://www.gnu.org/licenses/>.
16
17 Copyright (c) 2019-2022, The Eruption Development Team
18*/
19
20/// Implements a RGBA color value
21#[derive(Debug, Default, Clone)]
22pub struct Color {
23 r: u8,
24 g: u8,
25 b: u8,
26 a: u8,
27}
28
29impl Color {
30 pub fn new(r: u8, g: u8, b: u8, a: u8) -> Self {
31 Self { r, g, b, a }
32 }
33
34 pub fn r(&self) -> u8 {
35 self.r
36 }
37
38 pub fn g(&self) -> u8 {
39 self.g
40 }
41
42 pub fn b(&self) -> u8 {
43 self.b
44 }
45
46 pub fn a(&self) -> u8 {
47 self.a
48 }
49
50 pub fn set_r(&mut self, val: u8) {
51 self.r = val
52 }
53
54 pub fn set_g(&mut self, val: u8) {
55 self.g = val
56 }
57
58 pub fn set_b(&mut self, val: u8) {
59 self.b = val
60 }
61
62 pub fn set_a(&mut self, val: u8) {
63 self.a = val
64 }
65}