public void draw(Graphics2D g, Matrix3x3f view) { g.setColor(color); Vector2f topLeft = new Vector2f(curPos.x - radius, curPos.y + radius); topLeft = view.mul(topLeft); Vector2f bottomRight = new Vector2f(curPos.x + radius, curPos.y - radius); bottomRight = view.mul(bottomRight); int circleX = (int) topLeft.x; int circleY = (int) topLeft.y; int circleWidth = (int) (bottomRight.x - topLeft.x); int circleHeight = (int) (bottomRight.y - topLeft.y); g.fillOval(circleX, circleY, circleWidth, circleHeight); }
private Vector2f[] transform(Vector2f[] poly, Matrix3x3f mat) { Vector2f[] copy = new Vector2f[poly.length]; for (int i = 0; i < poly.length; ++i) { copy[i] = mat.mul(poly[i]); } return copy; }
private Vector2f[] wrapSouth(Vector2f[] poly) { return transform(poly, Matrix3x3f.translate(0.0f, -worldHeight)); }
private Vector2f[] wrapSouthWest(Vector2f[] poly) { return transform(poly, Matrix3x3f.translate(-worldWidth, -worldHeight)); }
private Vector2f[] wrapNorthEast(Vector2f[] poly) { return transform(poly, Matrix3x3f.translate(worldWidth, worldHeight)); }
private Vector2f[] wrapWest(Vector2f[] poly) { return transform(poly, Matrix3x3f.translate(-worldWidth, 0.0f)); }