Skip to content

Commit

Permalink
Improve focus renderer after adjusting ShapeRenderer.
Browse files Browse the repository at this point in the history
  • Loading branch information
steffen-wilke committed Jan 31, 2021
1 parent 07eec17 commit 49708b4
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,22 @@ public void render(Graphics2D g) {
final Rectangle2D focus = Editor.instance().getMapComponent().getFocusBounds();
final IMapObject focusedMapObject = Editor.instance().getMapComponent().getFocusedMapObject();
if (focus != null && focusedMapObject != null) {
Stroke stroke = new BasicStroke(1 / Game.world().camera().getRenderScale(), BasicStroke.CAP_ROUND, BasicStroke.JOIN_MITER, 4, new float[] { 1f, 1f }, Game.time().now() / 15f);
final float strokeSize = (float) Math.max(1, Math.log(Game.world().camera().getRenderScale()) * 4);
final float dashPhaseBlack = (float) ((Game.time().now() / 15f) * Math.max(1, Math.sqrt(Game.world().camera().getRenderScale())));
final float dashPhaseWhite = dashPhaseBlack + strokeSize;
Stroke stroke = new BasicStroke(1, BasicStroke.CAP_ROUND, BasicStroke.JOIN_MITER, strokeSize, new float[] { strokeSize, strokeSize }, dashPhaseBlack);

g.setColor(Color.BLACK);

Game.graphics().renderOutline(g, focus, stroke);

Stroke whiteStroke = new BasicStroke(1 / Game.world().camera().getRenderScale(), BasicStroke.CAP_ROUND, BasicStroke.JOIN_MITER, 4, new float[] { 1f, 1f }, Game.time().now() / 15.0f - 1f);
Stroke whiteStroke = new BasicStroke(1, BasicStroke.CAP_ROUND, BasicStroke.JOIN_MITER, strokeSize, new float[] { strokeSize, strokeSize }, dashPhaseWhite);
g.setColor(Color.WHITE);
Game.graphics().renderOutline(g, focus, whiteStroke);

// render transform rects
if (Editor.instance().getMapComponent().getEditMode() != MapComponent.EDITMODE_MOVE) {
Stroke transStroke = new BasicStroke(1 / Game.world().camera().getRenderScale());
Stroke transStroke = new BasicStroke(1);
for (Rectangle2D trans : Transform.getAnchors()) {
g.setColor(Style.COLOR_TRANSFORM_RECT_FILL);
Game.graphics().renderShape(g, trans);
Expand Down

0 comments on commit 49708b4

Please sign in to comment.