Christmas Greetings 2019

Inspired by Patsy and https://www.amazon.com/gp/product/B075JDVR53.

  type xmas_2019.m
function xmas_2019
    % Christmas greetings.
    
    set(gcf,'pos',[800 200 420 315])
    clf
    axis([0 1 0 1])
    axis off
    
    for k = 1:3
        [x,y] = base(k);
        patch(x,y,gray)
        [x,y] = edge(k);
        flame(k) = patch(x,y,'w');
    end

    gif_frame('html/xmas_2019.gif')
    for k = 1:50
        r = randi(2,1,3)-1;
        j = randi(3,1,1);
        if norm(r) > 0
            flame(j).FaceColor = r;
            gif_frame
        end
    end
    gif_frame('reset')
    close
    
    function [x,y] = base(k)
        xo = [.33 .45 .57];
        ys = [.38 .30 .44];
        x = xo(k) + .10*[0 1 1 0 0];
        y = ys(k)*[0 0 1 1 0];
    end

    function [x,y] = edge(k)
        xo = [.33 .45 .57];
        yo = [.38 .30 .44]; 
        e = [2 0 0 2 3];
        x = xo(k) + .01*[e 5 10-fliplr(e)];
        y = yo(k) + .08*[0:4 5 4:-1:0];
    end

    function g = gray
        g = [.5 .5 .5];
    end
end




Published with MATLAB® R2018b

|
  • print

댓글

댓글을 남기려면 링크 를 클릭하여 MathWorks 계정에 로그인하거나 계정을 새로 만드십시오.