User Tools

Site Tools


Privacy Policy


Version 2.50 is out since Jan 1st 2022

Frequently Asked Questions


Note for contributors

If you wish to create a new page in the DroidScript wiki, please click on the most appropriate namespace above and follow the notes for contributors there.

Because of spam, it has been necessary to add a CAPTCHA to the registration form and the save option for editing pages. You will not need to prove you are human if you are logged in, so please register.

Please feel free to improve any existing page, as well as adding new pages to increase the sum of public knowledge about DroidScript.

Formatting Syntax


Draw a Smiley

This demo was written by Sankarshan Dudhate.

//Called when application is started.
function OnStart()
    //Create a layout with objects vertically centered.
    lay = app.CreateLayout( "linear", "VCenter,FillXY" );    
    //Get size for a square imsge
    var siz=square(1);
    //Create an empty image to act as our drawing canvas of full width and height.
    img = app.CreateImage(null,siz.w,siz.h);
    lay.AddChild(img); //Add it to layout.
    img.SetColor("#ffffffff"); //Set colour of our canvas to white.
    img.SetPaintColor("#ff000000"); //Set colour objects darwn on canvas to 'Black'.
    img.SetPaintStyle("Line"); //Set style of objects drawn on canvas to 'Line.'
    img.SetLineWidth(3); //Set LineWidth of obiects drawn to 3 pixels. 
    img.DrawCircle(0.5,0.2,0.18); //Draw a circle with center at (0.5,0.2) and radius 0.18 of device's width. 
    img.SetPaintStyle("Fill"); //Set style of objects drawn to 'Fill'.
    img.SetPaintColor("#ff444444"); //Set colour of objects drawn to 'Gray'.
    img.DrawCircle(0.42,0.16,0.04); //Draw circle with center at (0.42,0.16) and radius 0.04
    img.DrawCircle(0.57,0.16,0.04); //Center at (0.57,0.16) and radius 0.04.
    img.SetPaintColor("#ff0000"); //Set colour of objects drawn to 'Red'.
    //Draw an arc.
    //Pattern : (x1,y1,x2,y2,StartAngle,EndAngle).
    //Add layout to app. App will be empty if no layout is added.
    app.AddLayout( lay );
function square(size)
    var ratio = app.GetDisplayWidth() /
    var ret={};
    if (ratio >= 1) // landscape
        ret.w = size / ratio;
        ret.h = size;
        ret.w = size;
        ret.h = size * ratio;
    return ret;
sample_code/draw_smiley.txt · Last modified: 2015/09/16 15:18 (external edit)