Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified scripts/android/screenshots/graphics-draw-arc.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ protected void drawContent(Graphics g, Rectangle bounds) {
g.setColor(0xffffff);
for (int iter = 0 ; iter < bounds.getWidth() / 2 ; iter++) {
nextColor(g);
g.drawArc(bounds.getX() + iter, bounds.getY() + iter, bounds.getX() + bounds.getWidth() - iter, bounds.getY() + bounds.getHeight() + iter, iter, 180);
g.drawArc(bounds.getX() + iter, bounds.getY() + iter, bounds.getWidth() - iter * 2, bounds.getHeight() - iter * 2, iter, 180);
Comment on lines 11 to +13

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Guard drawArc loop from negative height when width > height

The loop stops at bounds.getWidth() / 2 while each iteration shrinks both dimensions by iter * 2; when a GridLayout cell is wider than it is tall (e.g., landscape devices), iterations past bounds.getHeight() / 2 will call Graphics.drawArc with zero or negative height. Graphics expects positive dimensions (see CodenameOne/src/com/codename1/ui/Graphics.java:527-537 for the analogous fillArc check), so this can yield missing arcs or platform-specific IllegalArgumentExceptions in wide layouts. Consider capping the loop by the smaller of width/height or checking height before drawing.

Useful? React with 👍 / 👎.

}
}

Expand Down
Loading