- Version
- Download 177
- File Size 4.88 KB
- File Count 1
- Create Date September 22, 2020
- Last Updated September 27, 2021
7-24-2020_btest_java
Whittaker still working on a better title, but try this one you'll love it. Great fun.
/* 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-24-2020_test_B by Whittaker Courtney (a little messy still WIP) // 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) // mode 3 = (sin(acos(sqrt(exp(z)))) / cos(acos(sqrt(exp(z))))) * 2 Complex z = new Complex(pAffineTP.x, pAffineTP.y); Complex zc = new Complex(pAffineTP.x, pAffineTP.y); Complex z3 = new Complex(pAffineTP.x, pAffineTP.y); Complex z5 = new Complex(divide, 0); Complex z6 = new Complex(expand, 0); if (mode == 3){ z.Exp(); z.Sqrt(); zc.Exp(); zc.Sqrt(); } if (mode <= 2){ z.Add(z6); zc.Sub(z6); } z.Acos(); if (mode <= 2){ z.Div(z5); } //swap sin and cos depending on mode. if (mode == 0 || mode == 2 || mode == 3){ z.Sin(); } else if (mode == 1){ z.Cos(); } zc.Acos(); if (mode <= 2){ zc.Div(z5); } //swap sin and cos depending on mode. if(mode == 0 || mode == 2 || mode == 3){ zc.Cos(); } else if (mode == 1){ zc.Sin(); } if (mode == 3){ z.Div(zc); z.Add(z); } else{ z.Add(zc); } //mirror horizontally or horizontally and vertically depending on mode double random = pContext.random(); if (mode == 2 ){ z.Sqr(); if (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 (mode == 3 ){ z.Scale(M_2_PI); if (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 (random < 0.25){ pVarTP.x += pAmount * z.re; pVarTP.y += pAmount * z.im; } else if(random > 0.25 && random < 0.5){ pVarTP.x += pAmount * -z.re; pVarTP.y += pAmount * -z.im; } else if(random > 0.5 && 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, 3); else throw new IllegalArgumentException(pName); } @Override public String getName() { return 7-24-2020_test_b; } }
Attached Files
File | Action |
---|---|
7-24-2020_btest_java.java | Download |