public final class Image
extends java.lang.Object
Image
class represents an image that can be drawn to.
This class will store all colors in a packed int
. The format used is the same as Image.PackedIntComponentOrder.ARGB
.
Most methods take colors as parameter arguments. These are r
, g
and b
, or r
, g
, b
and a
. All of them are stored as float
s, with an expected range of [0.0F, 1.0F]
. Any value
outside of this range will be saturated. Calling setColor(0, 0, -1.0F, 0.5F, 2.0F)
will effectively be equivalent to setColor(0, 0, 0.0F, 0.5F, 1.0F)
.
Methods that only take r
, g
and b
as parameter arguments, will treat a
as 1.0F
.
Modifier and Type | Class and Description |
---|---|
static class |
Image.ArrayComponentOrder
An
ArrayComponentOrder is used to tell us what order the R-, G-, B- and A-components are stored in arrays. |
static class |
Image.PackedIntComponentOrder
A
PackedIntComponentOrder is used to tell us what order the R-, G-, B- and A-components are stored in an int , in a packed form. |
Constructor and Description |
---|
Image()
Constructs a new
Image instance. |
Image(int resolutionX,
int resolutionY)
Constructs a new
Image instance. |
Image(int resolutionX,
int resolutionY,
byte[] array)
Constructs a new
Image instance. |
Image(int resolutionX,
int resolutionY,
byte[] array,
Image.ArrayComponentOrder arrayComponentOrder)
Constructs a new
Image instance. |
Image(int resolutionX,
int resolutionY,
int[] array)
Constructs a new
Image instance. |
Image(int resolutionX,
int resolutionY,
int[] array,
Image.ArrayComponentOrder arrayComponentOrder)
Constructs a new
Image instance. |
Image(int resolutionX,
int resolutionY,
int[] array,
Image.PackedIntComponentOrder packedIntComponentOrder)
Constructs a new
Image instance. |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clears the image with a color of black.
|
void |
clear(float r,
float g,
float b)
Clears the image with a color of
r , g and b . |
void |
clear(float r,
float g,
float b,
float a)
Clears the image with a color of
r , g , b and a . |
void |
drawCircle(int x,
int y,
int radius)
Draws a circle with a center point of
x and y and a radius of radius , with a color of black. |
void |
drawCircle(int x,
int y,
int radius,
float r,
float g,
float b)
Draws a circle with a center point of
x and y and a radius of radius , with a color of r , g and b . |
void |
drawCircle(int x,
int y,
int radius,
float r,
float g,
float b,
float a)
Draws a circle with a center point of
x and y and a radius of radius , with a color of r , g , b and a . |
void |
drawLine(int startX,
int startY,
int endX,
int endY)
Draws a line from
startX and startY to endX and endY , with a color of black. |
void |
drawLine(int startX,
int startY,
int endX,
int endY,
float r,
float g,
float b)
Draws a line from
startX and startY to endX and endY , with a color of r , g and b . |
void |
drawLine(int startX,
int startY,
int endX,
int endY,
float r,
float g,
float b,
float a)
Draws a line from
startX and startY to endX and endY , with a color of r , g , b and a . |
void |
drawRectangle(int x,
int y,
int w,
int h)
Draws a rectangle from
x and y to x + w - 1 and y + h - 1 , with a color of black. |
void |
drawRectangle(int x,
int y,
int w,
int h,
float r,
float g,
float b)
Draws a rectangle from
x and y to x + w - 1 and y + h - 1 , with a color of r , g and b . |
void |
drawRectangle(int x,
int y,
int w,
int h,
float r,
float g,
float b,
float a)
Draws a rectangle from
x and y to x + w - 1 and y + h - 1 , with a color of r , g , b and a . |
void |
drawTriangle(int aX,
int aY,
int bX,
int bY,
int cX,
int cY)
Draws a triangle from three points, denoted
A , B and C , with a color of black. |
void |
drawTriangle(int aX,
int aY,
int bX,
int bY,
int cX,
int cY,
float r,
float g,
float b)
Draws a triangle from three points, denoted
A , B and C , with a color of r , g and b . |
void |
drawTriangle(int aX,
int aY,
int bX,
int bY,
int cX,
int cY,
float r,
float g,
float b,
float a)
Draws a triangle from three points, denoted
A , B and C , with a color of r , g , b and a . |
void |
fillCircle(int x,
int y,
int radius)
Fills a circle with a center point of
x and y and a radius of radius , with a color of black. |
void |
fillCircle(int x,
int y,
int radius,
float r,
float g,
float b)
Fills a circle with a center point of
x and y and a radius of radius , with a color of r , g and b . |
void |
fillCircle(int x,
int y,
int radius,
float r,
float g,
float b,
float a)
Fills a circle with a center point of
x and y and a radius of radius , with a color of r , g , b and a . |
void |
fillRectangle(int x,
int y,
int w,
int h)
Fills a rectangle from
x and y to x + w - 1 and y + h - 1 , with a color of black. |
void |
fillRectangle(int x,
int y,
int w,
int h,
float r,
float g,
float b)
Fills a rectangle from
x and y to x + w - 1 and y + h - 1 , with a color of r , g and b . |
void |
fillRectangle(int x,
int y,
int w,
int h,
float r,
float g,
float b,
float a)
Fills a rectangle from
x and y to x + w - 1 and y + h - 1 , with a color of r , g , b and a . |
void |
fillTriangle(int aX,
int aY,
int bX,
int bY,
int cX,
int cY)
Fills a triangle from three points, denoted
A , B and C , with a color of black. |
void |
fillTriangle(int aX,
int aY,
int bX,
int bY,
int cX,
int cY,
float r,
float g,
float b)
Fills a triangle from three points, denoted
A , B and C , with a color of r , g and b . |
void |
fillTriangle(int aX,
int aY,
int bX,
int bY,
int cX,
int cY,
float r,
float g,
float b,
float a)
Fills a triangle from three points, denoted
A , B and C , with a color of r , g , b and a . |
float |
getA(int x,
int y)
Returns the A-component of the color at
x and y as a float in the range [0.0, 1.0] . |
int[] |
getArray()
Returns a clone of the array that stores the colors.
|
float |
getB(int x,
int y)
Returns the B-component of the color at
x and y as a float in the range [0.0, 1.0] . |
float |
getG(int x,
int y)
Returns the G-component of the color at
x and y as a float in the range [0.0, 1.0] . |
float |
getR(int x,
int y)
Returns the R-component of the color at
x and y as a float in the range [0.0, 1.0] . |
int |
getResolutionX()
Returns the resolution along the X-axis, also known as the width.
|
int |
getResolutionY()
Returns the resolution along the Y-axis, also known as the height.
|
void |
save(java.io.File file)
Saves this
Image as a .PNG image to the file represented by file . |
void |
save(java.lang.String filename)
Saves this
Image as a .PNG image to the file represented by the filename filename . |
void |
setColor(int x,
int y,
float r,
float g,
float b)
Sets the color of
x and y to r , g and b . |
void |
setColor(int x,
int y,
float r,
float g,
float b,
float a)
Sets the color of
x and y to r , g , b and a . |
java.awt.image.BufferedImage |
toBufferedImage()
Returns a
BufferedImage representation of this Image instance. |
byte[] |
toByteArray()
Returns a
byte array representation of this Image instance. |
byte[] |
toByteArray(Image.ArrayComponentOrder arrayComponentOrder)
Returns a
byte array representation of this Image instance. |
int[] |
toIntArray()
Returns an
int array representation of this Image instance. |
int[] |
toIntArray(Image.PackedIntComponentOrder packedIntComponentOrder)
Returns an
int array representation of this Image instance. |
public Image()
Image
instance.
Calling this constructor is equivalent to new Image(800, 800)
.
public Image(int resolutionX, int resolutionY)
Image
instance.resolutionX
- the resolution along the X-axis, also known as the widthresolutionY
- the resolution along the Y-axis, also known as the heightpublic Image(int resolutionX, int resolutionY, byte[] array)
Image
instance.
Calling this constructor is equivalent to new Image(resolutionX, resolutionY, array, ArrayComponentOrder.BGRA)
.
It is expected that array.length
is the same as resolutionX * resolutionY * ArrayComponentOrder.BGRA.getComponentCount()
.
If array
is null
, a NullPointerException
will be thrown.
If array.length
is incorrect, an IllegalArgumentException
will be thrown.
resolutionX
- the resolution along the X-axis, also known as the widthresolutionY
- the resolution along the Y-axis, also known as the heightarray
- the array to create this Image
instance fromjava.lang.IllegalArgumentException
- thrown if, and only if, array.length
is incorrectjava.lang.NullPointerException
- thrown if, and only if, array
is null
public Image(int resolutionX, int resolutionY, byte[] array, Image.ArrayComponentOrder arrayComponentOrder)
Image
instance.
It is expected that array.length
is the same as resolutionX * resolutionY * arrayComponentOrder.getComponentCount()
.
If either array
or arrayComponentOrder
are null
, a NullPointerException
will be thrown.
If array.length
is incorrect, an IllegalArgumentException
will be thrown.
resolutionX
- the resolution along the X-axis, also known as the widthresolutionY
- the resolution along the Y-axis, also known as the heightarray
- the array to create this Image
instance fromarrayComponentOrder
- an Image.ArrayComponentOrder
to get the components from array
in the correct orderjava.lang.IllegalArgumentException
- thrown if, and only if, array.length
is incorrectjava.lang.NullPointerException
- thrown if, and only if, either array
or arrayComponentOrder
are null
public Image(int resolutionX, int resolutionY, int[] array)
Image
instance.
Calling this constructor is equivalent to new Image(resolutionX, resolutionY, array, PackedIntComponentOrder.ARGB)
.
It is expected that array.length
is the same as resolutionX * resolutionY
.
If array
is null
, a NullPointerException
will be thrown.
If array.length
is incorrect, an IllegalArgumentException
will be thrown.
resolutionX
- the resolution along the X-axis, also known as the widthresolutionY
- the resolution along the Y-axis, also known as the heightarray
- the array to create this Image
instance fromjava.lang.IllegalArgumentException
- thrown if, and only if, array.length
is incorrectjava.lang.NullPointerException
- thrown if, and only if, array
is null
public Image(int resolutionX, int resolutionY, int[] array, Image.ArrayComponentOrder arrayComponentOrder)
Image
instance.
It is expected that array.length
is the same as resolutionX * resolutionY * arrayComponentOrder.getComponentCount()
.
If either array
or arrayComponentOrder
are null
, a NullPointerException
will be thrown.
If array.length
is incorrect, an IllegalArgumentException
will be thrown.
resolutionX
- the resolution along the X-axis, also known as the widthresolutionY
- the resolution along the Y-axis, also known as the heightarray
- the array to create this Image
instance fromarrayComponentOrder
- an Image.ArrayComponentOrder
to get the components from array
in the correct orderjava.lang.IllegalArgumentException
- thrown if, and only if, array.length
is incorrectjava.lang.NullPointerException
- thrown if, and only if, either array
or arrayComponentOrder
are null
public Image(int resolutionX, int resolutionY, int[] array, Image.PackedIntComponentOrder packedIntComponentOrder)
Image
instance.
It is expected that array.length
is the same as resolutionX * resolutionY
.
If either array
or packedIntComponentOrder
are null
, a NullPointerException
will be thrown.
If array.length
is incorrect, an IllegalArgumentException
will be thrown.
resolutionX
- the resolution along the X-axis, also known as the widthresolutionY
- the resolution along the Y-axis, also known as the heightarray
- the array to create this Image
instance frompackedIntComponentOrder
- a Image.PackedIntComponentOrder
to get the components from the int
values of the array
in the correct orderjava.lang.IllegalArgumentException
- thrown if, and only if, array.length
is incorrectjava.lang.NullPointerException
- thrown if, and only if, either array
or packedIntComponentOrder
are null
public java.awt.image.BufferedImage toBufferedImage()
BufferedImage
representation of this Image
instance.BufferedImage
representation of this Image
instancepublic byte[] toByteArray()
byte
array representation of this Image
instance.
Calling this method is equivalent to toByteArray(ArrayComponentOrder.BGRA)
.
byte
array representation of this Image
instancepublic byte[] toByteArray(Image.ArrayComponentOrder arrayComponentOrder)
byte
array representation of this Image
instance.
The R-, G-, B- and A-components will be ordered according to arrayComponentOrder
.
If arrayComponentOrder
is null
, a NullPointerException
will be thrown.
arrayComponentOrder
- an Image.ArrayComponentOrder
byte
array representation of this Image
instancejava.lang.NullPointerException
- thrown if, and only if, arrayComponentOrder
is null
public float getA(int x, int y)
x
and y
as a float
in the range [0.0, 1.0]
.
If x
or y
are outside the image, 0.0F
will be returned.
x
- the X-coordinate of the colory
- the Y-coordinate of the colorx
and y
as a float
in the range [0.0, 1.0]
public float getB(int x, int y)
x
and y
as a float
in the range [0.0, 1.0]
.
If x
or y
are outside the image, 0.0F
will be returned.
x
- the X-coordinate of the colory
- the Y-coordinate of the colorx
and y
as a float
in the range [0.0, 1.0]
public float getG(int x, int y)
x
and y
as a float
in the range [0.0, 1.0]
.
If x
or y
are outside the image, 0.0F
will be returned.
x
- the X-coordinate of the colory
- the Y-coordinate of the colorx
and y
as a float
in the range [0.0, 1.0]
public float getR(int x, int y)
x
and y
as a float
in the range [0.0, 1.0]
.
If x
or y
are outside the image, 0.0F
will be returned.
x
- the X-coordinate of the colory
- the Y-coordinate of the colorx
and y
as a float
in the range [0.0, 1.0]
public int getResolutionX()
public int getResolutionY()
public int[] getArray()
public int[] toIntArray()
int
array representation of this Image
instance.
Calling this method is equivalent to toIntArray(PackedIntComponentOrder.ARGB)
.
int
array representation of this Image
instancepublic int[] toIntArray(Image.PackedIntComponentOrder packedIntComponentOrder)
int
array representation of this Image
instance.
The R-, G-, B- and A-components will be ordered according to packedIntComponentOrder
.
If packedIntComponentOrder
is null
, a NullPointerException
will be thrown.
packedIntComponentOrder
- a Image.PackedIntComponentOrder
int
array representation of this Image
instancejava.lang.NullPointerException
- thrown if, and only if, packedIntComponentOrder
is null
public void clear()
Calling this method is equivalent to clear(0.0F, 0.0F, 0.0F)
.
public void clear(float r, float g, float b)
r
, g
and b
.
Calling this method is equivalent to clear(r, g, b, 1.0F)
.
r
- the R-component of the colorg
- the G-component of the colorb
- the B-component of the colorpublic void clear(float r, float g, float b, float a)
r
, g
, b
and a
.r
- the R-component of the colorg
- the G-component of the colorb
- the B-component of the colora
- the A-component of the colorpublic void drawCircle(int x, int y, int radius)
x
and y
and a radius of radius
, with a color of black.
Only the parts of the circle that are inside the image will be drawn.
Calling this method is equivalent to drawCircle(x, y, radius, 0.0F, 0.0F, 0.0F)
.
x
- the X-coordinate of the center point of the circley
- the Y-coordinate of the center point of the circleradius
- the radius of the circlepublic void drawCircle(int x, int y, int radius, float r, float g, float b)
x
and y
and a radius of radius
, with a color of r
, g
and b
.
Only the parts of the circle that are inside the image will be drawn.
Calling this method is equivalent to drawCircle(x, y, radius, r, g, b, 1.0F)
.
x
- the X-coordinate of the center point of the circley
- the Y-coordinate of the center point of the circleradius
- the radius of the circler
- the R-component of the colorg
- the G-component of the colorb
- the B-component of the colorpublic void drawCircle(int x, int y, int radius, float r, float g, float b, float a)
x
and y
and a radius of radius
, with a color of r
, g
, b
and a
.
Only the parts of the circle that are inside the image will be drawn.
x
- the X-coordinate of the center point of the circley
- the Y-coordinate of the center point of the circleradius
- the radius of the circler
- the R-component of the colorg
- the G-component of the colorb
- the B-component of the colora
- the A-component of the colorpublic void drawLine(int startX, int startY, int endX, int endY)
startX
and startY
to endX
and endY
, with a color of black.
Only the parts of the line that are inside the image will be drawn.
Calling this method is equivalent to drawLine(startX, startY, endX, endY, 0.0F, 0.0F, 0.0F)
.
startX
- the X-coordinate to start the line atstartY
- the Y-coordinate to start the line atendX
- the X-coordinate to end the line atendY
- the Y-coordinate to end the line atpublic void drawLine(int startX, int startY, int endX, int endY, float r, float g, float b)
startX
and startY
to endX
and endY
, with a color of r
, g
and b
.
Only the parts of the line that are inside the image will be drawn.
Calling this method is equivalent to drawLine(startX, startY, endX, endY, r, g, b, 1.0F)
.
startX
- the X-coordinate to start the line atstartY
- the Y-coordinate to start the line atendX
- the X-coordinate to end the line atendY
- the Y-coordinate to end the line atr
- the R-component of the colorg
- the G-component of the colorb
- the B-component of the colorpublic void drawLine(int startX, int startY, int endX, int endY, float r, float g, float b, float a)
startX
and startY
to endX
and endY
, with a color of r
, g
, b
and a
.
Only the parts of the line that are inside the image will be drawn.
startX
- the X-coordinate to start the line atstartY
- the Y-coordinate to start the line atendX
- the X-coordinate to end the line atendY
- the Y-coordinate to end the line atr
- the R-component of the colorg
- the G-component of the colorb
- the B-component of the colora
- the A-component of the colorpublic void drawRectangle(int x, int y, int w, int h)
x
and y
to x + w - 1
and y + h - 1
, with a color of black.
Only the parts of the rectangle that are inside the image will be drawn.
Calling this method is equivalent to drawRectangle(x, y, w, h, 0.0F, 0.0F, 0.0F)
.
x
- the X-coordinate to start the rectangle aty
- the Y-coordinate to start the rectangle atw
- the width of the rectangleh
- the height of the rectanglepublic void drawRectangle(int x, int y, int w, int h, float r, float g, float b)
x
and y
to x + w - 1
and y + h - 1
, with a color of r
, g
and b
.
Only the parts of the rectangle that are inside the image will be drawn.
Calling this method is equivalent to drawRectangle(x, y, w, h, r, g, b, 1.0F)
.
x
- the X-coordinate to start the rectangle aty
- the Y-coordinate to start the rectangle atw
- the width of the rectangleh
- the height of the rectangler
- the R-component of the colorg
- the G-component of the colorb
- the B-component of the colorpublic void drawRectangle(int x, int y, int w, int h, float r, float g, float b, float a)
x
and y
to x + w - 1
and y + h - 1
, with a color of r
, g
, b
and a
.
Only the parts of the rectangle that are inside the image will be drawn.
x
- the X-coordinate to start the rectangle aty
- the Y-coordinate to start the rectangle atw
- the width of the rectangleh
- the height of the rectangler
- the R-component of the colorg
- the G-component of the colorb
- the B-component of the colora
- the A-component of the colorpublic void drawTriangle(int aX, int aY, int bX, int bY, int cX, int cY)
A
, B
and C
, with a color of black.
Only the parts of the triangle that are inside the image will be drawn.
Calling this method is equivalent to drawTriangle(aX, aY, bX, bY, cX, cY, 0.0F, 0.0F, 0.0F)
.
aX
- the X-coordinate of the point A
aY
- the Y-coordinate of the point A
bX
- the X-coordinate of the point B
bY
- the Y-coordinate of the point B
cX
- the X-coordinate of the point C
cY
- the Y-coordinate of the point C
public void drawTriangle(int aX, int aY, int bX, int bY, int cX, int cY, float r, float g, float b)
A
, B
and C
, with a color of r
, g
and b
.
Only the parts of the triangle that are inside the image will be drawn.
Calling this method is equivalent to drawTriangle(aX, aY, bX, bY, cX, cY, r, g, b, 1.0F)
.
aX
- the X-coordinate of the point A
aY
- the Y-coordinate of the point A
bX
- the X-coordinate of the point B
bY
- the Y-coordinate of the point B
cX
- the X-coordinate of the point C
cY
- the Y-coordinate of the point C
r
- the R-component of the colorg
- the G-component of the colorb
- the B-component of the colorpublic void drawTriangle(int aX, int aY, int bX, int bY, int cX, int cY, float r, float g, float b, float a)
A
, B
and C
, with a color of r
, g
, b
and a
.
Only the parts of the triangle that are inside the image will be drawn.
aX
- the X-coordinate of the point A
aY
- the Y-coordinate of the point A
bX
- the X-coordinate of the point B
bY
- the Y-coordinate of the point B
cX
- the X-coordinate of the point C
cY
- the Y-coordinate of the point C
r
- the R-component of the colorg
- the G-component of the colorb
- the B-component of the colora
- the A-component of the colorpublic void fillCircle(int x, int y, int radius)
x
and y
and a radius of radius
, with a color of black.
Only the parts of the circle that are inside the image will be filled.
Calling this method is equivalent to fillCircle(x, y, radius, 0.0F, 0.0F, 0.0F)
.
x
- the X-coordinate of the center point of the circley
- the Y-coordinate of the center point of the circleradius
- the radius of the circlepublic void fillCircle(int x, int y, int radius, float r, float g, float b)
x
and y
and a radius of radius
, with a color of r
, g
and b
.
Only the parts of the circle that are inside the image will be filled.
Calling this method is equivalent to fillCircle(x, y, radius, r, g, b, 1.0F)
.
x
- the X-coordinate of the center point of the circley
- the Y-coordinate of the center point of the circleradius
- the radius of the circler
- the R-component of the colorg
- the G-component of the colorb
- the B-component of the colorpublic void fillCircle(int x, int y, int radius, float r, float g, float b, float a)
x
and y
and a radius of radius
, with a color of r
, g
, b
and a
.
Only the parts of the circle that are inside the image will be filled.
x
- the X-coordinate of the center point of the circley
- the Y-coordinate of the center point of the circleradius
- the radius of the circler
- the R-component of the colorg
- the G-component of the colorb
- the B-component of the colora
- the A-component of the colorpublic void fillRectangle(int x, int y, int w, int h)
x
and y
to x + w - 1
and y + h - 1
, with a color of black.
Only the parts of the rectangle that are inside the image will be filled.
Calling this method is equivalent to fillRectangle(x, y, w, h, 0.0F, 0.0F, 0.0F)
.
x
- the X-coordinate to start the rectangle aty
- the Y-coordinate to start the rectangle atw
- the width of the rectangleh
- the height of the rectanglepublic void fillRectangle(int x, int y, int w, int h, float r, float g, float b)
x
and y
to x + w - 1
and y + h - 1
, with a color of r
, g
and b
.
Only the parts of the rectangle that are inside the image will be filled.
Calling this method is equivalent to fillRectangle(x, y, w, h, r, g, b, 1.0F)
.
x
- the X-coordinate to start the rectangle aty
- the Y-coordinate to start the rectangle atw
- the width of the rectangleh
- the height of the rectangler
- the R-component of the colorg
- the G-component of the colorb
- the B-component of the colorpublic void fillRectangle(int x, int y, int w, int h, float r, float g, float b, float a)
x
and y
to x + w - 1
and y + h - 1
, with a color of r
, g
, b
and a
.
Only the parts of the rectangle that are inside the image will be filled.
x
- the X-coordinate to start the rectangle aty
- the Y-coordinate to start the rectangle atw
- the width of the rectangleh
- the height of the rectangler
- the R-component of the colorg
- the G-component of the colorb
- the B-component of the colora
- the A-component of the colorpublic void fillTriangle(int aX, int aY, int bX, int bY, int cX, int cY)
A
, B
and C
, with a color of black.
Only the parts of the triangle that are inside the image will be filled.
Calling this method is equivalent to fillTriangle(aX, aY, bX, bY, cX, cY, 0.0F, 0.0F, 0.0F)
.
aX
- the X-coordinate of the point A
aY
- the Y-coordinate of the point A
bX
- the X-coordinate of the point B
bY
- the Y-coordinate of the point B
cX
- the X-coordinate of the point C
cY
- the Y-coordinate of the point C
public void fillTriangle(int aX, int aY, int bX, int bY, int cX, int cY, float r, float g, float b)
A
, B
and C
, with a color of r
, g
and b
.
Only the parts of the triangle that are inside the image will be filled.
Calling this method is equivalent to fillTriangle(aX, aY, bX, bY, cX, cY, r, g, b, 1.0F)
.
aX
- the X-coordinate of the point A
aY
- the Y-coordinate of the point A
bX
- the X-coordinate of the point B
bY
- the Y-coordinate of the point B
cX
- the X-coordinate of the point C
cY
- the Y-coordinate of the point C
r
- the R-component of the colorg
- the G-component of the colorb
- the B-component of the colorpublic void fillTriangle(int aX, int aY, int bX, int bY, int cX, int cY, float r, float g, float b, float a)
A
, B
and C
, with a color of r
, g
, b
and a
.
Only the parts of the triangle that are inside the image will be filled.
aX
- the X-coordinate of the point A
aY
- the Y-coordinate of the point A
bX
- the X-coordinate of the point B
bY
- the Y-coordinate of the point B
cX
- the X-coordinate of the point C
cY
- the Y-coordinate of the point C
r
- the R-component of the colorg
- the G-component of the colorb
- the B-component of the colora
- the A-component of the colorpublic void save(java.io.File file)
Image
as a .PNG image to the file represented by file
.
If file
is null
, a NullPointerException
will be thrown.
If an I/O error occurs, an UncheckedIOException
will be thrown.
file
- a File
that represents the file to save tojava.lang.NullPointerException
- thrown if, and only if, file
is null
java.io.UncheckedIOException
- thrown if, and only if, an I/O error occurspublic void save(java.lang.String filename)
Image
as a .PNG image to the file represented by the filename filename
.
If filename
is null
, a NullPointerException
will be thrown.
If an I/O error occurs, an UncheckedIOException
will be thrown.
filename
- a String
that represents the filename of the file to save tojava.lang.NullPointerException
- thrown if, and only if, filename
is null
java.io.UncheckedIOException
- thrown if, and only if, an I/O error occurspublic void setColor(int x, int y, float r, float g, float b)
x
and y
to r
, g
and b
.
If x
or y
are outside the image, nothing will happen.
Calling this method is equivalent to setColor(x, y, r, g, b, 1.0F)
.
x
- the X-coordinatey
- the Y-coordinater
- the R-component of the colorg
- the G-component of the colorb
- the B-component of the colorpublic void setColor(int x, int y, float r, float g, float b, float a)
x
and y
to r
, g
, b
and a
.
If x
or y
are outside the image, nothing will happen.
x
- the X-coordinatey
- the Y-coordinater
- the R-component of the colorg
- the G-component of the colorb
- the B-component of the colora
- the A-component of the color