Skip to content

Commit 03cf2d9

Browse files
Round rects; limit radius to 1/2 minor axis
1 parent 9bdc390 commit 03cf2d9

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

Adafruit_GFX.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,9 @@ void Adafruit_GFX::drawRect(int16_t x, int16_t y, int16_t w, int16_t h,
495495
*/
496496
/**************************************************************************/
497497
void Adafruit_GFX::drawRoundRect(int16_t x, int16_t y, int16_t w,
498-
int16_t h, int16_t r, uint16_t color) {
498+
int16_t h, int16_t r, uint16_t color) {
499+
int16_t max_radius = ((w < h) ? w : h) / 2; // 1/2 minor axis
500+
if(r > max_radius) r = max_radius;
499501
// smarter version
500502
startWrite();
501503
writeFastHLine(x+r , y , w-2*r, color); // Top
@@ -522,11 +524,12 @@ void Adafruit_GFX::drawRoundRect(int16_t x, int16_t y, int16_t w,
522524
*/
523525
/**************************************************************************/
524526
void Adafruit_GFX::fillRoundRect(int16_t x, int16_t y, int16_t w,
525-
int16_t h, int16_t r, uint16_t color) {
527+
int16_t h, int16_t r, uint16_t color) {
528+
int16_t max_radius = ((w < h) ? w : h) / 2; // 1/2 minor axis
529+
if(r > max_radius) r = max_radius;
526530
// smarter version
527531
startWrite();
528532
writeFillRect(x+r, y, w-2*r, h, color);
529-
530533
// draw four corners
531534
fillCircleHelper(x+w-r-1, y+r, r, 1, h-2*r-1, color);
532535
fillCircleHelper(x+r , y+r, r, 2, h-2*r-1, color);

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=Adafruit GFX Library
2-
version=1.3.3
2+
version=1.3.4
33
author=Adafruit
44
maintainer=Adafruit <[email protected]>
55
sentence=Adafruit GFX graphics core library, this is the 'core' class that all our other graphics libraries derive from.

0 commit comments

Comments
 (0)