Create your own Season's Greetings with Scilab

 

With this Scilab script, create your own Season's Greeting, to share it with your friends:

ScilabSeasonsGreeting.sce 1.91 kB

function Star(B, b, n, name)
    colour = modulo(name, 128);
    for p = n:-1:1
        for q = 1:min(p,2):2^(p-1)*b
           Z = B*exp(%i*q*%pi/2^(p-2)/b);
            xfpolys(real(Z), imag(Z), [colour colour+8]);
        end
    end
endfunction
txt = ["First Name"; "Date of Birth"];
sig = x_mdialog("Enter your info", txt, ["John"; "2017"]);
if ~isempty(sig) then
   
    year = evstr(sig(2));
    n = modulo(year,3)+3;
    b = modulo(year,6)+5;
    name = sum(ascii(sig(1)));
   
    R = 1;
    r = R/(2*cos(%pi/b));
    B = [0 0; R*%i r*exp(%i*(%pi/2 + %pi/b)); r*exp(%i*(%pi/2 - %pi/b)) R*%i];
    
    f = figure("visible","off", ..
    "figure_name", "",..
    "color_map", jetcolormap(128),..
    "menubar_visible", "off",..
    "toolbar_visible", "off",..
    "infobar_visible", "off");
    f.background = color("white");
   
    imageWidth = 138;
    imageHeight = 69;
   
    try
        // getURL requires an internet connection
        URL = getURL("https://www.scilab.org/sites/default/files/news/17/scilab-logo.png");
        uicontrol("Parent", f, ..
        "Style", "image", ..
        "Position", [(f.axes_size(1)-imageWidth-20) imageHeight imageWidth imageHeight], ..
        "Backgroundcolor",[1 1 1], ..
        "String", URL);
    catch
    end
   
    f.visible = "on";
    plot2d(%inf, %inf, frameflag = 3, rect = [-R,-R,R,R], axesflag = 0);
    Star(B, b, n, name);
    a = gca();
    t = a.title;
    t.font_size = 4;
    t.font_style = 5;
    t.text = sig(1)+"''s Season''s Greetings (proudly made with Scilab)";
   
    uicontrol("Parent", f, ..
    "Style", "pushbutton", ..
    "Position", [30 imageHeight 100 40], ..
    "String", "Save to PNG",..
    "Callback","savePNG()");
   
    function savePNG()
        File = uiputfile("*.png");
        if isempty(File) then
            return;
        end
        xs2png(f, File+".png");
    endfunction
   
end