Package org.jwildfire.create.tina.base

Examples of org.jwildfire.create.tina.base.XForm


    saveUndoPoint();
    addXForm();
    int fromId = row;
    int toId = getCurrLayer().getXForms().size() - 1;
    for (int i = 0; i < getCurrLayer().getXForms().size(); i++) {
      XForm xForm = getCurrLayer().getXForms().get(i);
      if (i == fromId) {
        for (int j = 0; j < getCurrLayer().getXForms().size(); j++) {
          xForm.getModifiedWeights()[j] = (j == toId) ? 1 : 0;
        }
      }
      else {
        xForm.getModifiedWeights()[toId] = 0;
      }
    }

  }
View Full Code Here


    }

  }

  public void addXForm() {
    XForm xForm = new XForm();
    xForm.addVariation(1.0, new Linear3DFunc());
    xForm.setWeight(0.5);
    saveUndoPoint();
    getCurrLayer().getXForms().add(xForm);
    gridRefreshing = true;
    try {
      refreshTransformationsTable();
View Full Code Here

    data.transformationsTable.getSelectionModel().setSelectionInterval(row, row);
    refreshFlameImage(false);
  }

  public void duplicateXForm() {
    XForm xForm = new XForm();
    xForm.assign(getCurrXForm());
    saveUndoPoint();
    getCurrLayer().getXForms().add(xForm);
    gridRefreshing = true;
    try {
      refreshTransformationsTable();
View Full Code Here

    }
    refreshFlameImage(false);
  }

  public void addFinalXForm() {
    XForm xForm = new XForm();
    xForm.addVariation(1.0, new Linear3DFunc());
    saveUndoPoint();
    getCurrLayer().getFinalXForms().add(xForm);
    gridRefreshing = true;
    try {
      refreshTransformationsTable();
View Full Code Here

public class AddVariationMutation implements Mutation {

  @Override
  public void execute(Layer pLayer) {
    XForm xForm;
    if (Math.random() < 0.75 || pLayer.getFinalXForms().size() == 0) {
      int idx = (int) (pLayer.getXForms().size() * Math.random());
      xForm = pLayer.getXForms().get(idx);
    }
    else {
      int idx = (int) (pLayer.getFinalXForms().size() * Math.random());
      xForm = pLayer.getFinalXForms().get(idx);
    }

    if (Math.random() < 0.75) {
      if (Math.random() < 0.67 && xForm.getVariationCount() > 0) {
        int idx = (int) (Math.random() * xForm.getVariationCount());
        xForm.removeVariation(xForm.getVariation(idx));
      }
      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.01 + Math.random() * 10.0, VariationFuncList.getVariationFuncInstance(fName, true));
    }
  }
View Full Code Here

  @Override
  public void execute(Layer pLayer) {
    if (Math.random() < 0.5) {
      for (int i = 0; i < pLayer.getXForms().size(); i++) {
        XForm xForm = pLayer.getXForms().get(i);
        xForm.setColor(Math.random());
        if (Math.random() < 0.25) {
          xForm.setColorSymmetry(Math.random());
        }
      }
    }
    else {
      pLayer.getPalette().setModShift(-256 + (int) (512 * Math.random()));
 
View Full Code Here

    apply(pLayer, 0.2);
    apply(pLayer, 0.1);
  }

  private void apply(Layer pLayer, double pAmount) {
    XForm xForm;
    if (pLayer.getFinalXForms().size() == 0 || Math.random() < 0.5) {
      xForm = pLayer.getXForms().get((int) (pLayer.getXForms().size() * Math.random()));
    }
    else {
      xForm = pLayer.getFinalXForms().get((int) (pLayer.getFinalXForms().size() * Math.random()));
    }
    if (Math.random() < 0.5) {
      if (Math.random() < 0.75) {
        if (Math.random() < 0.5) {
          xForm.setCoeff00(xForm.getCoeff00() + pAmount * (-0.25 + 0.5 * Math.random()));
        }
        if (Math.random() < 0.5) {
          xForm.setCoeff01(xForm.getCoeff01() + pAmount * (-0.25 + 0.5 * Math.random()));
        }
        if (Math.random() < 0.5) {
          xForm.setCoeff10(xForm.getCoeff10() + pAmount * (-0.25 + 0.5 * Math.random()));
        }
        if (Math.random() < 0.5) {
          xForm.setCoeff11(xForm.getCoeff11() + pAmount * (-0.25 + 0.5 * Math.random()));
        }
        if (Math.random() < 0.5) {
          xForm.setCoeff20(xForm.getCoeff20() + pAmount * (-0.25 + 0.5 * Math.random()));
        }
        if (Math.random() < 0.5) {
          xForm.setCoeff21(xForm.getCoeff21() + pAmount * (-0.25 + 0.5 * Math.random()));
        }
      }
      else {
        if (Math.random() < 0.5) {
          xForm.setPostCoeff00(xForm.getPostCoeff00() + pAmount * (-0.25 + 0.5 * Math.random()));
        }
        if (Math.random() < 0.5) {
          xForm.setPostCoeff01(xForm.getPostCoeff01() + pAmount * (-0.25 + 0.5 * Math.random()));
        }
        if (Math.random() < 0.5) {
          xForm.setPostCoeff10(xForm.getPostCoeff10() + pAmount * (-0.25 + 0.5 * Math.random()));
        }
        if (Math.random() < 0.5) {
          xForm.setPostCoeff11(xForm.getPostCoeff11() + pAmount * (-0.25 + 0.5 * Math.random()));
        }
        if (Math.random() < 0.5) {
          xForm.setPostCoeff20(xForm.getPostCoeff20() + pAmount * (-0.25 + 0.5 * Math.random()));
        }
        if (Math.random() < 0.5) {
          xForm.setPostCoeff21(xForm.getPostCoeff21() + pAmount * (-0.25 + 0.5 * Math.random()));
        }
      }
    }
    else {
      if (Math.random() < 0.33) {
View Full Code Here

    if (Math.random() < 0.75) {
      if (Math.random() < 0.5 && pLayer.getXForms().size() > 0) {
        int idx = (int) (Math.random() * pLayer.getXForms().size());
        pLayer.getXForms().remove(idx);
      }
      XForm xForm = new XForm();
      pLayer.getXForms().add(xForm);
      xForm.setWeight(0.1 + Math.random() * 2.0);
      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.01 + Math.random() * 10.0, VariationFuncList.getVariationFuncInstance(fName, true));
    }
    else {
      if (Math.random() < 0.5 && pLayer.getFinalXForms().size() > 0) {
        int idx = (int) (Math.random() * pLayer.getFinalXForms().size());
        pLayer.getFinalXForms().remove(idx);
      }
      XForm xForm = new XForm();
      pLayer.getFinalXForms().add(xForm);
      xForm.setWeight(0.1 + Math.random() * 2.0);
      String fName;
      if (Math.random() < 0.33) {
        int idx = ExperimentalSimpleRandomFlameGenerator.FNCLST_EXPERIMENTAL.length;
        fName = ExperimentalSimpleRandomFlameGenerator.FNCLST_EXPERIMENTAL[(int) (Math.random() * idx)];
      }
      else {
        while (true) {
          fName = VariationFuncList.getRandomVariationname();
          if (fName.indexOf("blur") < 0 && fName.indexOf("Blur") < 0 && fName.indexOf("fract_") != 0) {
            break;
          }
        }
      }

      xForm.addVariation(0.01 + Math.random() * 10.0, VariationFuncList.getVariationFuncInstance(fName, true));
    }
  }
View Full Code Here

    boolean contRot = Math.random() < 0.5;
    double r0 = 0;

    for (int i = 0; i < maxXForms; i++) {
      XForm xForm = new XForm();
      layer.getXForms().add(xForm);
      if (contRot) {
        r0 += 45.0 * Math.random() - 9.0 * Math.random();
        XFormTransformService.rotate(xForm, r0);
      }
      else {
        if (Math.random() < 0.5) {
          XFormTransformService.rotate(xForm, 360.0 * Math.random());
        }
        else {
          XFormTransformService.rotate(xForm, -360.0 * Math.random());
        }
      }
      XFormTransformService.localTranslate(xForm, (2.0 * Math.random() - 1.0) * tscl, (2.0 * Math.random() - 1.0) * tscl);
      scl *= 0.8 + Math.random() * 0.1;
      tscl *= 0.8 + Math.random() * 0.1;

      XFormTransformService.scale(xForm, scl, true, true);

      xForm.setColor(Math.random());
      xForm.addVariation(Math.random() * 0.5 + 0.5, new Linear3DFunc());
      xForm.setWeight(scl * Math.random() * 19.9 + 0.1);
    }
    return flame;
  }
View Full Code Here

    double _3rdWeight = 0.5;
    double symmetry = 0.6 + Math.random() * 0.4;
    int sides = (int) (Math.random() * 11.0 + 2.0);
    // 1st XForm
    {
      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) {
          w2 = GnarlRandomFlameGenerator.createWaves2Variation(scaleX, scaleY, freqX, freqY);
        }
        else {
          w2 = GnarlRandomFlameGenerator.createWaves2BVariation(scaleX, scaleY, freqX, freqY);
        }
      }

      xForm.addVariation(1, w2);

      switch ((int) (Math.random() * 36.0)) {
        case 0:
          xForm.addVariation(blurAmount, VariationFuncList.getVariationFuncInstance("blur", true));
          break;
        case 1:
          xForm.addVariation(nonBlurAmount, VariationFuncList.getVariationFuncInstance("cos", true));
          break;
        case 2:
          xForm.addVariation(nonBlurAmount, VariationFuncList.getVariationFuncInstance("exp", true));
          break;
        case 3:
          xForm.addVariation(nonBlurAmount, VariationFuncList.getVariationFuncInstance("exponential", true));
          break;
        case 4:
          xForm.addVariation(nonBlurAmount, VariationFuncList.getVariationFuncInstance("lazysusan", true));
          break;
        case 5:
          xForm.addVariation(nonBlurAmount, VariationFuncList.getVariationFuncInstance("ngon", true));
          break;
        case 6:
          xForm.addVariation(nonBlurAmount, VariationFuncList.getVariationFuncInstance("sech", true));
          break;
        case 7:
          xForm.addVariation(nonBlurAmount, VariationFuncList.getVariationFuncInstance("sinh", true));
          break;
        case 8:
          xForm.addVariation(nonBlurAmount, VariationFuncList.getVariationFuncInstance("epispiral_wf", true));
          break;
        case 9:
          xForm.addVariation(nonBlurAmount, VariationFuncList.getVariationFuncInstance("tanh", true));
          break;
        case 10:
          xForm.addVariation(nonBlurAmount, VariationFuncList.getVariationFuncInstance("twintrian", true));
          break;
        case 11:
          xForm.addVariation(blurAmount, VariationFuncList.getVariationFuncInstance("bubble", true));
          break;
        case 12:
          xForm.addVariation(nonBlurAmount, VariationFuncList.getVariationFuncInstance("epispiral", true));
          break;
        default: {
          int l = ExperimentalSimpleRandomFlameGenerator.FNCLST_EXPERIMENTAL.length;
          String fName = ExperimentalSimpleRandomFlameGenerator.FNCLST_EXPERIMENTAL[(int) (Math.random() * l)];
          xForm.addVariation(blurAmount, VariationFuncList.getVariationFuncInstance(fName, true));
        }
      }

      xForm.setColorSymmetry(symmetry);
      xForm.setColor(0.9);
      if (Math.random() > 0.5) {
        XFormTransformService.scale(xForm, 0.9 + Math.random() * 0.09, true, true);
      }
      double angle, tx, ty;
      switch (sides) {
        case 2:
          angle = -180;
          tx = Math.random() * 8 - 4;
          ty = Math.random() * 8 - 4;
          break;
        case 3:
          angle = -120;
          tx = Math.random() * 8 - 4;
          ty = Math.random() * 8 - 4;
          break;
        case 4:
          angle = -90;
          tx = Math.random() * 8 - 4;
          ty = Math.random() * 8 - 4;
          break;
        case 5:
          angle = -72;
          tx = Math.random() * 7 - 3.5;
          ty = Math.random() * 7 - 3.5;
          break;
        case 6:
          angle = -60;
          tx = Math.random() * 7 - 3.5;
          ty = Math.random() * 7 - 3.5;
          break;
        case 7:
          angle = -51.42857;
          tx = Math.random() * 6 - 3;
          ty = Math.random() * 6 - 3;
          break;
        case 8:
          angle = -135;
          tx = Math.random() * 6 - 3;
          ty = Math.random() * 6 - 3;
          break;
        case 9:
          angle = -40;
          tx = Math.random() * 5 - 2.5;
          ty = Math.random() * 5 - 2.5;
          break;
        case 10:
          angle = -36;
          tx = Math.random() * 4 - 2;
          ty = Math.random() * 4 - 2;
          break;
        case 11:
          angle = -32.73;
          tx = Math.random() * 4.2 - 3;
          ty = Math.random() * 4.2 - 3;
          break;
        case 12:
          angle = -30;
          tx = Math.random() * 4.2 - 3;
          ty = Math.random() * 4.2 - 3;
          break;
        default:
          throw new IllegalStateException();
      }
      XFormTransformService.rotate(xForm, angle);
      XFormTransformService.localTranslate(xForm, tx, ty);
    }
    // 2nd XForm
    XForm secondXForm;
    {
      XForm xForm = secondXForm = new XForm();
      layer.getXForms().add(xForm);
      xForm.setWeight(_2ndWeight);
      int f = (int) (Math.random() * 4);
      switch (f) {
        case 0:
          xForm.addVariation(Math.random() * 0.7 + 0.1, VariationFuncList.getVariationFuncInstance("radial_blur", true));
          break;
        case 1:
          xForm.addVariation(Math.random() * 0.7 + 0.3, VariationFuncList.getVariationFuncInstance("bubble", true));
          xForm.addVariation(Math.random() * 0.7 + 0.1, VariationFuncList.getVariationFuncInstance("radial_blur", true));
          break;
        case 2:
          xForm.addVariation(Math.random() * 0.1, VariationFuncList.getVariationFuncInstance("radial_blur", true));
          JuliaNFunc juliaN = (JuliaNFunc) VariationFuncList.getVariationFuncInstance("julian", true);
          juliaN.setParameter("power", 50 - Math.random() * 100);
          juliaN.setParameter("dist", Math.random() * 10 - 2);
          xForm.addVariation(Math.random() * 0.06 + 0.1, juliaN);
          break;
        case 3:
          xForm.addVariation(Math.random() * 0.7 + 0.3, VariationFuncList.getVariationFuncInstance("spherical3D", true));
          break;
      }
      XFormTransformService.rotate(xForm, 180 - Math.random() * 360.0);
      if (Math.random() > 0.5) {
        XFormTransformService.scale(xForm, 0.5 + Math.random() * 1.0, true, true);
      }
      xForm.setColorSymmetry(-1);
    }
    // 3rd XForm
    if (Math.random() > 0.75) {
      if (Math.random() > 0.5) {
        secondXForm.setWeight(5 + Math.random() * 20.0);
      }
      XForm xForm = new XForm();
      layer.getXForms().add(xForm);
      xForm.setWeight(_3rdWeight);
      xForm.addVariation(1.0, VariationFuncList.getVariationFuncInstance("linear3D", true));
      XFormTransformService.rotate(xForm, 180 - Math.random() * 360.0);
      XFormTransformService.localTranslate(xForm, 1.0 - 2.0 * Math.random(), 1.0 - 2.0 * Math.random());
      xForm.setColorSymmetry(-1);
    }
    return flame;
  }
View Full Code Here

TOP

Related Classes of org.jwildfire.create.tina.base.XForm

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.