Change font size
It is currently Mon May 20, 2019 8:01 pm

Forum rules


{L_IMAGE}



Post a new topicPost a reply Page 1 of 1   [ 1 post ]
Author Message
 Post subject: Sierpinski Triangle v0.1
PostPosted: Thu Apr 25, 2019 9:52 pm 
Furious Typer
User avatar

Joined: Fri Mar 26, 2010 12:11 pm
Posts: 173
Location: Belgium / Brussels
Sierpinski Triangle v0.1 by djphil (CC-BY-NC-SA 4.0)
{L_CODE}:
// Sierpinski Triangle v0.1 by djphil (CC-BY-NC-SA 4.0)

draw_sierpinski()
{
    string txt;
    integer y;

    for (y = 32 - 1; y >= 0; y--)
    {
        integer i;

        for (i = 0; i < y; i++)
        {
            txt += " ";
        }
       
        integer x;

        for (x = 0; x + y < 32; x++)
        {
            if (x & y) txt += "  ";
            else txt += "▲ ";
        }
        txt += "\n";
    }

    string cmd;
    cmd = osSetPenSize(cmd, 5);
    cmd = osSetPenColor(cmd, "Black");
    cmd = osSetFontName(cmd, "Courier New");
    cmd = osMovePen(cmd, 0, 0);
    cmd = osDrawFilledRectangle(cmd, 512, 512);
    cmd = osSetPenColor(cmd, "White");
    cmd = osMovePen(cmd, 10, 10);
    cmd = osDrawRectangle(cmd, 492, 492);
    cmd = osMovePen(cmd, 45, 60);
    cmd = osSetFontSize( cmd, 8);
    cmd = osDrawText( cmd, txt );

    string name = llGetScriptName();
    txt = "☢ " + llToUpper(name) + " ☢";
    vector extent = osGetDrawStringSize( "vector", txt, "Courier New", 14);
    integer xpos = 256 - ((integer) extent.x >> 1);
    integer ypos =  38 - ((integer) extent.y >> 1);
    cmd = osMovePen(cmd, xpos, ypos);
    cmd = osSetFontSize(cmd, 14);
    cmd = osDrawText(cmd, txt);

    txt = "☢ " + name + " by djphil (CC-BY-NC-SA 4.0) ☢";
    extent = osGetDrawStringSize( "vector", txt, "Courier New", 8);
    xpos = 256 - ((integer) extent.x >> 1);
    ypos = 474 - ((integer) extent.y >> 1);
    cmd = osMovePen(cmd, xpos, ypos);
    cmd = osSetFontSize(cmd, 8);
    cmd = osDrawText(cmd, txt);

    osSetDynamicTextureDataFace("", "vector", cmd, "width:512, height:512", 0, 1);
}

default
{
    on_rez(integer p) {llResetScript();}
    touch_start(integer n) {llResetScript();}
    state_entry() {draw_sierpinski();}
}


Attachments:
File comment: Sierpinski Triangle v0.1 by djphil (CC-BY-NC-SA 4.0)
Sierpinski Triangle v0.1.png
Sierpinski Triangle v0.1.png [ 194.81 KiB | Viewed 103 times ]

_________________
Webmaster @ digitalconcepts.free.fr & digigrids.free.fr
Top
 Profile  
 
Display posts from previous:  Sort by  
Post a new topicPost a reply Page 1 of 1   [ 1 post ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
610nm Style by Daniel St. Jules of Gamexe.net