Feedback

Please leave feedback and comments. I am always interested to hear how people get on using these LScripts!

Friday, 10 June 2011

LScript - Image_Duo


LScript (Layout) to apply a two tone colour effect from two selected colours.

Compatible with Newtek LightWave 9.6 and above.

// LScript Image Filter - www.StephenCulley.co.uk
//
// web   address: http://www.stephenculley.co.uk
// email address: email@stephenculley.co.uk

/* 
    LScript Image Filter - Duo

    Image_Duo.ls

*/

@version 2.5
@warnings
@script image
@name *Duo

    // Title
    sTitle = "*Duo";

    // Version
    sVersion = "v1.0";

    vColorA = <0,0,0>;
    vColorB = <255,255,255>;

create
{
    setdesc(sTitle);
}

process: ifo
{
    iProgress = ifo.height;
    if(runningUnder() != SCREAMERNET) moninit(iProgress);
    vColorA01 = vColorA * (1 / 255); 
    vColorB01 = vColorB * (1 / 255); 
    for(i = 1;i <= ifo.height;++i)
      {
      for(j = 1;j <= ifo.width;++j)
        {
 nAmount = clip(0,1,(ifo.red[j,i] + ifo.green[j,i] + ifo.blue[j,i]) * (1 / 3));
        ifo.red[j,i] = (vColorA01.x * (1 - nAmount)) + (vColorB01.x * nAmount);
        ifo.green[j,i] = (vColorA01.y * (1 - nAmount)) + (vColorB01.y * nAmount);
        ifo.blue[j,i] = (vColorA01.z * (1 - nAmount)) + (vColorB01.z * nAmount);
        }
      if(runningUnder() != SCREAMERNET) if(monstep()) return;
      }
}

// CLIP

clip: min,max,n
{
    if(n < min) n = min;
    if(n > max) n = max;
    return(n);
}

load: what,io
{
    if(what == SCENEMODE)
    {
        vColorA = io.read().asVec();
        vColorB = io.read().asVec();
    }
}

save: what,io
{
    if(what == SCENEMODE)
    {
        io.writeln(vColorA);
        io.writeln(vColorB);
    }
}

options
{
    reqbegin(sTitle + " " + sVersion);

    // Control
    ctrl_c0 = ctlcolor("Color A",vColorA);
    ctrl_c1 = ctlcolor("Color B",vColorB);

    // Developer
    ctlsep();
    ctrl_dev0 = ctltext("","developer: Stephen Culley","http://www.stephenculley.co.uk");

    return if !reqpost();

    vColorA = getvalue(ctrl_c0);
    vColorB = getvalue(ctrl_c1);

    reqend();
}


All scripts available at my Google Drive at
https://drive.google.com/open?id=1cR_q2GVUAJHumic1-A3eXV16acQnVTWs

No comments:

Post a Comment