public class Pixel
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private DigitalPicture |
picture
the digital picture this pixel belongs to
|
private int |
x
the x (column) location of this pixel in the picture; (0,0) is top left
|
private int |
y
the y (row) location of this pixel in the picture; (0,0) is top left
|
Constructor and Description |
---|
Pixel(DigitalPicture picture,
int x,
int y)
A constructor that takes the x and y location for the pixel and
the picture the pixel is coming from
|
Modifier and Type | Method and Description |
---|---|
double |
colorDistance(java.awt.Color testColor)
Method to get the distance between this pixel's color and the passed color
|
static double |
colorDistance(java.awt.Color color1,
java.awt.Color color2)
Method to compute the color distances between two color objects
|
private static int |
correctValue(int value)
Method to correct a color value to be within 0 to 255
|
int |
getAlpha()
Method to get the amount of alpha (transparency) at this pixel.
|
double |
getAverage()
Method to get the average of the colors of this pixel
|
int |
getBlue()
Method to get the amount of blue at this pixel.
|
static int |
getBlue(int value)
Method to get the blue value from a pixel represented as an int
|
int |
getCol()
Method to get the column (x value)
|
java.awt.Color |
getColor()
Method to get a color object that represents the color at this pixel.
|
int |
getGreen()
Method to get the amount of green at this pixel.
|
static int |
getGreen(int value)
Method to get the green value from a pixel represented as an int
|
int |
getRed()
Method to get the amount of red at this pixel.
|
static int |
getRed(int value)
Method to get the red value from a pixel represented as an int
|
int |
getRow()
Method to get the row (y value)
|
int |
getX()
Method to get the x location of this pixel.
|
int |
getY()
Method to get the y location of this pixel.
|
void |
setAlpha(int value)
Method to set the alpha (transparency) to a new alpha value
|
void |
setBlue(int value)
Method to set the blue to a new blue value
|
void |
setColor(java.awt.Color newColor)
Method to set the pixel color to the passed in color object.
|
void |
setGreen(int value)
Method to set the green to a new green value
|
void |
setRed(int value)
Method to set the red to a new red value
|
java.lang.String |
toString()
Method to return a string with information about this pixel
|
void |
updatePicture(int alpha,
int red,
int green,
int blue)
Method to update the picture based on the passed color
values for this pixel
|
private DigitalPicture picture
private int x
private int y
public Pixel(DigitalPicture picture, int x, int y)
picture
- the picture that the pixel is inx
- the x location of the pixel in the picturey
- the y location of the pixel in the picturepublic int getX()
public int getY()
public int getRow()
public int getCol()
public int getAlpha()
public int getRed()
public static int getRed(int value)
value
- the color value as an intpublic int getGreen()
public static int getGreen(int value)
value
- the color value as an intpublic int getBlue()
public static int getBlue(int value)
value
- the color value as an intpublic java.awt.Color getColor()
public void setColor(java.awt.Color newColor)
newColor
- the new color to usepublic void updatePicture(int alpha, int red, int green, int blue)
alpha
- the alpha (transparency) at this pixelred
- the red value for the color at this pixelgreen
- the green value for the color at this pixelblue
- the blue value for the color at this pixelprivate static int correctValue(int value)
value
- the value to usepublic void setRed(int value)
value
- the new value to usepublic void setGreen(int value)
value
- the value to usepublic void setBlue(int value)
value
- the new value to usepublic void setAlpha(int value)
value
- the new value to usepublic double colorDistance(java.awt.Color testColor)
testColor
- the color to compare topublic static double colorDistance(java.awt.Color color1, java.awt.Color color2)
color1
- a color objectcolor2
- a color objectpublic double getAverage()
public java.lang.String toString()
toString
in class java.lang.Object