Search in sources :

Example 11 with Variation

use of org.jwildfire.create.tina.variation.Variation in project JWildfire by thargor6.

the class VariationControlsDelegate method getInitialValue.

@Override
public double getInitialValue(String pPropName) {
    XForm xForm = owner.getCurrXForm();
    Variation var = xForm.getVariation(variationIndex);
    return AnimationService.getPropertyValue(var, pPropName);
}
Also used : XForm(org.jwildfire.create.tina.base.XForm) Variation(org.jwildfire.create.tina.variation.Variation)

Example 12 with Variation

use of org.jwildfire.create.tina.variation.Variation in project JWildfire by thargor6.

the class FlamePanel method drawXForms.

private void drawXForms(Graphics2D g) {
    if (selectedXForm != null && selectedXForm.getVariationCount() > 0) {
        try {
            selectedXForm.initTransform();
            for (Variation var : selectedXForm.getVariations()) {
                var.getFunc().init(getFlameTransformationContext(), layerHolder != null ? layerHolder.getLayer() : null, selectedXForm, var.getAmount());
            }
            double xMin = -1.0;
            double xMax = 1.0;
            int xSteps = 32;
            double yMin = -1.0;
            double yMax = 1.0;
            int ySteps = 32;
            // 
            double xs = (xMax - xMin) / (double) (xSteps - 1.0);
            double ys = (yMax - yMin) / (double) (ySteps - 1.0);
            int[][] xx = new int[ySteps][xSteps];
            int[][] yy = new int[ySteps][xSteps];
            {
                double y = yMin;
                // affine part of the transformation
                XYZPoint affineT = new XYZPoint();
                // complete transformation
                XYZPoint varT = new XYZPoint();
                XYZPoint p = new XYZPoint();
                for (int i = 0; i < ySteps; i++) {
                    double x = xMin;
                    for (int j = 0; j < xSteps; j++) {
                        p.x = x;
                        p.y = y;
                        p.z = 0.0;
                        selectedXForm.transformPoint(getFlameTransformationContext(), affineT, varT, p, p);
                        xx[i][j] = triangleXToView(p.x);
                        yy[i][j] = triangleYToView(-p.y);
                        x += xs;
                    }
                    y += ys;
                }
            }
            g.setColor(VARIATION_COLOR);
            g.setStroke(GRID_LINE);
            for (int y = 0; y < ySteps - 1; y++) {
                for (int x = 0; x < xSteps - 1; x++) {
                    g.drawLine(xx[y][x], yy[y][x], xx[y][x + 1], yy[y][x + 1]);
                    g.drawLine(xx[y][x], yy[y][x], xx[y + 1][x], yy[y + 1][x]);
                    if (x == xSteps - 2) {
                        g.drawLine(xx[y][x + 1], yy[y][x + 1], xx[y + 1][x + 1], yy[y + 1][x + 1]);
                    }
                    if (y == ySteps - 2) {
                        g.drawLine(xx[y + 1][x], yy[y + 1][x], xx[y + 1][x + 1], yy[y + 1][x + 1]);
                    }
                }
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
}
Also used : XYZPoint(org.jwildfire.create.tina.base.XYZPoint) Variation(org.jwildfire.create.tina.variation.Variation) XYZPoint(org.jwildfire.create.tina.base.XYZPoint)

Example 13 with Variation

use of org.jwildfire.create.tina.variation.Variation in project JWildfire by thargor6.

the class AbstractFlameReader method parseXFormAttributes.

protected void parseXFormAttributes(Flame pFlame, XForm pXForm, String pXML) {
    XMLAttributes atts = Tools.parseAttributes(pXML);
    String hs;
    if ((hs = atts.get(ATTR_NAME)) != null) {
        pXForm.setName(hs);
    }
    if ((hs = atts.get(ATTR_WEIGHT)) != null) {
        pXForm.setWeight(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_MIRROR_PRE_POST_TRANSLATIONS)) != null) {
        double val = Double.parseDouble(hs);
        pXForm.setMirrorTranslations(val == 1);
    }
    if ((hs = atts.get(ATTR_COLOR)) != null) {
        pXForm.setColor(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_MATERIAL)) != null) {
        pXForm.setMaterial(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_MATERIAL_SPEED)) != null) {
        pXForm.setMaterialSpeed(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_MOD_GAMMA)) != null) {
        pXForm.setModGamma(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_MOD_GAMMA_SPEED)) != null) {
        pXForm.setModGammaSpeed(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_MOD_CONTRAST)) != null) {
        pXForm.setModContrast(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_MOD_CONTRAST_SPEED)) != null) {
        pXForm.setModContrastSpeed(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_MOD_SATURATION)) != null) {
        pXForm.setModSaturation(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_MOD_SATURATION_SPEED)) != null) {
        pXForm.setModSaturationSpeed(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_MOD_HUE)) != null) {
        pXForm.setModHue(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_MOD_HUE_SPEED)) != null) {
        pXForm.setModHueSpeed(Double.parseDouble(hs));
    }
    // legacy
    if ((hs = atts.get(ATTR_ANTIALIAS_AMOUNT)) != null) {
        double value = Double.parseDouble(hs);
        if (value > 0)
            pFlame.setAntialiasAmount(value);
    }
    // legacy
    if ((hs = atts.get(ATTR_ANTIALIAS_RADIUS)) != null) {
        double value = Double.parseDouble(hs);
        if (value > 0)
            pFlame.setAntialiasRadius(value);
    }
    if ((hs = atts.get(ATTR_OPACITY)) != null) {
        double opacity = Double.parseDouble(hs);
        pXForm.setOpacity(opacity);
        if (Math.abs(opacity) <= MathLib.EPSILON) {
            pXForm.setDrawMode(DrawMode.HIDDEN);
        } else if (Math.abs(opacity - 1.0) > MathLib.EPSILON) {
            pXForm.setDrawMode(DrawMode.OPAQUE);
        } else {
            pXForm.setDrawMode(DrawMode.NORMAL);
        }
    }
    if ((hs = atts.get(ATTR_SYMMETRY)) != null) {
        pXForm.setColorSymmetry(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_XY_COEFS)) != null) {
        String[] s = hs.split(" ");
        pXForm.setXYCoeff00(Double.parseDouble(s[0]));
        pXForm.setXYCoeff01(Double.parseDouble(s[1]));
        pXForm.setXYCoeff10(Double.parseDouble(s[2]));
        pXForm.setXYCoeff11(Double.parseDouble(s[3]));
        pXForm.setXYCoeff20(Double.parseDouble(s[4]));
        pXForm.setXYCoeff21(Double.parseDouble(s[5]));
    }
    if ((hs = atts.get(ATTR_XY_POST)) != null) {
        String[] s = hs.split(" ");
        pXForm.setXYPostCoeff00(Double.parseDouble(s[0]));
        pXForm.setXYPostCoeff01(Double.parseDouble(s[1]));
        pXForm.setXYPostCoeff10(Double.parseDouble(s[2]));
        pXForm.setXYPostCoeff11(Double.parseDouble(s[3]));
        pXForm.setXYPostCoeff20(Double.parseDouble(s[4]));
        pXForm.setXYPostCoeff21(Double.parseDouble(s[5]));
    }
    if ((hs = atts.get(ATTR_YZ_COEFS)) != null) {
        String[] s = hs.split(" ");
        pXForm.setYZCoeff00(Double.parseDouble(s[0]));
        pXForm.setYZCoeff01(Double.parseDouble(s[1]));
        pXForm.setYZCoeff10(Double.parseDouble(s[2]));
        pXForm.setYZCoeff11(Double.parseDouble(s[3]));
        pXForm.setYZCoeff20(Double.parseDouble(s[4]));
        pXForm.setYZCoeff21(Double.parseDouble(s[5]));
    }
    if ((hs = atts.get(ATTR_YZ_POST)) != null) {
        String[] s = hs.split(" ");
        pXForm.setYZPostCoeff00(Double.parseDouble(s[0]));
        pXForm.setYZPostCoeff01(Double.parseDouble(s[1]));
        pXForm.setYZPostCoeff10(Double.parseDouble(s[2]));
        pXForm.setYZPostCoeff11(Double.parseDouble(s[3]));
        pXForm.setYZPostCoeff20(Double.parseDouble(s[4]));
        pXForm.setYZPostCoeff21(Double.parseDouble(s[5]));
    }
    if ((hs = atts.get(ATTR_ZX_COEFS)) != null) {
        String[] s = hs.split(" ");
        pXForm.setZXCoeff00(Double.parseDouble(s[0]));
        pXForm.setZXCoeff01(Double.parseDouble(s[1]));
        pXForm.setZXCoeff10(Double.parseDouble(s[2]));
        pXForm.setZXCoeff11(Double.parseDouble(s[3]));
        pXForm.setZXCoeff20(Double.parseDouble(s[4]));
        pXForm.setZXCoeff21(Double.parseDouble(s[5]));
    }
    if ((hs = atts.get(ATTR_ZX_POST)) != null) {
        String[] s = hs.split(" ");
        pXForm.setZXPostCoeff00(Double.parseDouble(s[0]));
        pXForm.setZXPostCoeff01(Double.parseDouble(s[1]));
        pXForm.setZXPostCoeff10(Double.parseDouble(s[2]));
        pXForm.setZXPostCoeff11(Double.parseDouble(s[3]));
        pXForm.setZXPostCoeff20(Double.parseDouble(s[4]));
        pXForm.setZXPostCoeff21(Double.parseDouble(s[5]));
    }
    if ((hs = atts.get(ATTR_CHAOS)) != null) {
        String[] s = hs.split(" ");
        for (int i = 0; i < s.length; i++) {
            pXForm.getModifiedWeights()[i] = Double.parseDouble(s[i]);
        }
    }
    readMotionCurves(pXForm, atts, null);
    // variations
    {
        List<String> variationNameList = VariationFuncList.getNameList();
        Map<String, String> aliasMap = VariationFuncList.getAliasMap();
        for (XMLAttribute attr : atts.getAttributes()) {
            String rawName = attr.getName();
            String name = removeIndexFromAttr(rawName);
            String varName = name;
            boolean hasVariation = variationNameList.indexOf(varName) >= 0;
            if (!hasVariation) {
                String aliasName = aliasMap.get(name);
                if (aliasName != null) {
                    varName = aliasName;
                    hasVariation = variationNameList.indexOf(varName) >= 0;
                }
            }
            if (hasVariation) {
                VariationFunc varFunc = VariationFuncList.getVariationFuncInstance(varName);
                Variation variation = pXForm.addVariation(Double.parseDouble(atts.get(rawName)), varFunc);
                String priority = atts.get(rawName + "_" + ATTR_FX_PRIORITY);
                if (priority != null && priority.length() > 0) {
                    variation.setPriority(Integer.parseInt(priority));
                }
                // ressources
                {
                    String[] ressNames = variation.getFunc().getRessourceNames();
                    if (ressNames != null) {
                        for (String pName : ressNames) {
                            String pHs;
                            if ((pHs = atts.get(rawName + "_" + pName)) != null) {
                                variation.getFunc().setRessource(pName, Tools.hexStringToByteArray(pHs));
                            }
                        }
                    }
                }
                // params
                {
                    String[] paramNames = variation.getFunc().getParameterNames();
                    String[] paramAltNames = variation.getFunc().getParameterAlternativeNames();
                    if (paramNames != null) {
                        if (paramAltNames != null && paramAltNames.length != paramNames.length) {
                            paramAltNames = null;
                        }
                        for (int i = 0; i < paramNames.length; i++) {
                            String pName = paramNames[i];
                            String pHs;
                            if ((pHs = atts.get(rawName + "_" + pName)) != null) {
                                variation.getFunc().setParameter(pName, Double.parseDouble(pHs));
                            } else // altNames can only be come from flames which were not created by JWF, so no need to handle index here
                            if (paramAltNames != null && ((pHs = atts.get(paramAltNames[i])) != null)) {
                                variation.getFunc().setParameter(pName, Double.parseDouble(pHs));
                            }
                            // curve
                            {
                                String namePrefix = rawName + "_" + pName + "_";
                                if (atts.get(namePrefix + AbstractFlameReader.CURVE_ATTR_POINT_COUNT) != null) {
                                    MotionCurve curve = variation.getMotionCurve(pName);
                                    if (curve == null) {
                                        curve = variation.createMotionCurve(pName);
                                    }
                                    readMotionCurveAttributes(atts, curve, namePrefix);
                                }
                            }
                        }
                    }
                }
                // then changes to parameter B cannot in turn cause additional parameters to be added/removed
                if (variation.getFunc().dynamicParameterExpansion()) {
                    String[] paramNames = variation.getFunc().getParameterNames();
                    String[] paramAltNames = variation.getFunc().getParameterAlternativeNames();
                    if (paramNames != null) {
                        if (paramAltNames != null && paramAltNames.length != paramNames.length) {
                            paramAltNames = null;
                        }
                        for (int i = 0; i < paramNames.length; i++) {
                            String pName = paramNames[i];
                            String pHs;
                            if ((pHs = atts.get(rawName + "_" + pName)) != null) {
                                variation.getFunc().setParameter(pName, Double.parseDouble(pHs));
                            } else // altNames can only be come from flames which were not created by JWF, so no need to handle index here
                            if (paramAltNames != null && ((pHs = atts.get(paramAltNames[i])) != null)) {
                                variation.getFunc().setParameter(pName, Double.parseDouble(pHs));
                            }
                            // curve
                            {
                                String namePrefix = rawName + "_" + pName + "_";
                                if (atts.get(namePrefix + AbstractFlameReader.CURVE_ATTR_POINT_COUNT) != null) {
                                    MotionCurve curve = variation.getMotionCurve(pName);
                                    if (curve == null) {
                                        curve = variation.createMotionCurve(pName);
                                    }
                                    readMotionCurveAttributes(atts, curve, namePrefix);
                                }
                            }
                        }
                    }
                }
                // curves
                readMotionCurves(variation, atts, rawName + "_");
            // 
            }
        }
    }
}
Also used : XMLAttributes(org.jwildfire.base.Tools.XMLAttributes) XMLAttribute(org.jwildfire.base.Tools.XMLAttribute) MotionCurve(org.jwildfire.create.tina.base.motion.MotionCurve) VariationFuncList(org.jwildfire.create.tina.variation.VariationFuncList) List(java.util.List) Variation(org.jwildfire.create.tina.variation.Variation) Map(java.util.Map) VariationFunc(org.jwildfire.create.tina.variation.VariationFunc)

