Skip to content

Commit

Permalink
fix wrong bounds being reported
Browse files Browse the repository at this point in the history
  • Loading branch information
xzel23 committed Jan 6, 2025
1 parent 9673b75 commit 483d672
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.dua3.utility.awt.AwtImageUtil;
import com.dua3.utility.data.Image;
import com.dua3.utility.lang.LangUtil;
import com.dua3.utility.math.geometry.Path2f;
import com.dua3.utility.math.geometry.Vector2f;
import com.dua3.utility.ui.Graphics;
Expand Down Expand Up @@ -124,19 +125,19 @@ public SwingGraphics(Graphics2D g2d, Rectangle bounds) {

@Override
public float getWidth() {
return (float) parentBounds.getWidth();
return (float) g2d.getClipBounds().getWidth();
}

@Override
public float getHeight() {
return (float) parentBounds.height;
return (float) g2d.getClipBounds().getHeight();
}

@Override
public Rectangle2f getBounds() {
assert isDrawing : "instance has been closed!";

return convert(parentBounds);
return convert(LangUtil.orElse(g2d.getClipBounds(), parentBounds));
}

/**
Expand Down

0 comments on commit 483d672

Please sign in to comment.