List of usage examples for com.badlogic.gdx.graphics.glutils ShapeRenderer end
public void end()
From source file:com.github.mkjensen.breakall.actor.Wall.java
License:Apache License
@Override protected void draw(ShapeRenderer renderer) { renderer.begin(ShapeType.Filled);/*from w ww. jav a 2 s . co m*/ renderer.setColor(Color.YELLOW); renderer.rect(getX() - getWidth() / 2, getY() - getHeight() / 2, getWidth(), getHeight()); renderer.end(); }
From source file:com.kotcrab.vis.editor.module.scene.entitymanipulator.RectangularSelection.java
License:Apache License
public void render(ShapeRenderer shapeRenderer) { if (rectToDraw != null) { Gdx.gl20.glEnable(GL20.GL_BLEND); Color border = selectionMode == SelectionMode.Inner ? INNER_MODE_BORDER_COLOR : OVERLAP_MODE_BORDER_COLOR; Color fill = selectionMode == SelectionMode.Inner ? INNER_MODE_FILL_COLOR : OVERLAP_MODE_FILL_COLOR; shapeRenderer.setColor(border);// w ww . j av a2 s. c o m shapeRenderer.begin(ShapeType.Line); shapeRenderer.rect(rectToDraw.getX(), rectToDraw.getY(), rectToDraw.getWidth(), rectToDraw.getHeight()); shapeRenderer.end(); shapeRenderer.setColor(fill); shapeRenderer.begin(ShapeType.Filled); shapeRenderer.rect(rectToDraw.getX(), rectToDraw.getY(), rectToDraw.getWidth(), rectToDraw.getHeight()); shapeRenderer.end(); } }
From source file:com.kotcrab.vis.editor.module.scene.entitymanipulator.tool.RotateTool.java
License:Apache License
@Override public void render(ShapeRenderer shapeRenderer) { super.render(shapeRenderer); if (totalSelectionBounds != null) { innerRadius = camera.getZoom() * 0.6f * 100f / scene.pixelsPerUnit; outerRadius = camera.getZoom() * 0.7f * 100f / scene.pixelsPerUnit; circleCenterX = totalSelectionBounds.x + totalSelectionBounds.width / 2; circleCenterY = totalSelectionBounds.y + totalSelectionBounds.height / 2; shapeRenderer.setColor(Color.WHITE); shapeRenderer.begin(ShapeType.Line); shapeRenderer.circle(circleCenterX, circleCenterY, innerRadius, 36); shapeRenderer.circle(circleCenterX, circleCenterY, outerRadius, 36); float rotation = entityManipulator.getSelectedEntities().peek().getRotation(); float startX = circleCenterX; float startY = circleCenterY - innerRadius; float endX = circleCenterX; float endY = circleCenterY + innerRadius; shapeRenderer.setColor(Color.RED); ShapeRendererUtils.lineRotatedAroundPoint(shapeRenderer, startX, startY, endX, endY, rotation, circleCenterX, circleCenterY); shapeRenderer.setColor(Color.GREEN); ShapeRendererUtils.lineRotatedAroundPoint(shapeRenderer, startX, startY, endX, endY, rotation + 90, circleCenterX, circleCenterY); shapeRenderer.end(); }/*from w ww .ja v a2 s . c o m*/ }
From source file:com.kotcrab.vis.editor.module.scene.entitymanipulator.tool.ScaleTool.java
License:Apache License
@Override public void render(ShapeRenderer shapeRenderer) { super.render(shapeRenderer); if (totalSelectionBounds != null) { float centerX = totalSelectionBounds.x + totalSelectionBounds.width / 2; float centerY = totalSelectionBounds.y + totalSelectionBounds.height / 2; float centerRectSize = 0.1f * camera.getZoom() * 100f / scene.pixelsPerUnit; float lineLengthX = 1 * camera.getZoom() * 100f / scene.pixelsPerUnit; float lineLengthY = 1 * camera.getZoom() * 100f / scene.pixelsPerUnit; if (Gdx.input.isButtonPressed(Buttons.LEFT)) { if (mouseLooping.isOnVirtualScreen() == false) { if (mouseInsideRectX) lineLengthX = camera.getInputX() - centerX; if (mouseInsideRectY) lineLengthY = camera.getInputY() - centerY; } else { //if mouse is on virtual screen, method above won't work because line would be flipped //but also on virtual screen line end won't be visible anyways so we are just drawing very long line if (mouseInsideRectX) lineLengthX = 100000; if (mouseInsideRectY) lineLengthY = 100000; }//from w ww . ja v a 2 s. co m } shapeRenderer.setColor(Color.GREEN); shapeRenderer.begin(ShapeType.Line); shapeRenderer.line(centerX, centerY, centerX + lineLengthX, centerY); shapeRenderer.end(); shapeRenderer.setColor(mouseInsideRectX ? xRectOver : xRect); shapeRenderer.begin(ShapeType.Filled); rect(shapeRenderer, xScaleRect.set(centerX + lineLengthX - centerRectSize / 2, centerY - centerRectSize / 2, centerRectSize, centerRectSize)); shapeRenderer.end(); shapeRenderer.setColor(Color.RED); shapeRenderer.begin(ShapeType.Line); shapeRenderer.line(centerX, centerY, centerX, centerY + lineLengthY); shapeRenderer.end(); shapeRenderer.setColor(mouseInsideRectY ? yRectOver : yRect); shapeRenderer.begin(ShapeType.Filled); rect(shapeRenderer, yScaleRect.set(centerX - centerRectSize / 2, centerY + lineLengthY - centerRectSize / 2, centerRectSize, centerRectSize)); shapeRenderer.end(); } }
From source file:com.kotcrab.vis.editor.module.scene.RectangularSelection.java
License:Apache License
public void render(ShapeRenderer shapeRenderer) { if (rectToDraw != null) { Gdx.gl20.glEnable(GL20.GL_BLEND); shapeRenderer.setColor(0.11f, 0.63f, 0.89f, 1); shapeRenderer.begin(ShapeType.Line); shapeRenderer.rect(rectToDraw.getX(), rectToDraw.getY(), rectToDraw.getWidth(), rectToDraw.getHeight()); shapeRenderer.end(); shapeRenderer.setColor(0.05f, 0.33f, 0.49f, 0.3f); shapeRenderer.begin(ShapeType.Filled); shapeRenderer.rect(rectToDraw.getX(), rectToDraw.getY(), rectToDraw.getWidth(), rectToDraw.getHeight()); shapeRenderer.end();//from w ww. j a va 2 s. c o m } }
From source file:com.mygdx.g3il.screens.MainMenuScreen.java
License:Apache License
@Override public void draw(float delta) { Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); camera.update();/*from ww w . j a v a 2 s. c o m*/ ShapeRenderer shapeRenderer = new ShapeRenderer(); shapeRenderer.setProjectionMatrix(camera.combined); shapeRenderer.begin(ShapeRenderer.ShapeType.Line); shapeRenderer.setColor(1, 1, 0, 1); shapeRenderer.rect(playBounds.x, playBounds.y, playBounds.getWidth(), playBounds.getHeight()); shapeRenderer.rect(highscoresBounds.x, highscoresBounds.y, highscoresBounds.getWidth(), highscoresBounds.getHeight()); shapeRenderer.end(); game.batch.setProjectionMatrix(camera.combined); game.batch.setColor(Color.WHITE); game.batch.begin(); game.batch.disableBlending(); game.batch.draw(background, 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); game.batch.end(); game.batch.enableBlending(); game.batch.begin(); final Vector2 position = new Vector2(); drawText("Play", playBounds.getCenter(position)); drawText("High Scores", highscoresBounds.getCenter(position)); //drawText("Help", helpBounds.getCenter(position)); game.batch.end(); }
From source file:com.nebula2d.editor.framework.components.BoundingBox.java
License:Open Source License
@Override public void render(GameObject selectedObject, SpriteBatch batcher, Camera cam) { if (gameObject != null && w > 0 && h > 0) { batcher.end();/*from w ww. j ava 2 s. c o m*/ ShapeRenderer shape = new ShapeRenderer(); shape.setProjectionMatrix(cam.combined); shape.setColor(Color.RED); shape.begin(ShapeRenderer.ShapeType.Line); float halfw = w / 2.0f; float halfh = h / 2.0f; float x = gameObject.getPosition().x - halfw; float y = gameObject.getPosition().y - halfh; shape.rect(x, y, w, h); shape.end(); batcher.begin(); } }
From source file:com.nebula2d.editor.framework.components.Circle.java
License:Open Source License
@Override public void render(GameObject selectedObject, SpriteBatch batcher, Camera cam) { if (gameObject != null && r % 360 != 0) { batcher.end();//from ww w . j a v a2 s. c o m ShapeRenderer shape = new ShapeRenderer(); shape.setProjectionMatrix(cam.combined); shape.setColor(Color.RED); shape.begin(ShapeRenderer.ShapeType.Line); float x = gameObject.getPosition().x; float y = gameObject.getPosition().y; shape.circle(x, y, r); shape.end(); batcher.begin(); } }
From source file:com.nebula2d.editor.framework.GameObject.java
License:Open Source License
public void render(GameObject selectedObject, SpriteBatch batcher, Camera cam) { if (renderer != null && renderer.isEnabled()) { renderer.render(selectedObject, batcher, cam); } else {//from www . j a v a 2 s . co m batcher.end(); Gdx.gl.glEnable(GL20.GL_BLEND); ShapeRenderer shape = new ShapeRenderer(); shape.setProjectionMatrix(cam.combined); OrthographicCamera ortho = (OrthographicCamera) cam; shape.begin(ShapeRenderer.ShapeType.Filled); shape.setColor(new Color(0f, 1f, 0f, 0.5f)); shape.circle(getPosition().x, getPosition().y, 4 * ortho.zoom); shape.end(); Gdx.gl.glDisable(GL20.GL_BLEND); batcher.begin(); } for (IRenderable renderable : renderables) { if (((Component) renderable).isEnabled()) { renderable.render(selectedObject, batcher, cam); } } }
From source file:com.nebula2d.editor.ui.RenderAdapter.java
License:Open Source License
@Override public void render() { Gdx.graphics.getGL20().glClearColor(.17f, .17f, .17f, 1.0f); Gdx.graphics.getGL20().glClear(GL20.GL_COLOR_BUFFER_BIT); if (!enabled) return;/*w ww . j a v a 2 s . c om*/ if (camera == null) return; batcher.setProjectionMatrix(camera.projection); batcher.begin(); Project p = MainFrame.getProject(); if (p != null && p.getCurrentScene() != null) { p.getCurrentScene().render(selectedObject, batcher, camera); } batcher.end(); if (selectedObject != null && selectedObject.getRenderer() != null && selectedObject.getRenderer().isReady()) { Rectangle boundingBox = selectedObject.getRenderer().getBoundingBox(camera); if (boundingBox != null) { Gdx.gl.glEnable(GL20.GL_BLEND); // Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA); ShapeRenderer shape = new ShapeRenderer(); shape.setColor(new Color(0.0f, 1.0f, 0.0f, 0.5f)); shape.begin(ShapeRenderer.ShapeType.Filled); float x = boundingBox.getX(); float y = boundingBox.getY(); shape.rect(x, y, boundingBox.getWidth(), boundingBox.getHeight()); shape.end(); Gdx.gl.glDisable(GL20.GL_BLEND); } } }