Example 14 with Variation

use of org.jwildfire.create.tina.variation.Variation in project JWildfire by thargor6.

the class AbstractFlameWriter method createXFormAttrList.

protected List<SimpleXMLBuilder.Attribute<?>> createXFormAttrList(SimpleXMLBuilder pXB, Layer pLayer, XForm pXForm) throws Exception {
    List<SimpleXMLBuilder.Attribute<?>> attrList = new ArrayList<SimpleXMLBuilder.Attribute<?>>();
    attrList.add(pXB.createAttr("weight", pXForm.getWeight()));
    attrList.add(pXB.createAttr("color", pXForm.getColor()));
    attrList.add(pXB.createAttr("symmetry", pXForm.getColorSymmetry()));
    attrList.add(pXB.createAttr(AbstractFlameReader.ATTR_MIRROR_PRE_POST_TRANSLATIONS, pXForm.getMirrorTranslations() ? 1 : 0));
    attrList.add(pXB.createAttr(AbstractFlameReader.ATTR_MATERIAL, pXForm.getMaterial()));
    attrList.add(pXB.createAttr(AbstractFlameReader.ATTR_MATERIAL_SPEED, pXForm.getMaterialSpeed()));
    attrList.add(pXB.createAttr(AbstractFlameReader.ATTR_MOD_GAMMA, pXForm.getModGamma()));
    attrList.add(pXB.createAttr(AbstractFlameReader.ATTR_MOD_GAMMA_SPEED, pXForm.getModGammaSpeed()));
    attrList.add(pXB.createAttr(AbstractFlameReader.ATTR_MOD_CONTRAST, pXForm.getModContrast()));
    attrList.add(pXB.createAttr(AbstractFlameReader.ATTR_MOD_CONTRAST_SPEED, pXForm.getModContrastSpeed()));
    attrList.add(pXB.createAttr(AbstractFlameReader.ATTR_MOD_SATURATION, pXForm.getModSaturation()));
    attrList.add(pXB.createAttr(AbstractFlameReader.ATTR_MOD_SATURATION_SPEED, pXForm.getModSaturationSpeed()));
    attrList.add(pXB.createAttr(AbstractFlameReader.ATTR_MOD_HUE, pXForm.getModHue()));
    attrList.add(pXB.createAttr(AbstractFlameReader.ATTR_MOD_HUE_SPEED, pXForm.getModHueSpeed()));
    if (pXForm.getDrawMode().equals(DrawMode.OPAQUE)) {
        attrList.add(pXB.createAttr("opacity", pXForm.getOpacity()));
    } else if (pXForm.getDrawMode().equals(DrawMode.HIDDEN)) {
        attrList.add(pXB.createAttr("opacity", 0.0));
    }
    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()));
        attrList.add(pXB.createAttr(fName + "_" + AbstractFlameReader.ATTR_FX_PRIORITY, v.getPriority()));
        // 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));
                }
            }
        }
    }
    attrList.add(pXB.createAttr(AbstractFlameReader.ATTR_XY_COEFS, pXForm.getXYCoeff00() + " " + pXForm.getXYCoeff01() + " " + pXForm.getXYCoeff10() + " " + pXForm.getXYCoeff11() + " " + pXForm.getXYCoeff20() + " " + pXForm.getXYCoeff21()));
    if (pXForm.isHasXYPostCoeffs()) {
        attrList.add(pXB.createAttr(AbstractFlameReader.ATTR_XY_POST, pXForm.getXYPostCoeff00() + " " + pXForm.getXYPostCoeff01() + " " + pXForm.getXYPostCoeff10() + " " + pXForm.getXYPostCoeff11() + " " + pXForm.getXYPostCoeff20() + " " + pXForm.getXYPostCoeff21()));
    }
    if (pXForm.isHasYZCoeffs()) {
        attrList.add(pXB.createAttr(AbstractFlameReader.ATTR_YZ_COEFS, pXForm.getYZCoeff00() + " " + pXForm.getYZCoeff01() + " " + pXForm.getYZCoeff10() + " " + pXForm.getYZCoeff11() + " " + pXForm.getYZCoeff20() + " " + pXForm.getYZCoeff21()));
    }
    if (pXForm.isHasYZPostCoeffs()) {
        attrList.add(pXB.createAttr(AbstractFlameReader.ATTR_YZ_POST, pXForm.getYZPostCoeff00() + " " + pXForm.getYZPostCoeff01() + " " + pXForm.getYZPostCoeff10() + " " + pXForm.getYZPostCoeff11() + " " + pXForm.getYZPostCoeff20() + " " + pXForm.getYZPostCoeff21()));
    }
    if (pXForm.isHasZXCoeffs()) {
        attrList.add(pXB.createAttr(AbstractFlameReader.ATTR_ZX_COEFS, pXForm.getZXCoeff00() + " " + pXForm.getZXCoeff01() + " " + pXForm.getZXCoeff10() + " " + pXForm.getZXCoeff11() + " " + pXForm.getZXCoeff20() + " " + pXForm.getZXCoeff21()));
    }
    if (pXForm.isHasZXPostCoeffs()) {
        attrList.add(pXB.createAttr(AbstractFlameReader.ATTR_ZX_POST, pXForm.getZXPostCoeff00() + " " + pXForm.getZXPostCoeff01() + " " + pXForm.getZXPostCoeff10() + " " + pXForm.getZXPostCoeff11() + " " + pXForm.getZXPostCoeff20() + " " + pXForm.getZXPostCoeff21()));
    }
    {
        String hs = "";
        for (int i = 0; i < pLayer.getXForms().size() - 1; i++) {
            hs += pXForm.getModifiedWeights()[i] + " ";
        }
        hs += pXForm.getModifiedWeights()[pLayer.getXForms().size() - 1];
        attrList.add(pXB.createAttr("chaos", hs));
    }
    String xName = pXForm.getName().replaceAll("\"", "");
    if (!xName.equals("")) {
        attrList.add(pXB.createAttr("name", xName));
    }
    List<String> blackList = Collections.emptyList();
    writeMotionCurves(pXForm, pXB, attrList, null, blackList);
    return attrList;
}
Also used : MotionCurveAttribute(org.jwildfire.create.tina.animate.AnimationService.MotionCurveAttribute) ArrayList(java.util.ArrayList) MotionCurve(org.jwildfire.create.tina.base.motion.MotionCurve) Variation(org.jwildfire.create.tina.variation.Variation) VariationFunc(org.jwildfire.create.tina.variation.VariationFunc)

