|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.newdawn.slick.Graphics
public class Graphics
A graphics context that can be used to render primatives to the accelerated canvas provided by LWJGL.
Field Summary | |
---|---|
protected static Graphics |
currentGraphics
The last graphics context in use |
protected static Font |
DEFAULT_FONT
The default font to use |
protected static SGL |
GL
The renderer to use for all GL operations |
static int |
MODE_ADD
Draw adding the existing colour to the new colour |
static int |
MODE_ALPHA_BLEND
Draw using the alpha blending |
static int |
MODE_ALPHA_MAP
Draw to the alpha map |
static int |
MODE_COLOR_MULTIPLY
Draw multiplying the source and destination colours |
static int |
MODE_NORMAL
The normal drawing mode |
static int |
MODE_SCREEN
Draw blending the new image into the old one by a factor of it's colour |
protected int |
screenHeight
The height of the screen |
protected int |
screenWidth
The width of the screen |
Constructor Summary | |
---|---|
Graphics()
Default constructor for sub-classes |
|
Graphics(int width,
int height)
Create a new graphics context. |
Method Summary | |
---|---|
void |
clear()
Clear the graphics context |
void |
clearAlphaMap()
Clear the state of the alpha map across the entire screen. |
void |
clearClip()
Clear the clipping being applied. |
void |
clearWorldClip()
Clear world clipping setup. |
void |
copyArea(Image target,
int x,
int y)
Copy an area of the rendered screen into an image. |
void |
destroy()
Dispose this graphics context, this will release any underlying resourses. |
protected void |
disable()
Disable rendering to this graphics context |
void |
draw(Shape shape)
Draw the outline of the given shape. |
void |
draw(Shape shape,
ShapeFill fill)
Draw the outline of the given shape. |
void |
drawAnimation(Animation anim,
float x,
float y)
Draw an animation to this graphics context |
void |
drawAnimation(Animation anim,
float x,
float y,
Color col)
Draw an animation to this graphics context |
void |
drawArc(float x1,
float y1,
float width,
float height,
float start,
float end)
Draw an oval to the canvas |
void |
drawArc(float x1,
float y1,
float width,
float height,
int segments,
float start,
float end)
Draw an oval to the canvas |
void |
drawGradientLine(float x1,
float y1,
Color Color1,
float x2,
float y2,
Color Color2)
Draw a line with a gradient between the two points. |
void |
drawGradientLine(float x1,
float y1,
float red1,
float green1,
float blue1,
float alpha1,
float x2,
float y2,
float red2,
float green2,
float blue2,
float alpha2)
Draw a line with a gradient between the two points. |
void |
drawImage(Image image,
float x,
float y)
Draw an image to the screen |
void |
drawImage(Image image,
float x,
float y,
Color col)
Draw an image to the screen |
void |
drawImage(Image image,
float x,
float y,
float srcx,
float srcy,
float srcx2,
float srcy2)
Draw a section of an image at a particular location and scale on the screen |
void |
drawImage(Image image,
float x,
float y,
float srcx,
float srcy,
float srcx2,
float srcy2,
Color col)
Draw a section of an image at a particular location and scale on the screen |
void |
drawImage(Image image,
float x,
float y,
float x2,
float y2,
float srcx,
float srcy,
float srcx2,
float srcy2)
Draw a section of an image at a particular location and scale on the screen |
void |
drawImage(Image image,
float x,
float y,
float x2,
float y2,
float srcx,
float srcy,
float srcx2,
float srcy2,
Color col)
Draw a section of an image at a particular location and scale on the screen |
void |
drawLine(float x1,
float y1,
float x2,
float y2)
Draw a line on the canvas in the current colour |
void |
drawOval(float x1,
float y1,
float width,
float height)
Draw an oval to the canvas |
void |
drawOval(float x1,
float y1,
float width,
float height,
int segments)
Draw an oval to the canvas |
void |
drawRect(float x1,
float y1,
float width,
float height)
Draw a rectangle to the canvas in the current colour |
void |
drawRoundRect(float x,
float y,
float width,
float height,
int cornerRadius)
Draw a rounded rectangle |
void |
drawRoundRect(float x,
float y,
float width,
float height,
int cornerRadius,
int segs)
Draw a rounded rectangle |
void |
drawString(java.lang.String str,
float x,
float y)
Draw a string to the screen using the current font |
protected void |
enable()
Enable rendering to this graphics context |
void |
fill(Shape shape)
Draw the the given shape filled in. |
void |
fill(Shape shape,
ShapeFill fill)
Draw the the given shape filled in. |
void |
fillArc(float x1,
float y1,
float width,
float height,
float start,
float end)
Fill an arc to the canvas (a wedge) |
void |
fillArc(float x1,
float y1,
float width,
float height,
int segments,
float start,
float end)
Fill an arc to the canvas (a wedge) |
void |
fillOval(float x1,
float y1,
float width,
float height)
Fill an oval to the canvas |
void |
fillOval(float x1,
float y1,
float width,
float height,
int segments)
Fill an oval to the canvas |
void |
fillRect(float x1,
float y1,
float width,
float height)
Fill a rectangle on the canvas in the current color |
void |
fillRect(float x,
float y,
float width,
float height,
Image pattern,
float offX,
float offY)
Tile a rectangle with a pattern specifing the offset from the top corner that one tile should match |
void |
fillRoundRect(float x,
float y,
float width,
float height,
int cornerRadius)
Fill a rounded rectangle |
void |
fillRoundRect(float x,
float y,
float width,
float height,
int cornerRadius,
int segs)
Fill a rounded rectangle |
void |
flush()
Flush this graphics context to the underlying rendering context |
void |
getArea(int x,
int y,
int width,
int height,
java.nio.ByteBuffer target)
Get an ara of pixels as RGBA values into a buffer |
Color |
getBackground()
Get the current graphics context background color |
Rectangle |
getClip()
Return the currently applied clipping rectangle |
Color |
getColor()
Get the color in use by this graphics context |
Font |
getFont()
Get the current font |
float |
getLineWidth()
Get the width of lines being drawn in this context |
Color |
getPixel(int x,
int y)
Get the colour of a single pixel in this graphics context |
Rectangle |
getWorldClip()
Get the last set world clip or null of the world clip isn't set |
boolean |
isAntiAlias()
True if antialiasing has been turned on for this graphics context |
void |
popTransform()
Pop a previously pushed transform from the stack to the current. |
void |
pushTransform()
Push the current state of the transform from this graphics contexts onto the underlying graphics stack's transform stack. |
void |
resetFont()
Reset to using the default font for this context |
void |
resetLineWidth()
Reset the line width in use to the default for this graphics context |
void |
resetTransform()
Reset the transformation on this graphics context |
void |
rotate(float rx,
float ry,
float ang)
Apply a rotation to everything draw on the graphics context |
void |
scale(float sx,
float sy)
Apply a scaling factor to everything drawn on the graphics context |
void |
setAntiAlias(boolean anti)
Indicate if we should antialias as we draw primitives |
void |
setBackground(Color color)
Set the background colour of the graphics context. |
void |
setClip(int x,
int y,
int width,
int height)
Set the clipping to apply to the drawing. |
void |
setClip(Rectangle rect)
Set the clipping to apply to the drawing. |
void |
setColor(Color color)
Set the color to use when rendering to this context |
static void |
setCurrent(Graphics current)
Set the current graphics context in use |
void |
setDrawMode(int mode)
Set the drawing mode to use. |
void |
setFont(Font font)
Set the font to be used when rendering text |
void |
setLineWidth(float width)
Set the with of the line to be used when drawing line based primitives |
void |
setWorldClip(float x,
float y,
float width,
float height)
Set clipping that controls which areas of the world will be drawn to. |
void |
setWorldClip(Rectangle clip)
Set the world clip to be applied |
void |
texture(Shape shape,
Image image)
Draw the the given shape filled in with a texture |
void |
texture(Shape shape,
Image image,
boolean fit)
Draw the the given shape filled in with a texture |
void |
texture(Shape shape,
Image image,
float scaleX,
float scaleY)
Draw the the given shape filled in with a texture |
void |
texture(Shape shape,
Image image,
float scaleX,
float scaleY,
boolean fit)
Draw the the given shape filled in with a texture |
void |
texture(Shape shape,
Image image,
float scaleX,
float scaleY,
ShapeFill fill)
Draw the the given shape filled in with a texture |
void |
texture(Shape shape,
Image image,
ShapeFill fill)
Draw the the given shape filled in with a texture |
void |
translate(float x,
float y)
Apply a translation to everything drawn to the context |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static SGL GL
public static int MODE_NORMAL
public static int MODE_ALPHA_MAP
public static int MODE_ALPHA_BLEND
public static int MODE_COLOR_MULTIPLY
public static int MODE_ADD
public static int MODE_SCREEN
protected static Graphics currentGraphics
protected static Font DEFAULT_FONT
protected int screenWidth
protected int screenHeight
Constructor Detail |
---|
public Graphics()
public Graphics(int width, int height)
width
- The width of the screen for this contextheight
- The height of the screen for this contextMethod Detail |
---|
public static void setCurrent(Graphics current)
current
- The graphics context that should be considered currentpublic void setDrawMode(int mode)
MODE_NORMAL
or
MODE_ALPHA_MAP
or MODE_ALPHA_BLEND
mode
- The mode to apply.public void clearAlphaMap()
MODE_ALPHA_BLEND
nothing will be drawn.
protected void enable()
public void flush()
protected void disable()
public Font getFont()
public void setBackground(Color color)
color
- The background color of the graphics contextpublic Color getBackground()
public void clear()
public void resetTransform()
public void scale(float sx, float sy)
sx
- The scaling factor to apply to the x axissy
- The scaling factor to apply to the y axispublic void rotate(float rx, float ry, float ang)
rx
- The x coordinate of the center of rotationry
- The y coordinate of the center of rotationang
- The angle (in degrees) to rotate bypublic void translate(float x, float y)
x
- The amount to translate on the x-axisy
- The amount of translate on the y-axispublic void setFont(Font font)
font
- The font to be used when rendering textpublic void resetFont()
public void setColor(Color color)
color
- The color to use when rendering to this contextpublic Color getColor()
public void drawLine(float x1, float y1, float x2, float y2)
x1
- The x coordinate of the start pointy1
- The y coordinate of the start pointx2
- The x coordinate of the end pointy2
- The y coordinate of the end pointpublic void draw(Shape shape, ShapeFill fill)
shape
- The shape to draw.fill
- The fill type to applypublic void fill(Shape shape, ShapeFill fill)
shape
- The shape to fill.fill
- The fill type to applypublic void draw(Shape shape)
shape
- The shape to draw.public void fill(Shape shape)
shape
- The shape to fill.public void texture(Shape shape, Image image)
shape
- The shape to texture.image
- The image to tile across the shapepublic void texture(Shape shape, Image image, ShapeFill fill)
shape
- The shape to texture.image
- The image to tile across the shapefill
- The shape fill to applypublic void texture(Shape shape, Image image, boolean fit)
shape
- The shape to texture.image
- The image to tile across the shapefit
- True if we want to fit the image on to the shapepublic void texture(Shape shape, Image image, float scaleX, float scaleY)
shape
- The shape to texture.image
- The image to tile across the shapescaleX
- The scale to apply on the x axis for texturingscaleY
- The scale to apply on the y axis for texturingpublic void texture(Shape shape, Image image, float scaleX, float scaleY, boolean fit)
shape
- The shape to texture.image
- The image to tile across the shapescaleX
- The scale to apply on the x axis for texturingscaleY
- The scale to apply on the y axis for texturingfit
- True if we want to fit the image on to the shapepublic void texture(Shape shape, Image image, float scaleX, float scaleY, ShapeFill fill)
shape
- The shape to texture.image
- The image to tile across the shapescaleX
- The scale to apply on the x axis for texturingscaleY
- The scale to apply on the y axis for texturingfill
- The shape fill to applypublic void drawRect(float x1, float y1, float width, float height)
x1
- The x coordinate of the top left cornery1
- The y coordinate of the top left cornerwidth
- The width of the rectangle to drawheight
- The height of the rectangle to drawpublic void clearClip()
public void setWorldClip(float x, float y, float width, float height)
x
- The x coordinate of the top left corner of the allowed areay
- The y coordinate of the top left corner of the allowed areawidth
- The width of the allowed areaheight
- The height of the allowed areapublic void clearWorldClip()
public void setWorldClip(Rectangle clip)
clip
- The area still visiblesetWorldClip(float, float, float, float)
public Rectangle getWorldClip()
public void setClip(int x, int y, int width, int height)
x
- The x coordinate of the top left corner of the allowed areay
- The y coordinate of the top left corner of the allowed areawidth
- The width of the allowed areaheight
- The height of the allowed areapublic void setClip(Rectangle rect)
rect
- The rectangle describing the clipped area in screen
coordinatespublic Rectangle getClip()
public void fillRect(float x, float y, float width, float height, Image pattern, float offX, float offY)
x
- The x coordinate of the rectangley
- The y coordinate of the rectanglewidth
- The width of the rectangleheight
- The height of the rectanglepattern
- The image to tile across the rectangleoffX
- The offset on the x axis from the top left corneroffY
- The offset on the y axis from the top left cornerpublic void fillRect(float x1, float y1, float width, float height)
x1
- The x coordinate of the top left cornery1
- The y coordinate of the top left cornerwidth
- The width of the rectangle to fillheight
- The height of the rectangle to fillpublic void drawOval(float x1, float y1, float width, float height)
x1
- The x coordinate of the top left corner of a box containing
the ovaly1
- The y coordinate of the top left corner of a box containing
the ovalwidth
- The width of the ovalheight
- The height of the ovalpublic void drawOval(float x1, float y1, float width, float height, int segments)
x1
- The x coordinate of the top left corner of a box containing
the ovaly1
- The y coordinate of the top left corner of a box containing
the ovalwidth
- The width of the ovalheight
- The height of the ovalsegments
- The number of line segments to use when drawing the ovalpublic void drawArc(float x1, float y1, float width, float height, float start, float end)
x1
- The x coordinate of the top left corner of a box containing
the arcy1
- The y coordinate of the top left corner of a box containing
the arcwidth
- The width of the archeight
- The height of the arcstart
- The angle the arc starts atend
- The angle the arc ends atpublic void drawArc(float x1, float y1, float width, float height, int segments, float start, float end)
x1
- The x coordinate of the top left corner of a box containing
the arcy1
- The y coordinate of the top left corner of a box containing
the arcwidth
- The width of the archeight
- The height of the arcsegments
- The number of line segments to use when drawing the arcstart
- The angle the arc starts atend
- The angle the arc ends atpublic void fillOval(float x1, float y1, float width, float height)
x1
- The x coordinate of the top left corner of a box containing
the ovaly1
- The y coordinate of the top left corner of a box containing
the ovalwidth
- The width of the ovalheight
- The height of the ovalpublic void fillOval(float x1, float y1, float width, float height, int segments)
x1
- The x coordinate of the top left corner of a box containing
the ovaly1
- The y coordinate of the top left corner of a box containing
the ovalwidth
- The width of the ovalheight
- The height of the ovalsegments
- The number of line segments to use when filling the ovalpublic void fillArc(float x1, float y1, float width, float height, float start, float end)
x1
- The x coordinate of the top left corner of a box containing
the arcy1
- The y coordinate of the top left corner of a box containing
the arcwidth
- The width of the archeight
- The height of the arcstart
- The angle the arc starts atend
- The angle the arc ends atpublic void fillArc(float x1, float y1, float width, float height, int segments, float start, float end)
x1
- The x coordinate of the top left corner of a box containing
the arcy1
- The y coordinate of the top left corner of a box containing
the arcwidth
- The width of the archeight
- The height of the arcsegments
- The number of line segments to use when filling the arcstart
- The angle the arc starts atend
- The angle the arc ends atpublic void drawRoundRect(float x, float y, float width, float height, int cornerRadius)
x
- The x coordinate of the top left corner of the rectangley
- The y coordinate of the top left corner of the rectanglewidth
- The width of the rectangleheight
- The height of the rectanglecornerRadius
- The radius of the rounded edges on the cornerspublic void drawRoundRect(float x, float y, float width, float height, int cornerRadius, int segs)
x
- The x coordinate of the top left corner of the rectangley
- The y coordinate of the top left corner of the rectanglewidth
- The width of the rectangleheight
- The height of the rectanglecornerRadius
- The radius of the rounded edges on the cornerssegs
- The number of segments to make the corners out ofpublic void fillRoundRect(float x, float y, float width, float height, int cornerRadius)
x
- The x coordinate of the top left corner of the rectangley
- The y coordinate of the top left corner of the rectanglewidth
- The width of the rectangleheight
- The height of the rectanglecornerRadius
- The radius of the rounded edges on the cornerspublic void fillRoundRect(float x, float y, float width, float height, int cornerRadius, int segs)
x
- The x coordinate of the top left corner of the rectangley
- The y coordinate of the top left corner of the rectanglewidth
- The width of the rectangleheight
- The height of the rectanglecornerRadius
- The radius of the rounded edges on the cornerssegs
- The number of segments to make the corners out ofpublic void setLineWidth(float width)
width
- The width of the line to be used when drawing line based
primitivespublic float getLineWidth()
public void resetLineWidth()
public void setAntiAlias(boolean anti)
anti
- True if we should antialiaspublic boolean isAntiAlias()
public void drawString(java.lang.String str, float x, float y)
str
- The string to drawx
- The x coordinate to draw the string aty
- The y coordinate to draw the string atpublic void drawImage(Image image, float x, float y, Color col)
image
- The image to draw to the screenx
- The x location at which to draw the imagey
- The y location at which to draw the imagecol
- The color to apply to the image as a filterpublic void drawAnimation(Animation anim, float x, float y)
anim
- The animation to be drawnx
- The x position to draw the animation aty
- The y position to draw the animation atpublic void drawAnimation(Animation anim, float x, float y, Color col)
anim
- The animation to be drawnx
- The x position to draw the animation aty
- The y position to draw the animation atcol
- The color to apply to the animation as a filterpublic void drawImage(Image image, float x, float y)
image
- The image to draw to the screenx
- The x location at which to draw the imagey
- The y location at which to draw the imagepublic void drawImage(Image image, float x, float y, float x2, float y2, float srcx, float srcy, float srcx2, float srcy2)
image
- The image to draw a section ofx
- The x position to draw the imagey
- The y position to draw the imagex2
- The x position of the bottom right corner of the drawn imagey2
- The y position of the bottom right corner of the drawn imagesrcx
- The x position of the rectangle to draw from this image (i.e.
relative to the image)srcy
- The y position of the rectangle to draw from this image (i.e.
relative to the image)srcx2
- The x position of the bottom right cornder of rectangle to
draw from this image (i.e. relative to the image)srcy2
- The t position of the bottom right cornder of rectangle to
draw from this image (i.e. relative to the image)public void drawImage(Image image, float x, float y, float srcx, float srcy, float srcx2, float srcy2)
image
- The image to draw a section ofx
- The x position to draw the imagey
- The y position to draw the imagesrcx
- The x position of the rectangle to draw from this image (i.e.
relative to the image)srcy
- The y position of the rectangle to draw from this image (i.e.
relative to the image)srcx2
- The x position of the bottom right cornder of rectangle to
draw from this image (i.e. relative to the image)srcy2
- The t position of the bottom right cornder of rectangle to
draw from this image (i.e. relative to the image)public void copyArea(Image target, int x, int y)
target
- The target imagex
- The x position to copy fromy
- The y position to copy frompublic Color getPixel(int x, int y)
x
- The x coordinate of the pixel to ready
- The y coordinate of the pixel to read
public void getArea(int x, int y, int width, int height, java.nio.ByteBuffer target)
x
- The x position in the context to grab fromy
- The y position in the context to grab fromwidth
- The width of the area to grab fromheight
- The hiehgt of the area to grab fromtarget
- The target buffer to grab intopublic void drawImage(Image image, float x, float y, float x2, float y2, float srcx, float srcy, float srcx2, float srcy2, Color col)
image
- The image to draw a section ofx
- The x position to draw the imagey
- The y position to draw the imagex2
- The x position of the bottom right corner of the drawn imagey2
- The y position of the bottom right corner of the drawn imagesrcx
- The x position of the rectangle to draw from this image (i.e.
relative to the image)srcy
- The y position of the rectangle to draw from this image (i.e.
relative to the image)srcx2
- The x position of the bottom right cornder of rectangle to
draw from this image (i.e. relative to the image)srcy2
- The t position of the bottom right cornder of rectangle to
draw from this image (i.e. relative to the image)col
- The color to apply to the image as a filterpublic void drawImage(Image image, float x, float y, float srcx, float srcy, float srcx2, float srcy2, Color col)
image
- The image to draw a section ofx
- The x position to draw the imagey
- The y position to draw the imagesrcx
- The x position of the rectangle to draw from this image (i.e.
relative to the image)srcy
- The y position of the rectangle to draw from this image (i.e.
relative to the image)srcx2
- The x position of the bottom right cornder of rectangle to
draw from this image (i.e. relative to the image)srcy2
- The t position of the bottom right cornder of rectangle to
draw from this image (i.e. relative to the image)col
- The color to apply to the image as a filterpublic void drawGradientLine(float x1, float y1, float red1, float green1, float blue1, float alpha1, float x2, float y2, float red2, float green2, float blue2, float alpha2)
x1
- The starting x position to draw the liney1
- The starting y position to draw the linered1
- The starting position's shade of redgreen1
- The starting position's shade of greenblue1
- The starting position's shade of bluealpha1
- The starting position's alpha valuex2
- The ending x position to draw the liney2
- The ending y position to draw the linered2
- The ending position's shade of redgreen2
- The ending position's shade of greenblue2
- The ending position's shade of bluealpha2
- The ending position's alpha valuepublic void drawGradientLine(float x1, float y1, Color Color1, float x2, float y2, Color Color2)
x1
- The starting x position to draw the liney1
- The starting y position to draw the lineColor1
- The starting position's colorx2
- The ending x position to draw the liney2
- The ending y position to draw the lineColor2
- The ending position's colorpublic void pushTransform()
public void popTransform()
public void destroy()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |