Package org.jwildfire.create.tina.variation

Examples of org.jwildfire.create.tina.variation.VariationFunc


            varName = aliasName;
            hasVariation = variationNameList.indexOf(varName) >= 0;
          }
        }
        if (hasVariation) {
          VariationFunc varFunc = VariationFuncList.getVariationFuncInstance(varName);
          Variation variation = pXForm.addVariation(Double.parseDouble(atts.get(rawName)), varFunc);
          // params
          {
            String paramNames[] = variation.getFunc().getParameterNames();
            String paramAltNames[] = variation.getFunc().getParameterAlternativeNames();
View Full Code Here


        _evalMotionCurves(gradient, pFrame);
      }
    }
    if (pObject instanceof Variation) {
      Variation var = (Variation) pObject;
      VariationFunc func = var.getFunc();
      for (String name : func.getParameterNames()) {
        MotionCurve curve = var.getMotionCurve(name);
        if (curve != null && curve.isEnabled()) {
          double value = evalCurve(pFrame, curve);
          try {
            func.setParameter(name, value);
          }
          catch (Exception ex) {
            ex.printStackTrace();
          }
        }
View Full Code Here

        _disableMotionCurves(gradient);
      }
    }
    if (pObject instanceof Variation) {
      Variation var = (Variation) pObject;
      VariationFunc func = var.getFunc();
      for (String name : func.getParameterNames()) {
        MotionCurve curve = var.getMotionCurve(name);
        if (curve != null && curve.isEnabled()) {
          curve.setEnabled(false);
        }
      }
View Full Code Here

    attrList.add(pXB.createAttr("symmetry", pXForm.getColorSymmetry()));

    UniqueNamesMaker namesMaker = new UniqueNamesMaker();
    for (int vIdx = 0; vIdx < pXForm.getVariationCount(); vIdx++) {
      Variation v = pXForm.getVariation(vIdx);
      VariationFunc func = v.getFunc();

      String fName = namesMaker.makeUnique(func.getName());

      attrList.add(pXB.createAttr(fName, v.getAmount()));
      // params
      {
        String params[] = func.getParameterNames();
        if (params != null) {
          Object vals[] = func.getParameterValues();
          for (int i = 0; i < params.length; i++) {
            if (vals[i] instanceof Integer) {
              attrList.add(pXB.createAttr((fName + "_" + params[i]), (Integer) vals[i]));
            }
            else if (vals[i] instanceof Double) {
              attrList.add(pXB.createAttr((fName + "_" + params[i]), (Double) vals[i]));
            }
            else {
              throw new IllegalStateException();
            }
            MotionCurve curve = v.getMotionCurve(params[i]);
            if (curve != null) {
              writeMotionCurve(pXB, attrList, fName + "_" + params[i], curve);
            }
          }
        }
      }
      // curves
      List<String> blackList = Collections.emptyList();
      writeMotionCurves(v, pXB, attrList, fName + "_", blackList);
      // ressources
      {
        String ressNames[] = func.getRessourceNames();
        if (ressNames != null) {
          byte vals[][] = func.getRessourceValues();
          for (int i = 0; i < ressNames.length; i++) {
            String hexStr = vals[i] != null && vals[i].length > 0 ? Tools.byteArrayToHexString(vals[i]) : "";
            attrList.add(pXB.createAttr((fName + "_" + ressNames[i]), hexStr));
          }
        }
View Full Code Here

      addVariations(variations, xForm);
    }
    filterVariations(variations);
    if (variations.size() > 0) {
      int idx = (int) (Math.random() * variations.size());
      VariationFunc var = variations.get(idx);
      int pIdx = (int) (Math.random() * var.getParameterNames().length);
      Object oldVal = var.getParameterValues()[pIdx];
      if (oldVal instanceof Integer) {
        int o = (Integer) oldVal;
        int da = Tools.FTOI(pAmount);
        if (da < 1) {
          da = 1;
        }
        if (o >= 0) {
          o += da;
        }
        else {
          o -= da;
        }
        var.setParameter(var.getParameterNames()[pIdx], o);
      }
      else if (oldVal instanceof Double) {
        double o = (Double) oldVal;
        if (o < EPSILON || Math.random() < 0.3) {
          if (o >= 0) {
            o += 0.1 * pAmount;
          }
          else {
            o -= 0.1 * pAmount;
          }
        }
        else {
          if (o >= 0) {
            o += o / 100.0 * pAmount;
          }
          else {
            o -= o / 100.0 * pAmount;
          }
        }
        var.setParameter(var.getParameterNames()[pIdx], o);
      }
    }
  }
View Full Code Here

  }

  private void addVariations(List<VariationFunc> pVariations, XForm pXForm) {
    if (pXForm.getVariationCount() > 0) {
      for (int i = 0; i < pXForm.getVariationCount(); i++) {
        VariationFunc var = pXForm.getVariation(i).getFunc();
        if (var.getParameterNames() != null && var.getParameterNames().length > 0) {
          pVariations.add(var);
        }
      }
    }
  }
