Java Code Examples for com.badlogic.gdx.graphics.glutils.ShapeRenderer#triangle()

The following examples show how to use com.badlogic.gdx.graphics.glutils.ShapeRenderer#triangle() . 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: SierpinskiTriangle.java    From ud405 with MIT License 6 votes vote down vote up
private void drawSierpinskiTriangle(ShapeRenderer shapeRenderer, Vector2 corner1, Vector2 corner2, Vector2 corner3, int recursions) {

        Vector2 midpoint12 = new Vector2((corner1.x + corner2.x) / 2, (corner1.y + corner2.y) / 2);
        Vector2 midpoint23 = new Vector2((corner2.x + corner3.x) / 2, (corner2.y + corner3.y) / 2);
        Vector2 midpoint31 = new Vector2((corner3.x + corner1.x) / 2, (corner3.y + corner1.y) / 2);

        if (recursions == 1) {
            shapeRenderer.triangle(corner1.x, corner1.y, midpoint12.x, midpoint12.y, midpoint31.x, midpoint31.y);
            shapeRenderer.triangle(corner2.x, corner2.y, midpoint23.x, midpoint23.y, midpoint12.x, midpoint12.y);
            shapeRenderer.triangle(corner3.x, corner3.y, midpoint31.x, midpoint31.y, midpoint23.x, midpoint23.y);
        } else {
            drawSierpinskiTriangle(shapeRenderer, corner1, midpoint12, midpoint31, recursions - 1);
            drawSierpinskiTriangle(shapeRenderer, corner2, midpoint23, midpoint12, recursions - 1);
            drawSierpinskiTriangle(shapeRenderer, corner3, midpoint31, midpoint23, recursions - 1);
        }

    }
 
Example 2
Source File: Icicle.java    From ud405 with MIT License 5 votes vote down vote up
public void render(ShapeRenderer renderer) {
    renderer.triangle(
            position.x, position.y,
            position.x - Constants.ICICLES_WIDTH / 2, position.y + Constants.ICICLES_HEIGHT,
            position.x + Constants.ICICLES_WIDTH / 2, position.y + Constants.ICICLES_HEIGHT
    );
}
 
Example 3
Source File: Icicle.java    From ud405 with MIT License 5 votes vote down vote up
public void render(ShapeRenderer renderer) {
    renderer.triangle(
            position.x, position.y,
            position.x - Constants.ICICLES_WIDTH / 2, position.y + Constants.ICICLES_HEIGHT,
            position.x + Constants.ICICLES_WIDTH / 2, position.y + Constants.ICICLES_HEIGHT
    );
}
 
Example 4
Source File: Icicle.java    From ud405 with MIT License 5 votes vote down vote up
public void render(ShapeRenderer renderer) {
    renderer.triangle(
            position.x, position.y,
            position.x - Constants.ICICLES_WIDTH / 2, position.y + Constants.ICICLES_HEIGHT,
            position.x + Constants.ICICLES_WIDTH / 2, position.y + Constants.ICICLES_HEIGHT
    );
}
 
Example 5
Source File: Icicle.java    From ud405 with MIT License 5 votes vote down vote up
public void render(ShapeRenderer renderer) {
    renderer.triangle(
            position.x, position.y,
            position.x - Constants.ICICLES_WIDTH / 2, position.y + Constants.ICICLES_HEIGHT,
            position.x + Constants.ICICLES_WIDTH / 2, position.y + Constants.ICICLES_HEIGHT
    );
}
 
Example 6
Source File: Icicle.java    From ud405 with MIT License 5 votes vote down vote up
public void render(ShapeRenderer renderer) {

        // TODO: Set the ShapeRenderer's color
        renderer.setColor(Constants.ICICLE_COLOR);

        // TODO: Set the ShapeType
        renderer.set(ShapeType.Filled);

        // TODO: Draw the icicle using the size constants
        renderer.triangle(
                position.x, position.y,
                position.x - Constants.ICICLES_WIDTH / 2, position.y + Constants.ICICLES_HEIGHT,
                position.x + Constants.ICICLES_WIDTH / 2, position.y + Constants.ICICLES_HEIGHT
        );
    }
 
Example 7
Source File: Icicle.java    From ud405 with MIT License 5 votes vote down vote up
public void render(ShapeRenderer renderer) {
    renderer.triangle(
            position.x, position.y,
            position.x - Constants.ICICLES_WIDTH / 2, position.y + Constants.ICICLES_HEIGHT,
            position.x + Constants.ICICLES_WIDTH / 2, position.y + Constants.ICICLES_HEIGHT
    );
}
 
Example 8
Source File: Icicle.java    From ud405 with MIT License 5 votes vote down vote up
public void render(ShapeRenderer renderer) {
    renderer.triangle(
            position.x, position.y,
            position.x - Constants.ICICLES_WIDTH / 2, position.y + Constants.ICICLES_HEIGHT,
            position.x + Constants.ICICLES_WIDTH / 2, position.y + Constants.ICICLES_HEIGHT
    );
}
 
Example 9
Source File: Icicle.java    From ud405 with MIT License 5 votes vote down vote up
public void render(ShapeRenderer renderer) {
    renderer.triangle(
            position.x, position.y,
            position.x - Constants.ICICLES_WIDTH / 2, position.y + Constants.ICICLES_HEIGHT,
            position.x + Constants.ICICLES_WIDTH / 2, position.y + Constants.ICICLES_HEIGHT
    );
}
 
