Effacer les filtres
Effacer les filtres

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

14 vues (au cours des 30 derniers jours)
Mohamed Abd El Raheem
Mohamed Abd El Raheem le 29 Mar 2021
Commenté : darova le 30 Mar 2021
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:

Réponses (1)

darova
darova le 30 Mar 2021
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 commentaire
darova
darova le 30 Mar 2021
How can i control an image size (used with RUN button)

Connectez-vous pour commenter.

Catégories

En savoir plus sur Elementary Polygons dans Help Center et File Exchange

Tags

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by