jwildfire.org

The official JWildfire forum
It is currently Mon May 25, 2020 5:13 am

All times are UTC+01:00




Post new topic  Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Tue Jan 14, 2020 8:16 pm 
Offline
User avatar

Joined: Fri Sep 02, 2016 1:57 pm
Posts: 183
Hi,

Want to experiment scripting the colour curves, what import.org line do I need and what would some of the commands be to set them?

Any help, greatly received.

_________________
**Visit The JWildfire Sanctuary**


Top
   
PostPosted: Tue Jan 14, 2020 9:31 pm 
Offline
Site Admin
User avatar

Joined: Wed May 15, 2013 10:28 pm
Posts: 1434
Here is an ready-to-use example, see the comments for explanation:
Code:
import org.jwildfire.create.tina.script.ScriptRunnerEnvironment;
import org.jwildfire.create.tina.randomgradient.StrongHueRandomGradientGenerator;
import org.jwildfire.create.tina.base.motion.MotionCurve;

public void run(ScriptRunnerEnvironment pEnv) throws Exception {
  if(pEnv.getCurrLayer()!=null) {
    MotionCurve hue = pEnv.getCurrLayer().getGradientEditorHueCurve();
    MotionCurve saturation = pEnv.getCurrLayer().getGradientEditorSaturationCurve();
    MotionCurve luminosity = pEnv.getCurrLayer().getGradientEditorLuminosityCurve();

    // 1. set random hue (at existing points)
    for(int i=0;i<hue.getY().length;i++) {
      hue.getY()[i]=Math.random()*255.0;  
    }

    // 2. set max saturation (at existing points)
    for(int i=0;i<saturation.getY().length;i++) {
      saturation.getY()[i]=255.0;  
    }
    // 3. create new luminosity-curve (only 3 points)
    // important: x-positions are integer values, while
    // y-positions are double values, due to historical reasons
    int newLumPointCount = 3;
    int newLumX[] = new int[newLumPointCount];
    double newLumY[] = new double[newLumPointCount];
    // set positions
    // important: x must be ordered from lower to high numbers
    newLumX[0]=5; 
    newLumY[0]=128.0; 
    newLumX[1]=100; 
    newLumY[1]=-11.0; 
    newLumX[2]=255; 
    newLumY[2]=255.0; 
    // apply to curve
    luminosity.setPoints(newLumX, newLumY);
    // refresh gradient, i.e. apply changes of curve
    pEnv.getCurrLayer().refreshGradientFromCurves();
    
    pEnv.refreshUI();
  }
}



Top
   
PostPosted: Tue Jan 14, 2020 9:37 pm 
Offline
User avatar

Joined: Fri Sep 02, 2016 1:57 pm
Posts: 183
Absolutely perfect, thank you ! :D

_________________
**Visit The JWildfire Sanctuary**


Top
   
PostPosted: Wed Jan 22, 2020 12:18 pm 
Offline
User avatar

Joined: Fri Sep 02, 2016 1:57 pm
Posts: 183
Loved the example, am trying now to find out how the make ramps buttons can be scripted, so I can get a nice saturation and luminosity ramp.

Thanks again Andreas for all your help.

_________________
**Visit The JWildfire Sanctuary**


Top
   
PostPosted: Sun Jan 26, 2020 1:21 am 
Offline
Site Admin
User avatar

Joined: Wed May 15, 2013 10:28 pm
Posts: 1434
To make a ramp you must only place two points (depnding on the direction of the ramp)

Ramp up: (0,0.0) and (255, 255.0)

Cheers!


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 5 posts ] 

All times are UTC+01:00


Who is online

Users browsing this forum: No registered users and 2 guests


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® Forum Software © phpBB Limited
Theme Created by HOLLYSMOKE
Theme updated to phpBB 3.1.6 by KamijouTouma
Theme Version is 3.1.6-ss2