View Full Code Here

    {
      XForm xForm = new XForm();
      layer.getXForms().add(xForm);
      xForm.setWeight(wavesWeight);
      double varRnd = Math.random();
      VariationFunc w2;
      if (Math.random() > 0.5) {
        w2 = createExpWaves2Variation(scaleX, scaleY, freqX, freqY, varRnd);
      }
      else {
        if (Math.random() < 0.25) {
View Full Code Here

    }
    return flame;
  }

  private VariationFunc createExpWaves2Variation(double scaleX, double scaleY, double freqX, double freqY, double varRnd) {
    VariationFunc w2;
    String varName;
    if (varRnd < 0.6) {
      varName = "waves2_wf";
    }
    else if (varRnd < 0.8) {
      varName = "waves3_wf";
    }
    else {
      varName = "waves4_wf";
    }
    w2 = VariationFuncList.getVariationFuncInstance(varName, true);
    if (Math.random() < 0.25) {
      w2.setParameter("use_cos_x", 1);
    }
    else {
      w2.setParameter("use_cos_x", 0);
    }
    if (Math.random() < 0.25) {
      w2.setParameter("use_cos_y", 1);
    }
    else {
      w2.setParameter("use_cos_y", 0);
    }
    if (Math.random() < 0.25) {
      w2.setParameter("dampx", -(0.01 + Math.random() * 0.39));
    }
    if (Math.random() < 0.25) {
      w2.setParameter("dampy", -(0.01 + Math.random() * 0.39));
    }
    w2.setParameter("freqx", freqX);
    w2.setParameter("scalex", scaleX);
    w2.setParameter("freqy", freqY);
    w2.setParameter("scaley", scaleY);
    return w2;
  }
View Full Code Here

      // variation 1
      xForm.addVariation(0.125 + Math.random() * 0.125, VariationFuncList.getVariationFuncInstance("linear", true));
      // variation 2
      {
        VariationFunc varFunc = VariationFuncList.getVariationFuncInstance("julian", true);
        varFunc.setParameter("power", 3);
        varFunc.setParameter("dist", 1);
        xForm.addVariation(0.6 + Math.random() * 0.4, varFunc);
      }
      // variation 3
      {
        VariationFunc varFunc = VariationFuncList.getVariationFuncInstance("juliascope", true);
        varFunc.setParameter("power", 6);
        varFunc.setParameter("dist", 1);
        xForm.addVariation(0.6 + Math.random() * 0.3, varFunc);
      }
      XFormTransformService.localTranslate(xForm, 1.0 - 2.0 * Math.random(), 1.0 - 2.0 * Math.random(), false);
      XFormTransformService.scale(xForm, 0.9 + Math.random() * 0.5, true, true, false);
      XFormTransformService.rotate(xForm, 360.0 * Math.random(), false);
    }
    // create transform 2
    {
      XForm xForm = new XForm();
      layer.getXForms().add(xForm);
      xForm.setWeight(0.23272111);
      xForm.setColor(0.8);
      xForm.setColorSymmetry(0);

      xForm.setCoeff00(-0.15514012); // a
      xForm.setCoeff10(0.20816567); // b
      xForm.setCoeff20(0.19004075); // e
      xForm.setCoeff01(-0.15087636); // c
      xForm.setCoeff11(0.20174952); // d
      xForm.setCoeff21(-0.04671182); // f

      xForm.setPostCoeff00(1);
      xForm.setPostCoeff10(0);
      xForm.setPostCoeff01(0);
      xForm.setPostCoeff11(1);
      xForm.setPostCoeff20(0);
      xForm.setPostCoeff21(0);

      // variation 1
      xForm.addVariation(1, VariationFuncList.getVariationFuncInstance("linear", true));
      // variation 2
      {
        VariationFunc varFunc = VariationFuncList.getVariationFuncInstance("juliascope", true);
        varFunc.setParameter("power", 2);
        varFunc.setParameter("dist", 1);
        xForm.addVariation(0.25 + Math.random() * 0.5, varFunc);
      }

      String fName;
      if (Math.random() < 0.33) {
        int idx = ExperimentalSimpleRandomFlameGenerator.FNCLST_EXPERIMENTAL.length;
        fName = ExperimentalSimpleRandomFlameGenerator.FNCLST_EXPERIMENTAL[(int) (Math.random() * idx)];
      }
      else {
        fName = VariationFuncList.getRandomVariationname();
      }
      xForm.addVariation(0.18 - Math.random() * 0.36, VariationFuncList.getVariationFuncInstance(fName, true));
      XFormTransformService.localTranslate(xForm, 1.0 - 2.0 * Math.random(), 1.0 - 2.0 * Math.random(), false);
      XFormTransformService.scale(xForm, 0.9 + Math.random() * 0.5, true, true, false);
      XFormTransformService.rotate(xForm, 360.0 * Math.random(), false);
    }
    // create transform 3
    {
      XForm xForm = new XForm();
      layer.getXForms().add(xForm);
      xForm.setWeight(0.04166667);
      xForm.setColor(0.1);
      xForm.setColorSymmetry(0.75);

      xForm.setCoeff00(0.92931929); // a
      xForm.setCoeff10(0.17076568); // b
      xForm.setCoeff20(0.15869232); // e
      xForm.setCoeff01(-0.02999303); // c
      xForm.setCoeff11(0.67104838); // d
      xForm.setCoeff21(-0.19510192); // f

      xForm.setPostCoeff00(1);
      xForm.setPostCoeff10(0);
      xForm.setPostCoeff01(0);
      xForm.setPostCoeff11(1);
      xForm.setPostCoeff20(0);
      xForm.setPostCoeff21(0);

      // variation 1
      xForm.addVariation(1, VariationFuncList.getVariationFuncInstance("linear", true));
    }
    // create transform 4
    {
      XForm xForm = new XForm();
      layer.getXForms().add(xForm);
      xForm.setWeight(0.04166667);
      xForm.setColor(0.15);
      xForm.setColorSymmetry(0.75);

      xForm.setCoeff00(0.53699507); // a
      xForm.setCoeff10(0.12206942); // b
      xForm.setCoeff20(-0.0380713); // e
      xForm.setCoeff01(0.23469299); // c
      xForm.setCoeff11(0.79862481); // d
      xForm.setCoeff21(0.04291273); // f

      xForm.setPostCoeff00(1);
      xForm.setPostCoeff10(0);
      xForm.setPostCoeff01(0);
      xForm.setPostCoeff11(1);
      xForm.setPostCoeff20(0);
      xForm.setPostCoeff21(0);
      xForm.addVariation(1, VariationFuncList.getVariationFuncInstance("linear", true));
    }
    // create transform 5
    {
      XForm xForm = new XForm();
      layer.getXForms().add(xForm);
      xForm.setWeight(0.04166667);
      xForm.setColor(0.2);
      xForm.setColorSymmetry(0);

      xForm.setCoeff00(0.89779523); // a
      xForm.setCoeff10(-0.23112747); // b
      xForm.setCoeff20(-0.4497571); // e
      xForm.setCoeff01(0.1734196); // c
      xForm.setCoeff11(0.94619577); // d
      xForm.setCoeff21(-0.0672393); // f

      xForm.setPostCoeff00(1);
      xForm.setPostCoeff10(0);
      xForm.setPostCoeff01(0);
      xForm.setPostCoeff11(1);
      xForm.setPostCoeff20(0);
      xForm.setPostCoeff21(0);

      xForm.addVariation(1, VariationFuncList.getVariationFuncInstance("linear", true));
    }
    // create transform 6
    {
      XForm xForm = new XForm();
      layer.getXForms().add(xForm);
      xForm.setWeight(0.04166667);
      xForm.setColor(0.25);
      xForm.setColorSymmetry(0);

      xForm.setCoeff00(0.70624241); // a
      xForm.setCoeff10(0.15652237); // b
      xForm.setCoeff20(0.43007701); // e
      xForm.setCoeff01(-0.04953437); // c
      xForm.setCoeff11(0.78838922); // d
      xForm.setCoeff21(0.21371425); // f

      xForm.setPostCoeff00(1);
      xForm.setPostCoeff10(0);
      xForm.setPostCoeff01(0);
      xForm.setPostCoeff11(1);
      xForm.setPostCoeff20(0);
      xForm.setPostCoeff21(0);

      xForm.addVariation(1, VariationFuncList.getVariationFuncInstance("linear", true));
    }
    // final transform
    if (Math.random() > 0.33) {
      XForm xForm = new XForm();
      layer.getFinalXForms().add(xForm);
      String finals[] = { "falloff2", "bwrands", "bwraps7", "cosine", "falloff3", "bwrands", "bwrands", "falloff2" };
      VariationFunc var = VariationFuncList.getVariationFuncInstance(finals[(int) (Math.random() * finals.length)], true);
      if (var.getName().equals("bwrands")) {
        var.setParameter("seed", (int) (Math.random() * Short.MAX_VALUE));
        var.setParameter("minpetals", (int) (3 + Math.random() * 3));
        var.setParameter("maxpetals", (int) (6 + Math.random() * 12));
      }
      if (var.getName().equals("bwrands") || var.getName().equals("bwraps7")) {
        var.setParameter("cellsize", 1.0 - Math.random() * 0.9);
        var.setParameter("space", Math.random() * 0.2);
        if (Math.random() > 0.5) {
          var.setParameter("inner_twist", 0.2 - Math.random() * 0.4);
          var.setParameter("outer_twist", 2.0 - Math.random() * 4.0);
        }
      }
      xForm.addVariation(1, var);
    }
    return flame;
