How can I make a shape's color fade more and more over time?

29 ビュー (過去 30 日間)
Gimil
Gimil 2014 年 4 月 22 日
回答済み: Hamid Radmard Rahmani 2018 年 12 月 24 日
The code below sets each shape to have the same transparency.
hold on; grid on;
axis equal;
scale = .9;
movex = 0;
movey = 0;
squarex = [0 1 1 0];
squarey = [0 0 1 1];
for i = 1:11
squarex = (squarex * scale + movex);
squarey = (squarey * scale + movey);
movex = movex +1;
movey = movey +1;
h = fill(squarex,squarey,'r');
set(h,'facealpha',.7);
pause (.3)
end

採用された回答

Image Analyst
Image Analyst 2014 年 4 月 22 日
Just make a transparency array
transparency = linspace(0, 1, 11); % Make 11 transparencies from 0 to 1 inclusive.
Then
set(h,'facealpha', transparency(i));

その他の回答 (1 件)

Hamid Radmard Rahmani
Hamid Radmard Rahmani 2018 年 12 月 24 日

カテゴリ

Help Center および File ExchangeDiscrete Data Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by