필터 지우기
필터 지우기

Using fill to color multiple polygons using input RGB color values.

조회 수: 14 (최근 30일)
Mohamed Abd El Raheem
Mohamed Abd El Raheem 2021년 3월 29일
댓글: darova 2021년 3월 30일
Greetings:
I have a problem using "fill" to produce two polygons, each with a color defind by rgb values. The following code defines two matrices, xx and yy, with columns representing the vertices of the two polygons. A 3D matix c, contains the rgb values of the colors.
Using "fill" in the form : fill(x1,y1,c1,x2,y2,c2, ...) to color each polygon, works fine. But using it in the manner fill(xx,yy,c) doesn't produce the correct colors. So, how to fix that to use it in the latter way?
xx = [0 0 1 1 0; 1 1 2 2 1]';
yy = [0 1 1 0 0; 0 1 1 0 0]';
c(1,1,:) = [0.6 0.6 0.8];
c(2,1,:) = [0.3 0.3 0.4];
figure;fill(xx,yy,c);
figure;fill(xx(:,1),yy(:,1),c(1,1,:),xx(:,2),yy(:,2),c(2,1,:));
The output figures of the code are here:

답변 (1개)

darova
darova 2021년 3월 30일
Try this
[x,y] = meshgrid(0:2,0:1);
c1(1,1,:) = [0.6 0.6 0.8];
c2(1,1,:) = [0.3 0.3 0.4];
c = [c1 c2 c2;c1 c2 c2];
surf(x,y,x*0,c)
view(0,90)

카테고리

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

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by