Skip to main content
SKILA
Associate III
April 30, 2020
Question

How to draw a rounded rectangle?

  • April 30, 2020
  • 7 replies
  • 1958 views

Hello all,

Is there a way to draw a rounded filled rectangle dynamically and assign it to a button?

Thanks!

Samer

This topic has been closed for replies.

7 replies

Martin KJELDSEN
Principal III
April 30, 2020

Can i ask why you'd want to do that dynamically? Because the size of your buttons change dynamically? Otherwise i'd simply draw them in paint.exe as an asset and use those. There's no direct support for drawing filled, rounded rectangles, no. You could create a custom widget that took a width and height and color, then you would have 4 images of rounded edges with full alpha that you place in each corner to indicate a rounded rectangle. You'd use the DMA to draw a color for the body and only a small piece of flash for the 4 images, which are reusable for all colors and perhaps sizes.

/Martin

SKILA
SKILAAuthor
Associate III
April 30, 2020

Perhaps I shouldn't have said dynamic​ because none of the shapes change during runtime. What I would really want to do is reduce the overall size of my firmware. I have many rounded rectangles in my design with a single filled colour. I can see that for some of the large rectangles the size of the generated file exceeds 1Mb which I just feel to be a waste.

​

Samer​

Martin KJELDSEN
Principal III
April 30, 2020

Ok. Did my suggestion make sense? You save some flash, pay some RAM instead.