Can I have round corners with PATCH?
Mostrar comentarios más antiguos
I use the following to create a rectangular box using PATCH,
patch([7 7 5 5], [5 7 7 5], 'r')
axis([0 10 0 10])
I want round corners. I have tried the property LineJoin but it does not do anything.
h.LineJoin = 'round';
So is this possible?
Respuesta aceptada
Más respuestas (1)
Les Beckham
el 22 de Mzo. de 2022
Editada: Les Beckham
el 22 de Mzo. de 2022
Try this. Adjust the 'curvature' value to adjust the ratio of the round corners to the size of the rectangle (1.0 will result in a circle).
rectangle('position', [5 5 2 2], 'curvature', 0.2, 'facecolor', 'r')
axis equal
axis([0 10 0 10])
4 comentarios
Kevin
el 22 de Mzo. de 2022
Les Beckham
el 22 de Mzo. de 2022
Editada: Les Beckham
el 22 de Mzo. de 2022
Actually, you can. Use a four element color specification. The fourth element is the alpha.
r = rectangle('position', [5 5 2 2], 'curvature', 0.2, 'facecolor', [1 0 0 0.2]);
axis equal
axis([0 10 0 10])
Kevin
el 22 de Mzo. de 2022
Les Beckham
el 22 de Mzo. de 2022
You are welcome.
I did too! I wasn't aware of polyshape or polybuffer. Apparently those were added during the several years that I didn't have a copy of Matlab.
Categorías
Más información sobre Polygons en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


