Search in sources :

Example 16 with RGBColor

use of org.jwildfire.create.tina.palette.RGBColor in project JWildfire by thargor6.

the class MapGradientReader method readPaletteFromMapData.

public List<RGBPalette> readPaletteFromMapData(String pMapData, String pFilename) {
    List<RGBPalette> res = new ArrayList<RGBPalette>();
    RGBPalette gradient = new RGBPalette();
    res.add(gradient);
    gradient.setFlam3Name(new File(pFilename).getName());
    StringTokenizer tokenizer = new StringTokenizer(pMapData, "\n\r");
    int idx = 0;
    Map<Integer, RGBColor> colors = new HashMap<Integer, RGBColor>();
    while (tokenizer.hasMoreElements()) {
        String line = tokenizer.nextToken();
        StringTokenizer lineTokenizer = new StringTokenizer(line, "\t ");
        int r, g, b;
        try {
            r = Integer.parseInt(((String) lineTokenizer.nextElement()).trim());
            g = Integer.parseInt(((String) lineTokenizer.nextElement()).trim());
            b = Integer.parseInt(((String) lineTokenizer.nextElement()).trim());
        } catch (Exception ex) {
            break;
        }
        if (r >= 0 && r <= 255 && g >= 0 && g <= 255 && b >= 0 && b <= 255) {
            RGBColor color = new RGBColor(r, g, b);
            colors.put(idx++, color);
        } else {
            break;
        }
    }
    gradient.setColors(colors, false, false);
    return res;
}
Also used : StringTokenizer(java.util.StringTokenizer) HashMap(java.util.HashMap) RGBPalette(org.jwildfire.create.tina.palette.RGBPalette) ArrayList(java.util.ArrayList) RGBColor(org.jwildfire.create.tina.palette.RGBColor) File(java.io.File)

Example 17 with RGBColor

use of org.jwildfire.create.tina.palette.RGBColor in project JWildfire by thargor6.

the class SmoothRandomGradientGenerator method generateKeyFrames.

@Override
public List<RGBColor> generateKeyFrames(int pKeyFrameCount) {
    List<RGBColor> keyFrames = new ArrayList<RGBColor>();
    int lastR = 0, lastG = 0, lastB = 0;
    int r, g, b;
    for (int i = 0; i < pKeyFrameCount; i++) {
        while (true) {
            r = Tools.roundColor(256.0 * Math.random());
            g = Tools.roundColor(256.0 * Math.random());
            b = Tools.roundColor(256.0 * Math.random());
            double diff = Math.abs(r - lastR) * 0.299 + Math.abs(g - lastG) * 0.588 + Math.abs(b - lastB) * 0.1130;
            if (diff > 66)
                break;
        }
        RGBColor col = new RGBColor(r, g, b);
        lastR = r;
        lastG = g;
        lastB = b;
        keyFrames.add(col);
    }
    return keyFrames;
}
Also used : RGBColor(org.jwildfire.create.tina.palette.RGBColor) ArrayList(java.util.ArrayList)

Example 18 with RGBColor

use of org.jwildfire.create.tina.palette.RGBColor in project JWildfire by thargor6.

the class GradientOverlay method gradientMarker_selectColor.

public boolean gradientMarker_selectColor(int marker, RGBPalette pGradient) {
    if (marker >= 0) {
        ResourceManager rm = ResourceManager.all(FilePropertyEditor.class);
        String title = rm.getString("ColorPropertyEditor.title");
        RGBColor color = pGradient.getColor(markerPos[marker]);
        Color selectedColor = JColorChooser.showDialog(parent, title, new Color(color.getRed(), color.getGreen(), color.getBlue()));
        if (selectedColor != null) {
            pGradient.setColor(markerPos[marker], selectedColor.getRed(), selectedColor.getGreen(), selectedColor.getBlue());
            return true;
        }
    }
    return false;
}
Also used : Color(java.awt.Color) RGBColor(org.jwildfire.create.tina.palette.RGBColor) RGBColor(org.jwildfire.create.tina.palette.RGBColor) ResourceManager(com.l2fprod.common.util.ResourceManager)

Example 19 with RGBColor

use of org.jwildfire.create.tina.palette.RGBColor in project JWildfire by thargor6.

the class FlameControlsDelegate method randomizeLightColor.

public void randomizeLightColor() {
    DistantLight light = getSolidRenderingSelectedLight();
    if (light != null) {
        owner.undoManager.saveUndoPoint(getCurrFlame());
        List<RGBColor> rndColors = new AllRandomGradientGenerator().generateKeyFrames(7);
        RGBColor rndColor = rndColors.get((int) (Math.random() * rndColors.size()));
        Color selectedColor = new Color(rndColor.getRed(), rndColor.getGreen(), rndColor.getBlue());
        setLightColor(light, selectedColor);
    }
}
Also used : AllRandomGradientGenerator(org.jwildfire.create.tina.randomgradient.AllRandomGradientGenerator) Color(java.awt.Color) RGBColor(org.jwildfire.create.tina.palette.RGBColor) Stereo3dColor(org.jwildfire.create.tina.base.Stereo3dColor) RGBColor(org.jwildfire.create.tina.palette.RGBColor) DistantLight(org.jwildfire.create.tina.base.solidrender.DistantLight)

Aggregations

RGBColor (org.jwildfire.create.tina.palette.RGBColor)19 ArrayList (java.util.ArrayList)8 RGBPalette (org.jwildfire.create.tina.palette.RGBPalette)5 Pixel (org.jwildfire.image.Pixel)5 Color (java.awt.Color)4 HashMap (java.util.HashMap)3 HSLPixel (org.jwildfire.transform.HSLTransformer.HSLPixel)3 File (java.io.File)2 StringTokenizer (java.util.StringTokenizer)2 Layer (org.jwildfire.create.tina.base.Layer)2 ResourceManager (com.l2fprod.common.util.ResourceManager)1 Flame (org.jwildfire.create.tina.base.Flame)1 Stereo3dColor (org.jwildfire.create.tina.base.Stereo3dColor)1 XForm (org.jwildfire.create.tina.base.XForm)1 DistantLight (org.jwildfire.create.tina.base.solidrender.DistantLight)1 AllRandomGradientGenerator (org.jwildfire.create.tina.randomgradient.AllRandomGradientGenerator)1 SimpleImage (org.jwildfire.image.SimpleImage)1 ImageReader (org.jwildfire.io.ImageReader)1