Package org.jwildfire.create.tina.base

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


public class LinearRandomFlameGenerator extends RandomFlameGenerator {

  @Override
  protected Flame prepareFlame(RandomFlameGeneratorState pState) {
    Flame flame = new Flame();
    Layer layer = flame.getFirstLayer();
    flame.setCentreX(0.0);
    flame.setCentreY(0.0);
    flame.setPixelsPerUnit(200);
    layer.getFinalXForms().clear();
    layer.getXForms().clear();

    int maxXForms = (int) (1.0 + Math.random() * 5.0);
    double scl = 1.0;
    double tscl = 2.0;

    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 {
View Full Code Here


  @Override
  protected Flame prepareFlame(RandomFlameGeneratorState pState) {
    // Bases loosely on the W2R Batch Script by parrotdolphin.deviantart.com */
    Flame flame = new Flame();
    Layer layer = flame.getFirstLayer();
    flame.setCentreX(0.0);
    flame.setCentreY(0.0);
    flame.setPixelsPerUnit(200);
    layer.getFinalXForms().clear();
    layer.getXForms().clear();
    // init
    double scaleX = Math.random() * 0.04 + 0.04;
    if (Math.random() > 0.75) {
      scaleX = 0 - scaleX;
    }

    double scaleY = Math.random() * 0.04 + 0.04;
    if (Math.random() > 0.75) {
      scaleY = 0 - scaleY;
    }
    else if (Math.random() < 0.25) {
      scaleY = scaleX;
    }

    double freqX = Math.random() * 2.0 + 7.0;
    double freqY;
    if (Math.random() < 0.25) {
      freqY = freqX;
    }
    else {
      freqY = Math.random() * 2.0 + 7.0;
    }

    double blurAmount = 0.0025 * Math.random();
    double nonBlurAmount = 0.25 * Math.random();
    double wavesWeight = Math.random() * 10 + 75;
    double _2ndWeight = 0.5;
    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);
View Full Code Here

public class SierpinskyRandomFlameGenerator extends RandomFlameGenerator {

  @Override
  protected Flame prepareFlame(RandomFlameGeneratorState pState) {
    Flame flame = new Flame();
    Layer layer = flame.getFirstLayer();
    flame.setCentreX(0.0);
    flame.setCamRoll((int) (Math.random() * 8.0) * -45.0);
    flame.setCentreY(0.0);
    flame.setPixelsPerUnit(200);
    layer.getFinalXForms().clear();
    layer.getXForms().clear();
    flame.setCamZoom(4.56);
    double posx[] = { -0.5, 0.5, 0.5, -0.5 };
    double posy[] = { -0.5, -0.5, 0.5, 0.5 };

    for (int i = 0; i < posx.length; i++) {
      XForm xForm = new XForm();
      layer.getXForms().add(xForm);
      xForm.setWeight(0.5);
      xForm.setCoeff20(posx[i]);
      xForm.setCoeff21(posy[i]);
      xForm.setColor(Math.random());
      xForm.setColorSymmetry(Math.random());
View Full Code Here

    }
  }

  private void drawTriangles(Graphics2D g) {
    if (layerHolder != null) {
      Layer layer = layerHolder.getLayer();
      if (layer != null) {
        if (!prefs.isTinaEditorControlsWithShadows()) {
          g.setColor(config.isEditPostTransform() ? XFORM_POST_COLOR : FlamePanelConfig.XFORM_COLOR);
        }

        // draw the selected one at last
        for (int pass = 0; pass < 2; pass++) {
          for (int i = 0; i < layer.getXForms().size(); i++) {
            XForm xForm = layer.getXForms().get(i);
            if ((pass == 0 && (selectedXForm == null || xForm != selectedXForm)) || (pass == 1 && xForm == selectedXForm)) {
              boolean isSelected = xForm == selectedXForm;
              if (prefs.isTinaEditorControlsWithShadows()) {
                g.setColor(SHADOW_COLOR);
                drawXForm(g, xForm, i, layer.getXForms().size(), false, true, isSelected);
                drawXForm(g, xForm, i, layer.getXForms().size(), false, false, isSelected);
              }
              else {
                drawXForm(g, xForm, i, layer.getXForms().size(), false, false, isSelected);
              }
            }
          }
          for (int i = 0; i < layer.getFinalXForms().size(); i++) {
            XForm xForm = layer.getFinalXForms().get(i);
            if ((pass == 0 && (selectedXForm == null || xForm != selectedXForm)) || (pass == 1 && xForm == selectedXForm)) {
              boolean isSelected = xForm == selectedXForm;
              if (prefs.isTinaEditorControlsWithShadows()) {
                g.setColor(SHADOW_COLOR);
                drawXForm(g, xForm, i, layer.getXForms().size(), true, true, isSelected);
                drawXForm(g, xForm, i, layer.getXForms().size(), true, false, isSelected);
              }
              else {
                drawXForm(g, xForm, i, layer.getXForms().size(), true, false, isSelected);
              }
            }
          }
          if (selectedXForm == null) {
            break;
View Full Code Here

            flame.setFocusX(flame.getFocusX() + rcX * 0.5);
            flame.setFocusY(flame.getFocusY() - rcY * 0.5);
            return true;
          }
          case GRADIENT: {
            Layer layer = layerHolder.getLayer();
            dx = viewDX * 0.25;
            if (fineMovement) {
              dx *= 0.25;
            }
            reRender = gradientOverlay.mouseDragged(dx, xBeginDrag, yBeginDrag, layer);
View Full Code Here

  public XForm mouseClicked(int x, int y) {
    redrawAfterMouseClick = false;
    // select flame
    if (config.getMouseDragOperation() == MouseDragOperation.MOVE_TRIANGLE || config.getMouseDragOperation() == MouseDragOperation.ROTATE_TRIANGLE || config.getMouseDragOperation() == MouseDragOperation.SCALE_TRIANGLE) {
      Layer layer = layerHolder.getLayer();
      if (layer != null) {
        for (XForm xForm : layer.getXForms()) {
          if (getHandler(flamePanelTriangleMode).isInsideXForm(xForm, x, y)) {
            if (config.getMouseDragOperation() == MouseDragOperation.POINTS) {
              config.setSelectedPoint(getHandler(flamePanelTriangleMode).selectNearestPoint(xForm, x, y));
              redrawAfterMouseClick = true;
              reRender = true;
            }
            return xForm;
          }
        }
        for (XForm xForm : layer.getFinalXForms()) {
          if (getHandler(flamePanelTriangleMode).isInsideXForm(xForm, x, y)) {
            if (config.getMouseDragOperation() == MouseDragOperation.POINTS) {
              config.setSelectedPoint(getHandler(flamePanelTriangleMode).selectNearestPoint(xForm, x, y));
              redrawAfterMouseClick = true;
              reRender = true;
View Full Code Here

      "spherical3D", "spiral", "rectangles", "blur", "waves", "swirl", "secant2", "boarders2" };

  @Override
  protected Flame prepareFlame(RandomFlameGeneratorState pState) {
    Flame flame = new Flame();
    Layer layer = flame.getFirstLayer();
    flame.setCentreX(0.0);
    flame.setCentreY(0.0);
    flame.setPixelsPerUnit(200);
    layer.getFinalXForms().clear();
    layer.getXForms().clear();

    int maxXForms = (int) (2.0 + Math.random() * 5.0);
    double scl = 1.0;
    for (int i = 0; i < maxXForms; i++) {
      XForm xForm = new XForm();
      layer.getXForms().add(xForm);
      if (Math.random() < 0.5) {
        XFormTransformService.rotate(xForm, 360.0 * Math.random());
      }
      else {
        XFormTransformService.rotate(xForm, -360.0 * Math.random());
 
View Full Code Here

public class XenomorphRandomFlameGenerator extends RandomFlameGenerator {

  @Override
  protected Flame prepareFlame(RandomFlameGeneratorState pState) {
    Flame flame = new Flame();
    Layer layer = flame.getFirstLayer();
    flame.setCentreX(0.0);
    flame.setCentreY(0.0);
    flame.setPixelsPerUnit(200);
    layer.getFinalXForms().clear();
    layer.getXForms().clear();

    // create transform 1
    {
      XForm xForm = new XForm();
      layer.getXForms().add(xForm);
      xForm.setWeight(0.1 + Math.random() * 0.4);
      xForm.setColor(0.74488914);
      xForm.setColorSymmetry(0);

      xForm.setCoeff00(0.75610133); // a
      xForm.setCoeff10(-0.74186252); // b
      xForm.setCoeff20(5.25778565); // e
      xForm.setCoeff01(0.74186252); // c
      xForm.setCoeff11(0.75610133); // d
      xForm.setCoeff21(-0.34949139); // f

      xForm.setPostCoeff00(-0.42606416);
      xForm.setPostCoeff10(0.44290131);
      xForm.setPostCoeff01(-0.10610689);
      xForm.setPostCoeff11(-0.40885976);
      xForm.setPostCoeff20(-2.81712);
      xForm.setPostCoeff21(7.390367);

      // variation 1
      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
View Full Code Here

      "circus", "lazyTravis", "ovoid3d", "circleblur", "sineblur", "starblur" };

  @Override
  protected Flame prepareFlame(RandomFlameGeneratorState pState) {
    Flame flame = new Flame();
    Layer layer = flame.getFirstLayer();
    flame.setCentreX(0.0);
    flame.setCentreY(0.0);
    flame.setPixelsPerUnit(200);
    layer.getFinalXForms().clear();
    layer.getXForms().clear();

    int maxXForms = (int) (1.0 + Math.random() * 5.0);
    double scl = 1.0;
    for (int i = 0; i < maxXForms; i++) {
      XForm xForm = new XForm();
      layer.getXForms().add(xForm);
      if (Math.random() < 0.5) {
        XFormTransformService.rotate(xForm, 360.0 * Math.random());
      }
      else {
        XFormTransformService.rotate(xForm, -360.0 * Math.random());
 
View Full Code Here

    return Math.random() > 0.33 ? new GnarlRandomFlameGenerator() : new ExperimentalGnarlRandomFlameGenerator();
  }

  @Override
  protected Flame preProcessFlame(Flame pFlame) {
    Layer layer = pFlame.getFirstLayer();
    while (layer.getXForms().size() > 2) {
      layer.getXForms().remove(layer.getXForms().size() - 1);
    }
    return pFlame;
  }
View Full Code Here

TOP

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

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.