Feedback

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

Tuesday, 26 March 2013

LScript - Image_Alpha

LScript (Layout) to create compressed video artifact effect.

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 - Alpha

    Image_Alpha.ls

*/

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

    // Title
    sTitle = "*Alpha";

    // Version
    sVersion = "v1.0";

    aType = @"Solid","Luma","Luma (Invert)"@;
    iType = 1;

create
{
    setdesc(sTitle + " - " + aType[iType]);
}

process: ifo
{

    if(iType == 1) // Solid
      {

      iProgress = ifo.height;
      if(runningUnder() != SCREAMERNET) moninit(iProgress);
      for(i = 1;i <= ifo.height;++i)
        {
        for(j = 1;j <= ifo.width;++j)
          {
          ifo.alpha[j,i] = 1.0;
          }
        if(runningUnder() != SCREAMERNET) if(monstep()) return;
        }

      }

    if(iType == 2) // Luma
      {

      iProgress = ifo.height;
      if(runningUnder() != SCREAMERNET) moninit(iProgress);
      for(i = 1;i <= ifo.height;++i)
        {
        for(j = 1;j <= ifo.width;++j)
          {
          ifo.alpha[j,i] = clip(0.0,1.0,(ifo.red[j,i] + ifo.green[j,i] + ifo.blue[j,i]) * (1 / 3));
          }
        if(runningUnder() != SCREAMERNET) if(monstep()) return;
        }

      }

    if(iType == 3) // Luma (Invert)
      {

      iProgress = ifo.height;
      if(runningUnder() != SCREAMERNET) moninit(iProgress);
      for(i = 1;i <= ifo.height;++i)
        {
        for(j = 1;j <= ifo.width;++j)
          {
          ifo.alpha[j,i] = clip(0.0,1.0,1.0 - ((ifo.red[j,i] + ifo.green[j,i] + ifo.blue[j,i]) * (1 / 3)));
          }
        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)
    {
        iType = io.read().asInt();

        setdesc(sTitle + " - " + aType[iType]);
    }
}

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

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


    // Control
    ctrl_c0 = ctlchoice("Type",iType,@"Solid","Luma","Luma Invert"@); // Type

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

    return if !reqpost();

    iType = getvalue(ctrl_c0);

    setdesc(sTitle + " - " + aType[iType]);

    reqend();
}


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

No comments:

Post a Comment