APIdia Launch Partner
Top Description Fields Constructors Methods
com.badlogic.gdx.graphics.g2d

public Class RepeatablePolygonSprite

extends Object
Class Inheritance
Imports
com.badlogic.gdx.graphics.Color, com.badlogic.gdx.math.*, com.badlogic.gdx.utils.Array, .ShortArray

Renders polygon filled with a repeating TextureRegion with specified density Without causing an additional flush or render call
Author
Avetis Zakharyan

Field Summary

Modifier and TypeField and Description
private Color
private int
private float
private boolean
private float
private float
private Array<short[]>
private Vector2
private Array<float[]>
private TextureRegion
private int
private Array<float[]>
public float
x

public float
y

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private void
buildVertices()

Builds final vertices with vertex attributes like coordinates, color and region u/v

public void
private float[]

Returns:

offsetted vertices
offset
(float[] vertices)

Offsets polygon to 0 coordinate for ease of calculations, later offset is put back on final render

public void
setColor(Color
- Tint color to be applied to entire polygon
color
)

public void
setPolygon(TextureRegion
- region to repeat
region
,
float[]
- cw vertices of polygon
vertices
)

Sets polygon with repeating texture region, the size of repeating grid is equal to region size

public void
setPolygon(TextureRegion
- region to repeat
region
,
float[]
- cw vertices of polygon
vertices
,
float
- number of regions per polygon width bound
density
)

Sets polygon with repeating texture region, the size of repeating grid is equal to region size

public void
setPosition(float x, float y)

private float[]
snapToGrid(float[] vertices)

This is a garbage, due to Intersector returning values slightly different then the grid values Snapping exactly to grid is important, so that during bulidVertices method, it can be figured out if points is on the wall of it's own grid box or not, to set u/v properly.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

colorback to summary
private Color color
colsback to summary
private int cols
densityback to summary
private float density
dirtyback to summary
private boolean dirty
gridHeightback to summary
private float gridHeight
gridWidthback to summary
private float gridWidth
indicesback to summary
private Array<short[]> indices
offsetback to summary
private Vector2 offset
partsback to summary
private Array<float[]> parts
regionback to summary
private TextureRegion region
rowsback to summary
private int rows
verticesback to summary
private Array<float[]> vertices
xback to summary
public float x
yback to summary
public float y

Constructor Detail

RepeatablePolygonSpriteback to summary
public RepeatablePolygonSprite()

Method Detail

buildVerticesback to summary
private void buildVertices()

Builds final vertices with vertex attributes like coordinates, color and region u/v

drawback to summary
public void draw(PolygonSpriteBatch batch)
offsetback to summary
private float[] offset(float[] vertices)

Offsets polygon to 0 coordinate for ease of calculations, later offset is put back on final render

Returns:float[]

offsetted vertices

setColorback to summary
public void setColor(Color color)
Parameters
color:Color

- Tint color to be applied to entire polygon

setPolygonback to summary
public void setPolygon(TextureRegion region, float[] vertices)

Sets polygon with repeating texture region, the size of repeating grid is equal to region size

Parameters
region:TextureRegion

- region to repeat

vertices:float[]

- cw vertices of polygon

setPolygonback to summary
public void setPolygon(TextureRegion region, float[] vertices, float density)

Sets polygon with repeating texture region, the size of repeating grid is equal to region size

Parameters
region:TextureRegion

- region to repeat

vertices:float[]

- cw vertices of polygon

density:float

- number of regions per polygon width bound

setPositionback to summary
public void setPosition(float x, float y)
snapToGridback to summary
private float[] snapToGrid(float[] vertices)

This is a garbage, due to Intersector returning values slightly different then the grid values Snapping exactly to grid is important, so that during bulidVertices method, it can be figured out if points is on the wall of it's own grid box or not, to set u/v properly. Any other implementations are welcome