Example 10
Source File: Icicle.java    From ud405 with MIT License 5 votes vote down vote up
public void render(ShapeRenderer renderer) {
    renderer.triangle(
            position.x, position.y,
            position.x - Constants.ICICLES_WIDTH / 2, position.y + Constants.ICICLES_HEIGHT,
            position.x + Constants.ICICLES_WIDTH / 2, position.y + Constants.ICICLES_HEIGHT
    );
}
 
Example 11
Source File: Icicle.java    From ud405 with MIT License 5 votes vote down vote up
public void render(ShapeRenderer renderer) {
    renderer.triangle(
            position.x, position.y,
            position.x - Constants.ICICLES_WIDTH / 2, position.y + Constants.ICICLES_HEIGHT,
            position.x + Constants.ICICLES_WIDTH / 2, position.y + Constants.ICICLES_HEIGHT
    );
}
 
Example 12
Source File: Icicle.java    From ud405 with MIT License 5 votes vote down vote up
public void render(ShapeRenderer renderer) {
    renderer.triangle(
            position.x, position.y,
            position.x - Constants.ICICLES_WIDTH / 2, position.y + Constants.ICICLES_HEIGHT,
            position.x + Constants.ICICLES_WIDTH / 2, position.y + Constants.ICICLES_HEIGHT
    );
}
 
Example 13
Source File: Icicle.java    From ud405 with MIT License 5 votes vote down vote up
public void render(ShapeRenderer renderer) {
    renderer.triangle(
            position.x, position.y,
            position.x - Constants.ICICLES_WIDTH / 2, position.y + Constants.ICICLES_HEIGHT,
            position.x + Constants.ICICLES_WIDTH / 2, position.y + Constants.ICICLES_HEIGHT
    );
}
 
Example 14
Source File: Icicle.java    From ud405 with MIT License 5 votes vote down vote up
public void render(ShapeRenderer renderer) {
    renderer.triangle(
            position.x, position.y,
            position.x - Constants.ICICLES_WIDTH / 2, position.y + Constants.ICICLES_HEIGHT,
            position.x + Constants.ICICLES_WIDTH / 2, position.y + Constants.ICICLES_HEIGHT
    );
}
 
Example 15
Source File: Icicle.java    From ud405 with MIT License 5 votes vote down vote up
public void render(ShapeRenderer renderer) {
    renderer.triangle(
            position.x, position.y,
            position.x - Constants.ICICLES_WIDTH / 2, position.y + Constants.ICICLES_HEIGHT,
            position.x + Constants.ICICLES_WIDTH / 2, position.y + Constants.ICICLES_HEIGHT
    );
}
 
Example 16
Source File: Icicle.java    From ud405 with MIT License 5 votes vote down vote up
public void render(ShapeRenderer renderer) {
    renderer.triangle(
            position.x, position.y,
            position.x - Constants.ICICLES_WIDTH / 2, position.y + Constants.ICICLES_HEIGHT,
            position.x + Constants.ICICLES_WIDTH / 2, position.y + Constants.ICICLES_HEIGHT
    );
}
 
Example 17
Source File: Icicle.java    From ud405 with MIT License 5 votes vote down vote up
public void render(ShapeRenderer renderer) {
    renderer.triangle(
            position.x, position.y,
            position.x - Constants.ICICLES_WIDTH / 2, position.y + Constants.ICICLES_HEIGHT,
            position.x + Constants.ICICLES_WIDTH / 2, position.y + Constants.ICICLES_HEIGHT
    );
}
 
Example 18
Source File: Icicle.java    From ud405 with MIT License 5 votes vote down vote up
public void render(ShapeRenderer renderer) {
    renderer.triangle(
            position.x, position.y,
            position.x - Constants.ICICLES_WIDTH / 2, position.y + Constants.ICICLES_HEIGHT,
            position.x + Constants.ICICLES_WIDTH / 2, position.y + Constants.ICICLES_HEIGHT
    );
}
 
Example 19
Source File: Icicle.java    From ud405 with MIT License 5 votes vote down vote up
public void render(ShapeRenderer renderer) {
    renderer.triangle(
            position.x, position.y,
            position.x - Constants.ICICLES_WIDTH / 2, position.y + Constants.ICICLES_HEIGHT,
            position.x + Constants.ICICLES_WIDTH / 2, position.y + Constants.ICICLES_HEIGHT
    );
}
 
Example 20
Source File: DebugUtils.java    From riiablo with Apache License 2.0 5 votes vote down vote up
public static void drawDiamond2(ShapeRenderer shapes, float x, float y, int width, int height) {
  int hw = width  >>> 1;
  int hh = height >>> 1;
  if (shapes.getCurrentType() == ShapeRenderer.ShapeType.Filled) {
    shapes.triangle(x, y + hh, x + hw, y + height, x + width, y + hh);
    shapes.triangle(x, y + hh, x + hw, y         , x + width, y + hh);
  } else {
    shapes.line(x        , y + hh    , x + hw   , y + height);
    shapes.line(x + hw   , y + height, x + width, y + hh    );
    shapes.line(x + width, y + hh    , x + hw   , y         );
    shapes.line(x + hw   , y         , x        , y + hh    );
  }
}