Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fillArc Arc2D arc type may wrong #14

Closed
Trisia opened this issue Feb 2, 2023 · 3 comments
Closed

fillArc Arc2D arc type may wrong #14

Trisia opened this issue Feb 2, 2023 · 3 comments

Comments

@Trisia
Copy link

Trisia commented Feb 2, 2023

fillArc method use Arc2D arc(int x, int y, int width, int height, int startAngle, int arcAngle) create Arc2D

public void fillArc(int x, int y, int width, int height, int startAngle,
int arcAngle) {
if (LOG_ENABLED) {
LOGGER.debug("fillArc({}, {}, {}, {}, {}, {})", x, y, width, height, startAngle, arcAngle);
}
fill(arc(x, y, width, height, startAngle, arcAngle));
}

In arc method use Arc2D.OPEN as default type, but fillArc expect Arc2D.PIE type

private Arc2D arc(int x, int y, int width, int height, int startAngle,
int arcAngle) {
if (this.arc == null) {
this.arc = new Arc2D.Double(x, y, width, height, startAngle,
arcAngle, Arc2D.OPEN);
} else {
this.arc.setArc(x, y, width, height, startAngle, arcAngle,
Arc2D.OPEN);
}
return this.arc;
}

The following code proves my suspicion

    public static void main(String[] args) throws IOException {
        BufferedImage image = new BufferedImage(500, 500, BufferedImage.TYPE_INT_ARGB);
        Graphics2D g = image.createGraphics();
        g.setPaint(Color.RED);
        g.fillArc(20, 20, 200, 200,200,200);
        ImageIO.write(image, "png", new File("test.png"));
    }

test

@Trisia Trisia changed the title fillArc Arc2D type may wrong fillArc Arc2D arc type may wrong Feb 2, 2023
@jfree
Copy link
Owner

jfree commented Feb 4, 2023

Good spot! I didn't notice this as I tend to use the draw(Shape) and fill(Shape) methods. I'm going to add a test case to this to the Graphics2D tester project then fix all the broken implementations.

@Trisia
Copy link
Author

Trisia commented Feb 5, 2023

thinks

jfree added a commit that referenced this issue Feb 5, 2023
@jfree
Copy link
Owner

jfree commented Feb 5, 2023

Fix is committed.

@jfree jfree closed this as completed Feb 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants