Drawing a rectangle with special specifications

조회 수: 1 (최근 30일)
Stephen
Stephen 2014년 5월 16일
댓글: Henric Rydén 2014년 5월 19일
how can i draw a 172*172 that first edge is black (intensity=0) and second edge 10% brighter and the third edge 10% brighter than second and the last edge 10% brighter than third edge...
thank you for your answers

답변 (1개)

Henric Rydén
Henric Rydén 2014년 5월 16일
편집: Henric Rydén 2014년 5월 16일
figure;
axes('XLim', [-50 200],'YLim', [-50 200]);
line([0 172],[172 172],'LineWidth',5,'Color',[0 0 0])
line([172 172],[172 0],'LineWidth',5,'Color',[.1 .1 .1])
line([172 0],[0 0],'LineWidth',5,'Color',[.2 .2 .2])
line([0 0],[0 172],'LineWidth',5,'Color',[.3 .3 .3])
  댓글 수: 3
Star Strider
Star Strider 2014년 5월 16일
To compensate for line thickness, change it to:
figure;
axes('XLim', [-50 200],'YLim', [-50 200]);
line([-2 174],[172 172],'LineWidth',5,'Color',[0 0 0])
line([172 172],[174 -2],'LineWidth',5,'Color',[.1 .1 .1])
line([174 -2],[0 0],'LineWidth',5,'Color',[.2 .2 .2])
line([0 0],[-2 174],'LineWidth',5,'Color',[.3 .3 .3])
Henric Rydén
Henric Rydén 2014년 5월 19일
If you need nicer corners you should use patch instead of line. The syntax is similar, but you give coordinates of faces and vertices. You can also set transparency of patch objects.

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

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by