RobotCore
1.0
WPILib port to raspberry Pi
Toggle main menu visibility
Loading...
Searching...
No Matches
Color8Bit.java
1
// Copyright (c) FIRST and other WPILib contributors.
2
// Open Source Software; you can modify and/or share it under the terms of
3
// the WPILib BSD license file in the root directory of this project.
4
5
package
org.wpilib.util;
6
7
import
java.util.Objects;
8
10
public
class
Color8Bit
{
12
public
final
int
red
;
13
15
public
final
int
green
;
16
18
public
final
int
blue
;
19
21
public
Color8Bit
() {
22
red
= 0;
23
green
= 0;
24
blue
= 0;
25
}
26
34
public
Color8Bit
(
int
red
,
int
green
,
int
blue
) {
35
this.red = Math.clamp(
red
, 0, 255);
36
this.green = Math.clamp(
green
, 0, 255);
37
this.blue = Math.clamp(
blue
, 0, 255);
38
}
39
45
public
Color8Bit
(
Color
color) {
46
this
((int) (color.red * 255), (int) (color.green * 255), (int) (color.blue * 255));
47
}
48
55
public
Color8Bit
(String hexString) {
56
if
(hexString.length() != 7 || !hexString.startsWith(
"#"
)) {
57
throw
new
IllegalArgumentException(
"Invalid hex string \""
+ hexString +
"\""
);
58
}
59
60
this.red = Integer.valueOf(hexString.substring(1, 3), 16);
61
this.green = Integer.valueOf(hexString.substring(3, 5), 16);
62
this.blue = Integer.valueOf(hexString.substring(5, 7), 16);
63
}
64
65
@Override
66
public
boolean
equals(Object other) {
67
if
(
this
== other) {
68
return
true
;
69
}
70
if
(other ==
null
) {
71
return
false
;
72
}
73
74
return
other instanceof
Color8Bit
color8Bit
75
&&
red
== color8Bit.red
76
&&
green
== color8Bit.green
77
&&
blue
== color8Bit.blue;
78
}
79
80
@Override
81
public
int
hashCode() {
82
return
Objects.hash(
red
,
green
,
blue
);
83
}
84
85
@Override
86
public
String toString() {
87
return
toHexString
();
88
}
89
95
public
String
toHexString
() {
96
return
String.format(
"#%02X%02X%02X"
,
red
,
green
,
blue
);
97
}
98
}
org.wpilib.util.Color8Bit.Color8Bit
Color8Bit(Color color)
Definition
Color8Bit.java:45
org.wpilib.util.Color8Bit.blue
final int blue
Definition
Color8Bit.java:18
org.wpilib.util.Color8Bit.Color8Bit
Color8Bit()
Definition
Color8Bit.java:21
org.wpilib.util.Color8Bit.Color8Bit
Color8Bit(String hexString)
Definition
Color8Bit.java:55
org.wpilib.util.Color8Bit.green
final int green
Definition
Color8Bit.java:15
org.wpilib.util.Color8Bit.Color8Bit
Color8Bit(int red, int green, int blue)
Definition
Color8Bit.java:34
org.wpilib.util.Color8Bit.toHexString
String toHexString()
Definition
Color8Bit.java:95
org.wpilib.util.Color8Bit.red
final int red
Definition
Color8Bit.java:12
org.wpilib.util.Color
Definition
Color.java:14
org
wpilib
util
Color8Bit.java
Generated by
1.18.0