public class ColorSensor extends Part
Modifier and Type | Field and Description |
---|---|
static int[][] |
colorCubes
Color cubes for detecting color labels.
6 user adaptable int arrays with red_min, red_max, green_min, green_max, blue_min, blue_max
for the colors Black, Blue, Green, Yellow, Red, White.
|
Constructor and Description |
---|
ColorSensor()
Creates a sensor instance connected to port S1.
|
ColorSensor(SensorPort port)
Creates a sensor instance connected to the given port.
|
Modifier and Type | Method and Description |
---|---|
java.awt.Color |
getColor()
Returns the color detected by the color sensor at the current location.
|
int |
getColorID()
Returns a integer number ID for the current color reading.
|
ColorLabel |
getColorLabel()
Returns one of the enums of ColorLabel.
|
java.lang.String |
getColorStr()
Returns the name of the enums of ColorLabel.
|
int |
getLightValue()
Returns the brightness (scaled intensity in the HSB color model)
detected by the light sensor at the current location.
|
SensorPort |
getPort()
Returns the port of the sensor.
|
static boolean |
inColorCube(java.awt.Color color,
int[] colorCube)
Checks if given color lies within given color cube.
|
public static int[][] colorCubes
ColorSensor.colorCubes[1] = new int[]{0, 2, 0, 2, 0, 2};
public ColorSensor(SensorPort port)
port
- the port where the sensor is plugged-inpublic ColorSensor()
public int getLightValue()
public java.awt.Color getColor()
public int getColorID()
public ColorLabel getColorLabel()
public java.lang.String getColorStr()
public static boolean inColorCube(java.awt.Color color, int[] colorCube)
color
- the color to checkcolorCube
- an integer array of 6 boundary values in the order:
red_min, red_max, green_min, green_max, blue_min, blue_maxpublic SensorPort getPort()