필터 지우기
필터 지우기

Patch FaceVertexCData being overwritten by FaceColor

조회 수: 14 (최근 30일)
Nathaniel Wood
Nathaniel Wood 2017년 9월 14일
답변: Duncan Lilley 2017년 9월 19일
Hello,
I am attempting to set up a patch with R2016b wherein one face of the patch has a certain color, and the rest share another. To do this I set up an (m x 3) array, "FacetColor," that assigned an RGB triplet to every face in the patch, according to its position in the geometry. The patch was then created with the code:
fv=struct('faces',facet,'vertices',vertex);
h=patch(fv,'FaceVertexCData', FacetColor, ...
'EdgeColor', 'none', ...
'FaceLighting', 'gouraud', ...
'AmbientStrength', 0.4);
alpha(h,1);
Unfortunately, whenever I attempt to run this code, MATLAB apparently ignores my FacetColor array and instead uses the default FaceColor value of [0 0 0]. This turns the entire patch uniformly black. I tried setting the FaceColor value to 'none,' thinking that doing so might force MATLAB to use the FaceVertexCData field, but instead it causes the patch to turn invisible. How am I configuring this patch incorrectly?
Any advice or assistance would be appreciated! My thanks in advance.

채택된 답변

Duncan Lilley
Duncan Lilley 2017년 9월 19일
In order for the patch to use the color data you have specified, you must set the "FaceColor" property to be either "flat" or "interp". As you have specified a color for each face, you will likely want to set "FaceColor" to "flat", which indicates that each face will be a uniform color, with "FaceVertexCData" specifying one color per face.
More information about this property and its possible settings can be found on the "patch" documentation page under "Name-Value Pair Arguments", here.

추가 답변 (0개)

카테고리

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