Can I have round corners with PATCH?

25 次查看(过去 30 天)
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?

采纳的回答

Matt J
Matt J 2022-3-22
编辑:Matt J 2022-3-22
You can with polyshape,
h=polybuffer( polyshape([7 7 5 5], [5 7 7 5]),0.5);
plot(h,'FaceColor','r', 'FaceAlpha',0.5)

更多回答(1 个)

Les Beckham
Les Beckham 2022-3-22
编辑:Les Beckham 2022-3-22
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 个评论
Kevin
Kevin 2022-3-22
I see. But the forth element is not mentioned in the DOC.
I am hoping that this is not an undocumented feature and it may get removed in the future.
But thanks for mentioning this. I have learnt something new today. Great.
Les Beckham
Les Beckham 2022-3-22
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Polygons 的更多信息

产品


版本

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by