Summer Garden Custom Variation

Home » Custom Variations » Summer Garden Custom Variation
By Whittaker Courtney
The same custom variation that made

Summer Garden Custom Variation

By Whittaker Courtney

The same custom variation that made "summer garden" used here.
It's similar in behavior to the julia_outside function but acts differently and can do some cool stuff.

default formula = sin(acos(z+2)/2) + cos(acos(z-2)/2)

mode 0 default, mode 1 = swap sin and cos, mode 2 = square entire formula.

/*
  JWildfire - an image and animation processor written in Java 
  Copyright (C) 1995-2011 Andreas Maschke
  This is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser 
  General Public License as published by the Free Software Foundation; either version 2.1 of the 
  License, or (at your option) any later version.
 
  This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without 
  even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 
  Lesser General Public License for more details.
  You should have received a copy of the GNU Lesser General Public License along with this software; 
  if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jwildfire.create.tina.variation;

import org.jwildfire.create.tina.base.XForm;
import org.jwildfire.create.tina.base.XYZPoint;
import org.jwildfire.base.Tools;
import static org.jwildfire.base.mathlib.Complex;
import static org.jwildfire.base.mathlib.MathLib.*;


public class WcTemplateFunc extends VariationFunc {
  private static final long serialVersionUID = 1L;
  
  private static final String PARAM_DIVIDE = "divide";
  private static final String PARAM_EXPAND = "expand"; 
  private static final String PARAM_MODE = "mode";    
  private static final String[] paramNames = { PARAM_DIVIDE, PARAM_EXPAND, PARAM_MODE};
  private double divide = 2.0;
  private double expand = 2.0;
  private int mode = 0;
  
  @Override
  public void transform(FlameTransformationContext pContext, XForm pXForm, XYZPoint pAffineTP, XYZPoint pVarTP, double pAmount) {
  //7-21-2020_test by Whittaker Courtney 
  // mode 0 default, mode 1 = swap sin and cos, mode 2 = square last z value.
  // default formula = sin(acos(z+2)/2) + cos(acos(z-2)/2)

       Complex z = new Complex(pAffineTP.x, pAffineTP.y);
       Complex zc = new Complex(pAffineTP.x, pAffineTP.y);       

       Complex z5 = new Complex(divide, 0);
       Complex z6 = new Complex(expand, 0);                
   
z.Add(z6);
zc.Sub(z6); 

z.Acos();
z.Div(z5);
//swap sin and cos depending on mode.
if (mode == 0 || mode == 2){
z.Sin();
}
else if (mode == 1){
z.Cos();
    }
    
zc.Acos();
zc.Div(z5);
//swap sin and cos depending on mode.
if(mode == 0 || mode == 2){
zc.Cos();
}
else if (mode == 1){
zc.Sin();    
    }

z.Add(zc);
      
//mirror horizontally or horizontally and vertically depending on mode
if (mode == 2){
z.Sqr();
   if (pContext.random() < 0.5){                              
       pVarTP.x += pAmount * z.re;  
       pVarTP.y += pAmount * z.im;    
    }
    else {     
       pVarTP.x += pAmount * -z.re; 
       pVarTP.y += pAmount * -z.im;
    }
}

else{                                                                
   if (pContext.random() < 0.25){                              
       pVarTP.x += pAmount * z.re;  
       pVarTP.y += pAmount * z.im;    
    }
    else if(pContext.random() > 0.25 && pContext.random() < 0.5){     
       pVarTP.x += pAmount * -z.re; 
       pVarTP.y += pAmount * -z.im;
    } 
    else if(pContext.random() > 0.5 && pContext.random() < 0.75){     
       pVarTP.x += pAmount * z.re; 
       pVarTP.y += pAmount * -z.im;
    } 
    else{     
       pVarTP.x += pAmount * -z.re; 
       pVarTP.y += pAmount * z.im;
    }                                       
}

    if (pContext.isPreserveZCoordinate()) {
        pVarTP.z += pAmount * pAffineTP.z;
    }

  }
  
  @Override
  public String[] getParameterNames() {
    return paramNames;
  }

  @Override
  public Object[] getParameterValues() {
    return new Object[] {divide, expand, mode};
  }

  @Override
  public void setParameter(String pName, double pValue) {
    if (PARAM_DIVIDE.equalsIgnoreCase(pName))
      divide = pValue;
    else if (PARAM_EXPAND.equalsIgnoreCase(pName))
      expand = pValue;            
    else if (PARAM_MODE.equalsIgnoreCase(pName))
      mode = (int) Tools.limitValue(pValue, 0, 2);   
    else
      throw new IllegalArgumentException(pName);
  }

  @Override
  public String getName() {
    return "7-21-2020_test";
  }

}

 

Download Summary

  • Icon java
  • Version
  • Total Downloads 27
  • File Size 4.24 KB
  • File Count 1
  • Create Date July 22, 2020
  • Categories
  • Tags
  • Attached Files

  • FileAction
    summergarden.javaDownload 
You'll need to either add a custom_wf or load the java file please see how to use custom variations.


Leave a Comment