フィルターのクリア

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)
  1 件のコメント
darova
darova 2021 年 3 月 30 日
How can i control an image size (used with RUN button)

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeElementary Polygons についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by