Search in sources :

Example 1 with Attribute

use of org.jwildfire.create.tina.io.SimpleXMLBuilder.Attribute in project JWildfire by thargor6.

the class FACLFlameWriter method getFlameXML.

public String getFlameXML(Flame pFlame) throws Exception {
    SimpleXMLBuilder xb = new SimpleXMLBuilder();
    List<SimpleXMLBuilder.Attribute<?>> flamesAttrList = new ArrayList<>();
    flamesAttrList.add(new Attribute<String>("name", ""));
    xb.beginElement("Flames", flamesAttrList);
    // Flame
    List<SimpleXMLBuilder.Attribute<?>> attrList = createFlameAttributes(pFlame, xb);
    Layer layer = pFlame.getFirstLayer();
    xb.beginElement("flame", attrList);
    // XForm
    for (XForm xForm : layer.getXForms()) {
        xb.emptyElement("xform", createXFormAttrList(xb, layer, xForm));
    }
    // FinalXForms
    for (XForm xForm : layer.getFinalXForms()) {
        xb.emptyElement("finalxform", createXFormAttrList(xb, layer, xForm));
    }
    // Gradient
    addGradient(xb, layer);
    xb.endElement("flame");
    xb.endElement("Flames");
    return xb.buildXML();
}
Also used : Attribute(org.jwildfire.create.tina.io.SimpleXMLBuilder.Attribute) XForm(org.jwildfire.create.tina.base.XForm) SimpleXMLBuilder(org.jwildfire.create.tina.io.SimpleXMLBuilder) ArrayList(java.util.ArrayList) Layer(org.jwildfire.create.tina.base.Layer)

Example 2 with Attribute

use of org.jwildfire.create.tina.io.SimpleXMLBuilder.Attribute in project JWildfire by thargor6.

the class FACLFlameWriter method addGradient.

private void addGradient(SimpleXMLBuilder xb, Layer layer) {
    RGBPalette palette = layer.getPalette();
    for (int i = 0; i < 256; i++) {
        List<SimpleXMLBuilder.Attribute<?>> attrList = new ArrayList<>();
        attrList.add(new Attribute<Integer>("index", i));
        String rgbStr = palette.getColor(i).getRed() + " " + palette.getColor(i).getGreen() + " " + palette.getColor(i).getBlue();
        attrList.add(new Attribute<String>("rgb", rgbStr));
        xb.simpleElement("color", null, attrList);
    }
}
Also used : Attribute(org.jwildfire.create.tina.io.SimpleXMLBuilder.Attribute) RGBPalette(org.jwildfire.create.tina.palette.RGBPalette) ArrayList(java.util.ArrayList)

Aggregations

ArrayList (java.util.ArrayList)2 Attribute (org.jwildfire.create.tina.io.SimpleXMLBuilder.Attribute)2 Layer (org.jwildfire.create.tina.base.Layer)1 XForm (org.jwildfire.create.tina.base.XForm)1 SimpleXMLBuilder (org.jwildfire.create.tina.io.SimpleXMLBuilder)1 RGBPalette (org.jwildfire.create.tina.palette.RGBPalette)1