Java Code Examples for com.badlogic.gdx.graphics.Color#toFloatBits()

The following examples show how to use com.badlogic.gdx.graphics.Color#toFloatBits() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RayHandler.java    From uracer-kotd with Apache License 2.0 6 votes vote down vote up
private void setShadowBox() {
	int i = 0;
	// This need some work, maybe camera matrix would needed
	float c = Color.toFloatBits( 0, 0, 0, 1 );

	m_segments[i++] = -1000000f;
	m_segments[i++] = -1000000f;
	m_segments[i++] = c;
	m_segments[i++] = -1000000f;
	m_segments[i++] = 1000000f;
	m_segments[i++] = c;
	m_segments[i++] = 1000000f;
	m_segments[i++] = 1000000f;
	m_segments[i++] = c;
	m_segments[i++] = 1000000f;
	m_segments[i++] = -1000000;
	m_segments[i++] = c;
	box.setVertices( m_segments, 0, i );
}
 
Example 2
Source File: VerticalGradientDrawable.java    From gdx-vfx with Apache License 2.0 5 votes vote down vote up
public VerticalGradientDrawable setColors(Color colorBottom, Color colorTop) {
    float colorBitsBottom = colorBottom.toFloatBits();
    float colorBitsTop = colorTop.toFloatBits();

    // Update vertices' colors.
    vertices[0*VERT_SIZE + COMP_COLOR] = colorBitsBottom;
    vertices[1*VERT_SIZE + COMP_COLOR] = colorBitsTop;
    vertices[2*VERT_SIZE + COMP_COLOR] = colorBitsTop;
    vertices[3*VERT_SIZE + COMP_COLOR] = colorBitsBottom;

    return this;
}
 
Example 3
Source File: SpriteAnimationDrawable.java    From talos with Apache License 2.0 4 votes vote down vote up
private void updateVertices(float x, float y, float width, float height, Color color, float u, float v, float u2, float v2, float rotation) {
    int idx = 0;
    origin.set(x + width/2f, y + width/2f);

    tmp.set(x, y).rotateAround(origin, rotation);
    vertices[idx++] = tmp.x;
    vertices[idx++] = tmp.y;
    vertices[idx++] = color.toFloatBits();
    vertices[idx++] = u;
    vertices[idx++] = v;

    tmp.set(x, y+height).rotateAround(origin, rotation);
    vertices[idx++] = tmp.x;
    vertices[idx++] = tmp.y;
    vertices[idx++] = color.toFloatBits();
    vertices[idx++] = u;
    vertices[idx++] = v2;

    tmp.set(x+width, y+height).rotateAround(origin, rotation);
    vertices[idx++] = tmp.x;
    vertices[idx++] = tmp.y;
    vertices[idx++] = color.toFloatBits();
    vertices[idx++] = u2;
    vertices[idx++] = v2;

    tmp.set(x+width, y).rotateAround(origin, rotation);
    vertices[idx++] = tmp.x;
    vertices[idx++] = tmp.y;
    vertices[idx++] = color.toFloatBits();
    vertices[idx++] = u2;
    vertices[idx++] = v;

    idx = 0;

    indexes[idx++] = 0;
    indexes[idx++] = 1;
    indexes[idx++] = 2;
    indexes[idx++] = 0;
    indexes[idx++] = 2;
    indexes[idx++] = 3;
}
 
Example 4
Source File: Renderer20.java    From fluid-simulator-v2 with Apache License 2.0 4 votes vote down vote up
public void color (float r, float g, float b, float a) {
	vertices[vertexIdx + colorOffset] = Color.toFloatBits(r, g, b, a);
}
 
Example 5
Source File: GraphDrawerDrawable.java    From shapedrawer with MIT License 2 votes vote down vote up
/**
 * Sets the color of the graph path in packed float bits.
 *
 * @param color The color.
 */
public void setColor(Color color) {
    this.color = color.toFloatBits();
}
 
