public class Pixel
extends java.lang.Object
Constructor and Description |
---|
Pixel(RasterImage picture,
int x,
int y)
A constructor that take 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)
Determines the distance between this pixel's color and the passed color.
|
int |
getAlpha()
Accessor for this pixel's alpha value (transparency).
|
double |
getAverage()
Determines the average value of the three colour components of this pixel
|
int |
getBlue()
Accessor for this pixel's blue value.
|
java.awt.Color |
getColor()
Accessor for this pixel's colour.
|
int |
getGreen()
Accessor for this pixel's green value.
|
int |
getRed()
Accessor for this pixel's red value.
|
int |
getX()
Accessor for the x location of this pixel.
|
int |
getY()
Accessor for the y location of this pixel.
|
void |
setAlpha(int value)
Mutates this pixel's alpha value to the passed value, provided the passed
value falls within the interval [0,255].
|
void |
setBlue(int value)
Mutates this pixel's blue colour value to the passed value, provided the
passed value falls within the interval [0,255].
|
void |
setColor(java.awt.Color newColor)
Mutates this pixel's colour to the passed color.
|
void |
setGreen(int value)
Mutates this pixel's green colour value to the passed value, provided the
passed value falls within the interval [0,255].
|
void |
setRed(int value)
Mutates this pixel's red colour value to the passed value, provided the
passed value falls within the interval [0,255].
|
java.lang.String |
toString()
Returns a string descriptor about the 3 colour components of this pixel.
|
void |
updatePicture(int alpha,
int red,
int green,
int blue)
Mutates this pixel's colour to the passed color, as represented by the
tuple of values described below.
|
public Pixel(RasterImage 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 getAlpha()
public int getRed()
public int getGreen()
public int getBlue()
public 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) value that the pixel should havered
- the red value for the color that the pixel should havegreen
- the green value for the color that the pixel should haveblue
- the blue value for the color that the pixel should havepublic 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 which to comparepublic double getAverage()
public java.lang.String toString()
toString
in class java.lang.Object