Example 15 with Variation

use of org.jwildfire.create.tina.variation.Variation in project JWildfire by thargor6.

the class Affine3DMutation method apply.

private void apply(Layer pLayer, double pAmount) {
    XForm xForm;
    if (pLayer.getFinalXForms().size() == 0 || Math.random() < 0.5) {
        xForm = pLayer.getXForms().get(Tools.randomInt(pLayer.getXForms().size()));
    } else {
        xForm = pLayer.getFinalXForms().get(Tools.randomInt(pLayer.getFinalXForms().size()));
    }
    if (pLayer.getOwner().isPreserveZ() && Math.random() > 0.25) {
        boolean hasZScale = false;
        for (Variation var : xForm.getVariations()) {
            if (PostZScaleWFFunc.VAR_NAME.equals(var.getFunc().getName())) {
                hasZScale = true;
                break;
            }
        }
        if (!hasZScale) {
            VariationFunc fnc = VariationFuncList.getVariationFuncInstance(PostZScaleWFFunc.VAR_NAME);
            xForm.addVariation(new Variation(0.001 + Math.random() * 0.1, fnc));
        }
    }
    if (Math.random() < 0.5) {
        if (Math.random() < 0.75) {
            if (Math.random() < 0.5) {
                xForm.setXYCoeff00(xForm.getXYCoeff00() + pAmount * (-0.25 + 0.5 * Math.random()));
            }
            if (Math.random() < 0.5) {
                xForm.setXYCoeff01(xForm.getXYCoeff01() + pAmount * (-0.25 + 0.5 * Math.random()));
            }
            if (Math.random() < 0.5) {
                xForm.setXYCoeff10(xForm.getXYCoeff10() + pAmount * (-0.25 + 0.5 * Math.random()));
            }
            if (Math.random() < 0.5) {
                xForm.setXYCoeff11(xForm.getXYCoeff11() + pAmount * (-0.25 + 0.5 * Math.random()));
            }
            if (Math.random() < 0.5) {
                xForm.setXYCoeff20(xForm.getXYCoeff20() + pAmount * (-0.25 + 0.5 * Math.random()));
            }
            if (Math.random() < 0.5) {
                xForm.setXYCoeff21(xForm.getXYCoeff21() + pAmount * (-0.25 + 0.5 * Math.random()));
            }
        } else {
            if (Math.random() < 0.5) {
                xForm.setXYPostCoeff00(xForm.getXYPostCoeff00() + pAmount * (-0.25 + 0.5 * Math.random()));
            }
            if (Math.random() < 0.5) {
                xForm.setXYPostCoeff01(xForm.getXYPostCoeff01() + pAmount * (-0.25 + 0.5 * Math.random()));
            }
            if (Math.random() < 0.5) {
                xForm.setXYPostCoeff10(xForm.getXYPostCoeff10() + pAmount * (-0.25 + 0.5 * Math.random()));
            }
            if (Math.random() < 0.5) {
                xForm.setXYPostCoeff11(xForm.getXYPostCoeff11() + pAmount * (-0.25 + 0.5 * Math.random()));
            }
            if (Math.random() < 0.5) {
                xForm.setXYPostCoeff20(xForm.getXYPostCoeff20() + pAmount * (-0.25 + 0.5 * Math.random()));
            }
            if (Math.random() < 0.5) {
                xForm.setXYPostCoeff21(xForm.getXYPostCoeff21() + pAmount * (-0.25 + 0.5 * Math.random()));
            }
        }
    } else {
        if (Math.random() < 0.33) {
            XFormTransformService.flipHorizontal(xForm, Math.random() < 0.5);
        }
        if (Math.random() > 0.67) {
            XFormTransformService.flipVertical(xForm, Math.random() < 0.5);
        }
        if (Math.random() < 0.75) {
            XFormTransformService.globalTranslate(xForm, -pAmount + 2 * Math.random() * pAmount, -pAmount + 2 * Math.random() * pAmount, Math.random() < 0.5);
        }
        if (Math.random() < 0.5) {
            XFormTransformService.rotate(xForm, -pAmount * 10.0 + 20.0 * Math.random() * pAmount, Math.random() < 0.5);
        }
        if (Math.random() < 0.5) {
            XFormTransformService.scale(xForm, -pAmount + 2 * Math.random() * pAmount, Math.random() < 0.75, Math.random() < 0.75);
        }
    }
}
Also used : XForm(org.jwildfire.create.tina.base.XForm) Variation(org.jwildfire.create.tina.variation.Variation) VariationFunc(org.jwildfire.create.tina.variation.VariationFunc)

Aggregations

Variation (org.jwildfire.create.tina.variation.Variation)26 XForm (org.jwildfire.create.tina.base.XForm)15 VariationFunc (org.jwildfire.create.tina.variation.VariationFunc)9 ArrayList (java.util.ArrayList)5 MotionCurve (org.jwildfire.create.tina.base.motion.MotionCurve)5 List (java.util.List)4 Field (java.lang.reflect.Field)3 Flame (org.jwildfire.create.tina.base.Flame)3 Layer (org.jwildfire.create.tina.base.Layer)3 RGBPalette (org.jwildfire.create.tina.palette.RGBPalette)2 Font (java.awt.Font)1 File (java.io.File)1 ParameterizedType (java.lang.reflect.ParameterizedType)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 JFileChooser (javax.swing.JFileChooser)1 XMLAttribute (org.jwildfire.base.Tools.XMLAttribute)1 XMLAttributes (org.jwildfire.base.Tools.XMLAttributes)1 AnimAware (org.jwildfire.create.tina.animate.AnimAware)1 MotionCurveAttribute (org.jwildfire.create.tina.animate.AnimationService.MotionCurveAttribute)1