public class Graphics
extends java.lang.Object
| Constructor and Description |
|---|
Graphics(com.badlogic.gdx.graphics.g2d.SpriteBatch spriteBatch,
com.badlogic.gdx.graphics.glutils.ShapeRenderer shapeRenderer) |
| Modifier and Type | Method and Description |
|---|---|
void |
clearBlendFunction()
Resets the blend function to its default
|
void |
clearShaderProgram()
Clears the
ShaderProgram applied to this instance |
void |
disableBlending()
Disables blending during rendering
|
void |
drawCircle(float centerX,
float centerY,
int radius)
Draws a circle to the window in the current
Color with the set
line height |
void |
drawLineSegment(float x1,
float y1,
float x2,
float y2)
Renders a line segment to the window in the current
Color with
the set line height |
void |
drawRect(float x,
float y,
float width,
float height)
Renders a rectangle to the window in the current
Color with the
set line height |
void |
drawShape(Shape shape)
Draws an instance of
Shape |
void |
drawSprite(com.badlogic.gdx.graphics.g2d.Sprite sprite)
Draws a
Sprite with all transformations applied to this graphics
context |
void |
drawSprite(com.badlogic.gdx.graphics.g2d.Sprite sprite,
float x,
float y)
Draws a
Sprite at the given coordinates with all transformations
applied to this graphics context |
void |
drawSpriteCache(com.badlogic.gdx.graphics.g2d.SpriteCache spriteCache,
int cacheId) |
void |
drawString(java.lang.String text,
float x,
float y)
Draws a string to the window
|
void |
drawString(java.lang.String text,
float x,
float y,
float wrapWidth)
Draws a string to the window, automatically wrapping it to a specified width
|
void |
drawTexture(com.badlogic.gdx.graphics.Texture texture,
float x,
float y)
Draws a texture to this graphics context
|
void |
drawTextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion textureRegion,
float x,
float y)
Draws a texture region to this graphics context
|
void |
enabledBlending()
Enables blending during rendering
|
void |
fillCircle(float centerX,
float centerY,
int radius)
Fills a circle to the window in the current
Color |
void |
fillRect(float x,
float y,
float width,
float height)
Fills a rectangle to the window in the current
Color |
void |
flush()
Immediately flushes everything rendered rather than waiting until the end
of rendering
|
com.badlogic.gdx.graphics.Color |
getBackgroundColor()
Returns the background
Color |
com.badlogic.gdx.graphics.Color |
getColor()
Returns the
Color to draw shapes with |
float |
getCurrentHeight() |
float |
getCurrentWidth() |
com.badlogic.gdx.graphics.g2d.BitmapFont |
getFont()
Returns the
BitmapFont to draw Strings with |
int |
getLineHeight()
Returns the line height used
|
com.badlogic.gdx.math.Matrix4 |
getProjectionMatrix() |
float |
getRotation() |
float |
getRotationX() |
float |
getRotationY() |
float |
getScaleX() |
float |
getScaleY() |
com.badlogic.gdx.graphics.Color |
getTint()
Returns the
Color tint being applied to all draw operations |
float |
getTranslationX() |
float |
getTranslationY() |
void |
postRender()
Called by mini2Dx after rendering
|
void |
preRender(int gameWidth,
int gameHeight)
Called by mini2Dx before rendering begins
|
Rectangle |
removeClip()
Removes the applied clip
|
void |
removeTint()
Removes the tinting
Color |
void |
rotate(float degrees,
float x,
float y)
Rotates the canvas by the provided degrees around the provided point
|
void |
scale(float scaleX,
float scaleY)
Scales the canvas
|
void |
setBackgroundColor(com.badlogic.gdx.graphics.Color backgroundColor)
Sets the background
Color to be used |
void |
setBlendFunction(int srcFunc,
int dstFunc)
Sets the blend function to be applied
OpenGL Blend Function Cheatsheet
|
void |
setClip(float x,
float y,
float width,
float height)
Sets the graphics context clip.
|
void |
setClip(Rectangle clip)
Sets the graphics context clip.
|
void |
setColor(com.badlogic.gdx.graphics.Color color)
Sets the
Color to draw shapes with |
void |
setFont(com.badlogic.gdx.graphics.g2d.BitmapFont font)
Sets the
BitmapFont to draw Strings with |
void |
setLineHeight(int lineHeight)
Sets the line height to be used
|
void |
setShaderProgram(com.badlogic.gdx.graphics.glutils.ShaderProgram shaderProgram)
Applies a
ShaderProgram to this instance |
void |
setTint(com.badlogic.gdx.graphics.Color tint)
Sets the
Color to apply to draw operations |
java.lang.String |
toString() |
void |
translate(float translateX,
float translateY)
Moves the graphics context by a certain amount of the X and Y axis
|
public Graphics(com.badlogic.gdx.graphics.g2d.SpriteBatch spriteBatch,
com.badlogic.gdx.graphics.glutils.ShapeRenderer shapeRenderer)
public void preRender(int gameWidth,
int gameHeight)
gameWidth - The current game window widthgameHeight - The current game window heightpublic void postRender()
public void drawLineSegment(float x1,
float y1,
float x2,
float y2)
Color with
the set line heightx1 - X coordinate of point Ay1 - Y coordinate of point Ax2 - X coordinate of point By2 - Y coordinate of point Bpublic void drawRect(float x,
float y,
float width,
float height)
Color with the
set line heightx - The x coordinate to render aty - The y coordinate to render atwidth - The width of the rectangleheight - The height of the rectanglepublic void fillRect(float x,
float y,
float width,
float height)
Colorx - The x coordinate to render aty - The y coordinate to render atwidth - The width of the rectangleheight - The height of the rectanglepublic void drawCircle(float centerX,
float centerY,
int radius)
Color with the set
line heightcenterX - The x coordinate of the center of the circlecenterY - The y coordinate of the center of the circleradius - The radius of the circlepublic void fillCircle(float centerX,
float centerY,
int radius)
ColorcenterX - The x coordinate of the center of the circlecenterY - The y coordinate of the center of the circleradius - The radius of the circlepublic void drawString(java.lang.String text,
float x,
float y)
text - The String to drawx - The x coordinate to draw aty - The y coordinate to draw atpublic void drawString(java.lang.String text,
float x,
float y,
float wrapWidth)
text - The String to drawx - The x coordinate to draw aty - The y coordinate to draw atwrapWidth - The width the String is automatically wrapped topublic void drawTexture(com.badlogic.gdx.graphics.Texture texture,
float x,
float y)
texture - The Texture to drawx - The x coordinate to draw aty - The y coordinate to draw atpublic void drawTextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion textureRegion,
float x,
float y)
textureRegion - The TextureRegion to drawx - The x coordinate to draw aty - The y coordinate to draw atpublic void drawShape(Shape shape)
Shapeshape - The implementation of Shape to drawpublic void drawSprite(com.badlogic.gdx.graphics.g2d.Sprite sprite)
Sprite with all transformations applied to this graphics
contextsprite - The Sprite to drawpublic void drawSprite(com.badlogic.gdx.graphics.g2d.Sprite sprite,
float x,
float y)
Sprite at the given coordinates with all transformations
applied to this graphics contextsprite - The Sprite to drawx - The x coordinate to render aty - The y coordinate to render atpublic void drawSpriteCache(com.badlogic.gdx.graphics.g2d.SpriteCache spriteCache,
int cacheId)
public void rotate(float degrees,
float x,
float y)
degrees - The degree value in a clockwise directionx - The x coordinate to rotate aroundy - The y coordinate to rotate aroundpublic void scale(float scaleX,
float scaleY)
scaleX - Scaling along the X axisscaleY - Scaling along the Y axospublic void translate(float translateX,
float translateY)
translateX - The x axis translationtranslateY - The y axis translationpublic void setClip(float x,
float y,
float width,
float height)
x - The x coordinate the clip begins aty - The y coordinate the clip begins atwidth - The width of the clipheight - The height of the clippublic void setClip(Rectangle clip)
clip - The clip areapublic Rectangle removeClip()
public void setTint(com.badlogic.gdx.graphics.Color tint)
Color to apply to draw operationstint - The Color to tint withpublic void setFont(com.badlogic.gdx.graphics.g2d.BitmapFont font)
BitmapFont to draw Strings withfont - A non-null instance of BitmapFontpublic void removeTint()
Colorpublic void enabledBlending()
public void disableBlending()
public void setShaderProgram(com.badlogic.gdx.graphics.glutils.ShaderProgram shaderProgram)
ShaderProgram to this instanceshaderProgram - The ShaderProgram to applypublic void clearShaderProgram()
ShaderProgram applied to this instancepublic void setBlendFunction(int srcFunc,
int dstFunc)
srcFunc - Source GL functiondstFunc - Destination GL functionpublic void clearBlendFunction()
public void flush()
public int getLineHeight()
public void setLineHeight(int lineHeight)
lineHeight - A value greater than 0public com.badlogic.gdx.graphics.Color getColor()
Color to draw shapes withpublic void setColor(com.badlogic.gdx.graphics.Color color)
Color to draw shapes withcolor - public com.badlogic.gdx.graphics.Color getBackgroundColor()
Colorpublic void setBackgroundColor(com.badlogic.gdx.graphics.Color backgroundColor)
Color to be usedpublic com.badlogic.gdx.graphics.g2d.BitmapFont getFont()
BitmapFont to draw Strings withpublic com.badlogic.gdx.graphics.Color getTint()
Color tint being applied to all draw operationspublic float getScaleX()
public float getScaleY()
public float getTranslationX()
public float getTranslationY()
public float getRotation()
public float getRotationX()
public float getRotationY()
public com.badlogic.gdx.math.Matrix4 getProjectionMatrix()
public float getCurrentWidth()
public float getCurrentHeight()
public java.lang.String toString()
toString in class java.lang.Object