cancel
Showing results for 
Search instead for 
Did you mean: 

How to draw a rectangle with round corner

shark
Senior

How to draw a rectangle with round corner.

9 REPLIES 9
Alexandre RENOUX
Principal

Hello,

You can do that by using an image editor (paint.net, photoshop, gimp) -> create a rectangle with round corners -> save the image as png (so that alpha is included) -> import this image in your touchGFX project and use the Image widget to add it to your screen.

/Alexandre

shark
Senior

Sorry, I need it at run time by coding.

Alexandre RENOUX
Principal

Hello,

You can display the rectangle at run time whenever you want in the app. Just do rectangleImage.setVisible(true) when needed.

What do you want to do ?

/Alexandre

shark
Senior

Sorry, I need to draw rectangle with 4 round corner, with different size specified at run time.

Alexandre RENOUX
Principal

Hello,

This is high level graphics programming and we don't have an example for it right now.

We will consider creating one.

/Alexandre

shark
Senior

Yes, hope you can release an example soon.

I have a lot of needs of different size, that require a rectangle as a background image. And png file is too expensive in code space.

I checked existing widget and example, but failed.

Alexandre RENOUX
Principal

If it's a background image, why do you need round corners ? I'm still lost on what you are trying to do exactly as a project.

/Alexandre

Tuoman
Senior II

Should not be too difficult to program it yourself.

I'm glad that TouchGFX is not full of bloatware to keep it light.

If you do this feature, please add it to open repository:

https://github.com/touchgfx/touchgfx-open-repository/tree/master/widgets

Martin KJELDSEN
Chief III

You could simply use a box, and then have corners with alpha in some sizes to create the rounded corners. Depending on what you're doing you may experience performance issues since we cannot use ChromART to draw the kind of shape you're after.

/Martin