View Full Code Here

      xForm.addVariation(1.43, VariationFuncList.getVariationFuncInstance("bubble", true));
      // variation 2
      xForm.addVariation(0.012, VariationFuncList.getVariationFuncInstance("linear", true));
      // variation 3
      {
        VariationFunc varFunc = VariationFuncList.getVariationFuncInstance("radial_blur", true);
        varFunc.setParameter("angle", 0.609835);
        xForm.addVariation(-0.249, varFunc);
      }
      // variation 4
      xForm.addVariation(1, VariationFuncList.getVariationFuncInstance("power", true));
      // random affine transforms (uncomment to play around)
      //   XFormTransformService.scale(xForm, 1.25-Math.random()*0.5, true, true, false);
      //   XFormTransformService.rotate(xForm, 360.0*Math.random(), false);
      XFormTransformService.localTranslate(xForm, 1.0 - 2.0 * Math.random(), 1.0 - 2.0 * Math.random(), false);
      // random affine post transforms (uncomment to play around)
      //   XFormTransformService.scale(xForm, 1.25-Math.random()*0.5, true, true, true);
      //   XFormTransformService.rotate(xForm, 360.0*Math.random(), true);
      //   XFormTransformService.localTranslate(xForm, 1.0-2.0*Math.random(), 1.0-2.0*Math.random(), true);
    }
    // create transform 2
    {
      XForm xForm = new XForm();
      layer.getXForms().add(xForm);
      xForm.setWeight(10.0 + Math.random() * 8.0);
      xForm.setColor(0.90312262);
      xForm.setColorSymmetry(0.95);

      xForm.setCoeff00(-0.85421287); // a
      xForm.setCoeff10(-0.63343313); // b
      xForm.setCoeff20(1.09379129); // e
      xForm.setCoeff01(-0.63343313); // c
      xForm.setCoeff11(0.85421287); // d
      xForm.setCoeff21(-0.20406326); // f

      xForm.setPostCoeff00(0.84389756);
      xForm.setPostCoeff10(-0.35800434);
      xForm.setPostCoeff01(0.43174917);
      xForm.setPostCoeff11(0.89637273);
      xForm.setPostCoeff20(-0.945758);
      xForm.setPostCoeff21(-0.4502584);

      // change relative weights
      xForm.getModifiedWeights()[0] = 2.05;
      xForm.getModifiedWeights()[1] = 1.25;
      xForm.getModifiedWeights()[2] = 0.9;

      // variation 1
      xForm.addVariation(0.008, VariationFuncList.getVariationFuncInstance("linear", true));
      // variation 2
      xForm.addVariation(10.72, VariationFuncList.getVariationFuncInstance("spherical", true));
      // random affine transforms (uncomment to play around)
      XFormTransformService.scale(xForm, 1.25 - Math.random() * 0.5, true, true, false);
      XFormTransformService.rotate(xForm, 36.0 * Math.random(), false);
      XFormTransformService.localTranslate(xForm, 1.0 - 2.0 * Math.random(), 1.0 - 2.0 * Math.random(), false);
      // random affine post transforms (uncomment to play around)
      //   XFormTransformService.scale(xForm, 1.25-Math.random()*0.5, true, true, true);
      //   XFormTransformService.rotate(xForm, 360.0*Math.random(), true);
      //   XFormTransformService.localTranslate(xForm, 1.0-2.0*Math.random(), 1.0-2.0*Math.random(), true);
    }
    // create transform 3
    {
      XForm xForm = new XForm();
      layer.getXForms().add(xForm);
      xForm.setWeight(0.7);
      xForm.setColor(0.47272985);
      xForm.setColorSymmetry(0);

      xForm.setCoeff00(0.68724662); // a
      xForm.setCoeff10(-0.72642418); // b
      xForm.setCoeff20(-2.14812602); // e
      xForm.setCoeff01(0.72642418); // c
      xForm.setCoeff11(0.68724662); // d
      xForm.setCoeff21(2.39994214); // f

      xForm.setPostCoeff00(0.60646395);
      xForm.setPostCoeff10(0.79511098);
      xForm.setPostCoeff01(-0.79511098);
      xForm.setPostCoeff11(0.60646395);
      xForm.setPostCoeff20(-1.06135064);
      xForm.setPostCoeff21(-0.6369509);

      // variation 1
      {
        VariationFunc varFunc = VariationFuncList.getVariationFuncInstance("bipolar", true);
        varFunc.setParameter("shift", 0);
        xForm.addVariation(1, varFunc);
      }
      // random affine transforms (uncomment to play around)
      //   XFormTransformService.scale(xForm, 1.25-Math.random()*0.5, true, true, false);
      //    XFormTransformService.rotate(xForm, 360.0*Math.random(), false);
View Full Code Here

TOP

Related Classes of org.jwildfire.create.tina.variation.VariationFunc

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.