/** @see #rectLine(float, float, float, float, float) */ public void rectLine (Vector2 p1, Vector2 p2, float width) { rectLine(p1.x, p1.y, p2.x, p2.y, width); }
/** @see #rectLine(float, float, float, float, float) */ public void rectLine (Vector2 p1, Vector2 p2, float width) { rectLine(p1.x, p1.y, p2.x, p2.y, width); }
/** Draws a line using {@link ShapeType#Line} or {@link ShapeType#Filled}. The line is drawn with two colors interpolated * between the start and end points. */ public void line (float x, float y, float z, float x2, float y2, float z2, Color c1, Color c2) { if (shapeType == ShapeType.Filled) { rectLine(x, y, x2, y2, defaultRectLineWidth, c1, c2); return; } check(ShapeType.Line, null, 2); renderer.color(c1.r, c1.g, c1.b, c1.a); renderer.vertex(x, y, z); renderer.color(c2.r, c2.g, c2.b, c2.a); renderer.vertex(x2, y2, z2); }
/** Draws a line using {@link ShapeType#Line} or {@link ShapeType#Filled}. The line is drawn with two colors interpolated * between the start and end points. */ public void line (float x, float y, float z, float x2, float y2, float z2, Color c1, Color c2) { if (shapeType == ShapeType.Filled) { rectLine(x, y, x2, y2, defaultRectLineWidth, c1, c2); return; } check(ShapeType.Line, null, 2); renderer.color(c1.r, c1.g, c1.b, c1.a); renderer.vertex(x, y, z); renderer.color(c2.r, c2.g, c2.b, c2.a); renderer.vertex(x2, y2, z2); }
/** @see #rectLine(float, float, float, float, float) */ public void rectLine (Vector2 p1, Vector2 p2, float width) { rectLine(p1.x, p1.y, p2.x, p2.y, width); }
if (Gdx.input.isTouched()) { ShapeRenderer sr = new ShapeRenderer(); sr.setColor(Color.BLACK); sr.setProjectionMatrix(camera.combined); sr.begin(ShapeType.Filled); sr.rectLine(player.getLeft().x, player.getLeft().y, Global.game_touch_position.x, Global.game_touch_position.y, desired_thickness); sr.rectLine(player.getRight().x, player.getRight().y, Global.game_touch_position.x, Global.game_touch_position.y, desired_thickness); sr.end(); }
ShapeRenderer shapeRenderer = new ShapeRenderer(); shapeRenderer.begin(ShapeType.Filled); shapeRenderer.rectLine(x1, y1, x2, y2, width); shapeRenderer.end();
@Override public void drawRect(float x, float y, float width, float height) { int roundWidth = MathUtils.round(width); int roundHeight = MathUtils.round(height); beginRendering(); endRendering(); renderingShapes = true; shapeRenderer.begin(ShapeType.Filled); Gdx.gl.glEnable(GL20.GL_BLEND); Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA); shapeRenderer.setColor(color); shapeRenderer.rectLine(x, y, x + roundWidth, y, lineHeight); shapeRenderer.rectLine(x, y, x , y + roundHeight, lineHeight); shapeRenderer.rectLine(x + roundWidth, y, x + roundWidth, y + roundHeight, lineHeight); shapeRenderer.rectLine(x, y + roundHeight, x + roundWidth, y + roundHeight, lineHeight); shapeRenderer.end(); beginRendering(); }
/** Draws a line using {@link ShapeType#Line} or {@link ShapeType#Filled}. The line is drawn with two colors interpolated * between the start and end points. */ public void line (float x, float y, float z, float x2, float y2, float z2, Color c1, Color c2) { if (shapeType == ShapeType.Filled) { rectLine(x, y, x2, y2, defaultRectLineWidth, c1, c2); return; } check(ShapeType.Line, null, 2); renderer.color(c1.r, c1.g, c1.b, c1.a); renderer.vertex(x, y, z); renderer.color(c2.r, c2.g, c2.b, c2.a); renderer.vertex(x2, y2, z2); }
renderer.rectLine(x, y, x += 2, y = Math.max(base, base + Math.round(property.values[i] / property.maximum * 36)), 2);
@Override public void drawLineSegment(float x1, float y1, float x2, float y2) { beginRendering(); endRendering(); /* TODO: Move all shape rendering over to using ShapeRenderer */ renderingShapes = true; shapeRenderer.begin(ShapeType.Filled); Gdx.gl.glEnable(GL20.GL_BLEND); Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA); shapeRenderer.setColor(color); shapeRenderer.rectLine(x1, y1, x2, y2, lineHeight); shapeRenderer.end(); beginRendering(); }
@Override public void render() { Gdx.gl.glClearColor(0, 0, 0, 1); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); shapeRenderer.begin(ShapeType.Filled); shapeRenderer.setColor(Color.GREEN); // Draw the stem shapeRenderer.rectLine(100, 0, 100, 300, 20); // TODO: Draw two leaves on the stem using rotated rectangles shapeRenderer.rect(100, 100, 0, 0, 40, 40, 1, 1, 135); shapeRenderer.rect(100, 150, 0, 0, 30, 30, 1, 1, 315); // TODO: Set the active color to yellow shapeRenderer.setColor(Color.YELLOW); // TODO: Use a loop to draw 20 of these petals in a circle final int petals = 20; for (int petal = 0; petal < petals; petal++) { shapeRenderer.rect(100, 300, 0, 0, 40, 40, 1, 1, 360.0f * petal / petals); } shapeRenderer.end(); } }
shapeRenderer.setColor(COLOR_X); shapeRenderer.setProjectionMatrix(shapeRenderMat); shapeRenderer.rectLine(pivot.x, pivot.y, Gdx.input.getX(), Gdx.graphics.getHeight() - Gdx.input.getY(), 2); shapeRenderer.end(); shapeRenderer.setColor(COLOR_Y); shapeRenderer.setProjectionMatrix(shapeRenderMat); shapeRenderer.rectLine(pivot.x, pivot.y, Gdx.input.getX(), Gdx.graphics.getHeight() - Gdx.input.getY(), 2); shapeRenderer.end(); shapeRenderer.setColor(COLOR_Z); shapeRenderer.setProjectionMatrix(shapeRenderMat); shapeRenderer.rectLine(pivot.x, pivot.y, Gdx.input.getX(), Gdx.graphics.getHeight() - Gdx.input.getY(), 2); shapeRenderer.end(); shapeRenderer.setColor(COLOR_XYZ); shapeRenderer.setProjectionMatrix(shapeRenderMat); shapeRenderer.rectLine(pivot.x, pivot.y, Gdx.input.getX(), Gdx.graphics.getHeight() - Gdx.input.getY(), 2); shapeRenderer.end();
shapeRenderer.setColor(Color.BLACK); shapeRenderer.setProjectionMatrix(shapeRenderMat); shapeRenderer.rectLine(pivot.x, pivot.y, Gdx.input.getX(), Gdx.graphics.getHeight() - Gdx.input.getY(), 2); shapeRenderer.setColor(COLOR_X); shapeRenderer.setColor(Color.BLACK); shapeRenderer.setProjectionMatrix(shapeRenderMat); shapeRenderer.rectLine(pivot.x, pivot.y, Gdx.input.getX(), Gdx.graphics.getHeight() - Gdx.input.getY(), 2); shapeRenderer.setColor(COLOR_Y); shapeRenderer.setColor(Color.BLACK); shapeRenderer.setProjectionMatrix(shapeRenderMat); shapeRenderer.rectLine(pivot.x, pivot.y, Gdx.input.getX(), Gdx.graphics.getHeight() - Gdx.input.getY(), 2); shapeRenderer.setColor(COLOR_Z);
public void draw(Batch batch, float a) { batch.end(); rend.setProjectionMatrix(batch.getProjectionMatrix()); rend.setTransformMatrix(batch.getTransformMatrix()); rend.setColor(getColor()); rend.begin(ShapeType.Filled); for (int i = 0; i < path.size - 1; i++) { Vector2 now = path.get(i); Vector2 next = path.get(i + 1); rend.rectLine(now.x + getX(), now.y + getY(), next.x + getX(), next.y + getY(), strokeWidth); rend.circle(now.x + getX(), now.y + getY(), strokeWidth / 2); } rend.circle(path.peek().x + getX(), path.peek().y + getY(), strokeWidth / 2); rend.end(); batch.begin(); } }
shapeRenderer.rectLine(0, 200, 200, 250, 10);