2020-04-30 09:19 AM
Hello all,
Is there a way to draw a rounded filled rectangle dynamically and assign it to a button?
Thanks!
Samer
2020-04-30 10:32 AM
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
2020-04-30 11:05 AM
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
2020-04-30 11:12 AM
Ok. Did my suggestion make sense? You save some flash, pay some RAM instead.
2020-04-30 11:44 AM
There is more than enough RAM and Flash on my board. The problem is with the size of the firmware. The board is part of a larger system and will be programmed and updated using another board via a slow control link. Hence, why I need the firmware to be as small as possible.
The whole idea here is that I was hoping there is a way to draw a rounded rectangle just like I can draw a filled box in Touchgfx.
I hope that makes sense.
Samer
2020-04-30 11:52 AM
Sure. There isn't, unfortunately. It violates the TouchGFX philosophy that we want do things and efficient as fast as possible, and try not to offer up too many inefficient alternatives, like using the CPU to render (we would have to use the CPU in this case).
You could do a crazy workaround where you draw yourself into some memory and use that as input to a dynamic bitmap which you could then use for a button. It's pretty convoluted, but if that's your only option.
2020-04-30 11:54 AM
No problem. Thanks for the input. Appreciate it.
2020-04-30 12:14 PM
No problem. Let me know if you want to explore some of this further.