Draw rotated rectangle with rounded edge

조회 수: 4 (최근 30일)
J AI
J AI 2021년 1월 9일
편집: Adam Danz 2021년 1월 11일
I found the answer to drawing rotated rectangles using the solution provided here by Y Yoon. However, I am not sure how to integrate curvature to the rectangle at the edges like it can be done in the function rectangle. Any other solution will also be highly appreciated. Thanks in advance.
  댓글 수: 4
Adam Danz
Adam Danz 2021년 1월 9일
I see.... I'll add an answer in a bit.
J AI
J AI 2021년 1월 9일
Thank you. Your help is highly appreciated.

댓글을 달려면 로그인하십시오.

채택된 답변

Adam Danz
Adam Danz 2021년 1월 9일
편집: Adam Danz 2021년 1월 11일
I created a function to extend the capabilities of Matlab's rectangle() but with these additional features:
  • Position rectangles by their center points rather than by their lower left coordinate.
  • Supports creation of multiple rectangles with independent properties
  • Outputs handles to patch object rather than rectangle
  • Outputs rectangles parameters including vertices
  • Option to rotate rectangles about their centers
See the example file in rectangle2() on the file exchange.
  댓글 수: 5
Adam Danz
Adam Danz 2021년 1월 10일
편집: Adam Danz 2021년 1월 11일
@J AI the function has been updated to vs 1.1.0 and is a bit faster than the first version.
It now includes an example file and show how to apply different color to the rectangles. Note that you can also specify FaceColor to set the color of all rectangles.
The drawnow is required to update the properties that I'm pulling the curvature data from and as you said, it slows things down a bit. It's unavoidable with this method although I'll think about changing methods some time in the future.
Adam Danz
Adam Danz 2021년 1월 11일
Please download vs 2.0.0 which I just updated.
It fixes some minor potential errors but it also adds a lot of flexibility to set multiple rectangle properties (see example file).
I don't plan for any further updates unless errors are reported. At some point I may get around to figuring out how Matalb creates the curved edges rather than using the rectangle function to create them.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Graphics Performance에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by