Example 6
Source File: ShapeDrawer.java    From shapedrawer with MIT License 2 votes vote down vote up
/**
 * <p>Calls {@link #line(float, float, float, float, float, boolean)}()} with default line width and {@code snap}.</p>
 * @param s the starting point of the line
 * @param e the end point of the line
 * @param color the colour of the line
 */
public void line(Vector2 s, Vector2 e, Color color) {
    float c = color.toFloatBits();
    line(s.x, s.y, e.x, e.y, defaultLineWidth, isDefaultSnap(), c, c);
}
 
Example 7
Source File: ShapeDrawer.java    From shapedrawer with MIT License 2 votes vote down vote up
/**
 * <p>Calls {@link #line(float, float, float, float, float, boolean, float, float)}()} with default line width and {@code snap}.</p>
 * @param s the starting point of the line
 * @param e the end point of the line
 * @param color color the colour of the line
 * @param lineWidth the width of the line in world units
 */
public void line(Vector2 s, Vector2 e, Color color, float lineWidth) {
    float c = color.toFloatBits();
    line(s.x, s.y, e.x, e.y, lineWidth, isDefaultSnap(), c, c);
}
 
Example 8
Source File: ShapeDrawer.java    From shapedrawer with MIT License 2 votes vote down vote up
/**
 * <p>Calls {@link #line(float, float, float, float, Color, float)}()} with {@code snap} set to the default value.</p>
 * @param x1 the x-component of the first point
 * @param y1 the y-component of the first point
 * @param x2 the x-component of the second point
 * @param y2 the y-component of the second point
 * @param color color the colour of the line
 * @param lineWidth the width of the line in world units
 */
public void line(float x1, float y1, float x2, float y2, Color color, float lineWidth) {
    float c = color.toFloatBits();
    line(x1, y1, x2, y2, lineWidth, isDefaultSnap(), c, c);
}
 
Example 9
Source File: ShapeDrawer.java    From shapedrawer with MIT License 2 votes vote down vote up
/**
 * <p>Draws a filled circle (disc) by calling {@link #filledEllipse(float, float, float, float, float, float, float)} with rotation set to 0
 * and radiusX and radiusY set to {@code radius}.</p>
 * @param centreX the x-coordinate of the centre point
 * @param centreY the y-coordinate of the centre point
 * @param radius the radius
 * @param color the colour of the disc
 */
public void filledCircle(float centreX, float centreY, float radius, Color color) {
    float c = color.toFloatBits();
    filledEllipse(centreX, centreY, radius, radius, 0, c, c);
}
 
Example 10
Source File: ShapeDrawer.java    From shapedrawer with MIT License 2 votes vote down vote up
/**
 * <p>Draws a filled circle (disc) by calling {@link #filledEllipse(float, float, float, float, float, float, float)} with rotation set to 0
 * and radiusX and radiusY set to {@code radius}.</p>
 * @param centre the centre of the disc
 * @param radius the radius
 *  @param color the colour of the disc
 */
public void filledCircle(Vector2 centre, float radius, Color color) {
    float c = color.toFloatBits();
    filledEllipse(centre.x, centre.y, radius, radius, 0, c, c);
}
 
Example 11
Source File: ShapeDrawer.java    From shapedrawer with MIT License 2 votes vote down vote up
/**
 * <p>Calls {@link #filledTriangle(float, float, float, float, float, float, float, float, float)}.</p>
 * @param x1 x coordinate of first vertex
 * @param y1 y coordinate of first vertex
 * @param x2 x coordinate of second vertex
 * @param y2 y coordinate of second vertex
 * @param x3 x coordinate of third vertex
 * @param y3 y coordinate of third vertex
 * @param color colour of the triangle
 */
public void filledTriangle(float x1, float y1, float x2, float y2, float x3, float y3, Color color) {
    float c = color.toFloatBits();
    filledTriangle(x1, y1, x2, y2, x3, y3, c, c, c);
}