diff --git a/FactorioBlueprintStringRenderer/src/com/demod/fbsr/Direction.java b/FactorioBlueprintStringRenderer/src/com/demod/fbsr/Direction.java index ed20450..bc8ebbd 100644 --- a/FactorioBlueprintStringRenderer/src/com/demod/fbsr/Direction.java +++ b/FactorioBlueprintStringRenderer/src/com/demod/fbsr/Direction.java @@ -1,5 +1,6 @@ package com.demod.fbsr; +import java.awt.geom.AffineTransform; import java.awt.geom.Point2D; import java.awt.geom.Point2D.Double; import java.awt.geom.Rectangle2D; @@ -86,4 +87,10 @@ public enum Direction { Direction[] values = values(); return values[(((ordinal() + deltaIndex) % values.length) + values.length) % values.length]; } + + public Rectangle2D rotateBounds(Rectangle2D bounds) { + AffineTransform at = new AffineTransform(); + at.rotate(Math.PI * 2.0 * ordinal() / 8.0); + return at.createTransformedShape(bounds).getBounds2D(); + } } \ No newline at end of file diff --git a/FactorioBlueprintStringRenderer/src/com/demod/fbsr/FBSR.java b/FactorioBlueprintStringRenderer/src/com/demod/fbsr/FBSR.java index e46fb19..105962c 100644 --- a/FactorioBlueprintStringRenderer/src/com/demod/fbsr/FBSR.java +++ b/FactorioBlueprintStringRenderer/src/com/demod/fbsr/FBSR.java @@ -93,14 +93,14 @@ public class FBSR { } Point2D.Double position = tuple.entity.getPosition(); - Rectangle2D.Double selectionBox; + Rectangle2D selectionBox; if (tuple.prototype != null) { - selectionBox = tuple.prototype.getSelectionBox(); + selectionBox = tuple.entity.getDirection().rotateBounds(tuple.prototype.getSelectionBox()); } else { selectionBox = new Rectangle2D.Double(); } - Rectangle2D.Double bounds = new Rectangle2D.Double(selectionBox.x + position.x, selectionBox.y + position.y, - selectionBox.width, selectionBox.height); + Rectangle2D.Double bounds = new Rectangle2D.Double(selectionBox.getX() + position.x, + selectionBox.getY() + position.y, selectionBox.getWidth(), selectionBox.getHeight()); // System.out.println(bounds); // Everything is doubled and rounded to the closest original 0.5