1.7k views
in Embedded Wizard Studio by
How to draw a round edged rectangle using Vector graphics?

1 Answer

0 votes
by

Hi GLM,
you can use a Views::FillPath to render your Graphics::Path with rounded corners.

Preparing the Path may look like this:
 

// Update the shape
var point size = Bounds.size;
var int32 edges = 40;
var int32 radius = 10;
var int32 padding = 4;

if ( size.x < padding || size.y < padding )
  padding = 0;

if ( radius > (size.y - padding) / 2 )
  radius = (size.y - padding) / 2;

if ( radius > (size.x - padding) / 2 )
  radius = (size.x - padding) / 2;

Path.InitSubPath( 0, edges );
Path.Begin( 0, padding, padding + radius );

Path.AddArc( 0, padding + radius, padding + radius, radius, radius, 180.0, 270.0, edges / 5 );
Path.AddLine( 0, size.x - radius - padding, padding );
Path.AddArc( 0, size.x - padding - radius, padding + radius, radius, radius, 270.0, 360.0, edges / 5 );
Path.AddLine( 0, size.x - padding, size.y - radius - padding );
Path.AddArc( 0, size.x - padding - radius, size.y - padding - radius, radius, radius, 0.0, 90.0, edges / 5 );
Path.AddLine( 0, padding + radius, size.y - padding );
Path.AddArc( 0, padding + radius, size.y - padding - radius, radius, radius, 90.0, 180.0, edges / 5 );
Path.Close( 0 );

InvalidateViewState();

Regards,
Rudolf

by

Hi Manfred,

I just created a project which consists of a pushbutton with rounded rectangle border and a path created using stroke path. Please check it and share a solution for this problem.

Regards,

Sazna.

by

Hi Sazna,

I just had a quick view into the project - you configured the path with 10000 edges. Why do you need so many edges for that stroke path?

I assume you got some error message during runtime on your target - please have a look to the console window.

Best regards,

Manfred.

by
Hi Manfred,

I just checked the smoothness of the path by increasing the no of edges. Now I tried with 100 edges and flashed it  to the board. It displays as it is. Thank you so much for your time in fixing this issue.

Regards,

Sazna.
by

Hi Team,

I have created a rounded rectangle by using stroke path and fill path and connected same path object. 

When simulating both paths are visible. But when flashing to the board I couldn't able to see the stroke path as border. only filled rectangle is there. What causes this issue? 

Regards,

Sazna.

by

Hi Sazna,
I guess you run out of memory for the rendering tasks. Please have a look to the console window.
So please reduce the edges or increase the 'EW_MAX_ISSUE_TASKS' within ewconfig.h.

Regards,
Rudolf

Ask Embedded Wizard - Archive

Welcome to the Ask Embedded Wizard archive. This community forum served us well for many years, but we've evolved our support approach!

Your resources:

The Embedded Wizard Online Documentation provides comprehensive documentation, tutorials, examples and ready-to-use software packages.

For dedicated assistance, explore our Embedded Wizard Product Support.

You can still browse the valuable discussions from our community history here.

Embedded Wizard Website | Privacy Policy | Imprint

...