Beatmup Java package
FloatColor.java
1 /*
2  Beatmup image and signal processing library
3  Copyright (C) 2019, lnstadrum
4 
5  This program is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 
19 package Beatmup.Imaging;
20 
21 /**
22  * Floating-point RGBA color value.
23  */
24 public class FloatColor {
25  public float r; //!< red
26  public float g; //!< green
27  public float b; //!< blue
28  public float a; //!< alpha
29 
30  /**
31  * Creates a zero-valued color.
32  */
33  public FloatColor() {
34  r = g = b = a = 0;
35  }
36 
37  /**
38  * Creates a color by aggregating the four channels values components
39  * @param r the red channel value
40  * @param g the green channel value
41  * @param b the blue channel value
42  * @param a the alpha channel value
43  */
44  public FloatColor(float r, float g, float b, float a) {
45  this.r = r;
46  this.g = g;
47  this.b = b;
48  this.a = a;
49  // This constructor is called by JNI, do not remove it.
50  }
51 
52  /**
53  * @return an integer approximation of the current color mapping [0, 1] input range to [0, 255] output range.
54  */
55  public Color getIntColor() {
56  return new Color(Math.round(r * 255), Math.round(g * 255), Math.round(b * 255), Math.round(a * 255));
57  }
58 }
Integer RGBA color value.
Definition: Color.java:24
Floating-point RGBA color value.
Definition: FloatColor.java:24
FloatColor()
Creates a zero-valued color.
Definition: FloatColor.java:33
FloatColor(float r, float g, float b, float a)
Creates a color by aggregating the four channels values components.
Definition: FloatColor.java:44