Search in sources :

Example 11 with RGBColor

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

the class GradientOverlay method pasteRange.

public void pasteRange(RGBPalette pGradient) {
    if (currClipboard != null && currClipboard.length > 0) {
        for (int i = getFrom(); (i <= getTo()) && ((i - getFrom()) < currClipboard.length); i++) {
            RGBColor color = currClipboard[i - getFrom()];
            pGradient.setColor(i, color.getRed(), color.getGreen(), color.getBlue());
        }
    }
}
Also used : RGBColor(org.jwildfire.create.tina.palette.RGBColor)

Example 12 with RGBColor

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

the class GradientOverlay method fadeAll.

public void fadeAll(RGBPalette pGradient) {
    // getFrom();
    int startIdx = 0;
    // getTo();
    int endIdx = GRADIENT_SIZE - 1;
    for (int i = startIdx; i <= endIdx; i++) {
        RGBColor color = pGradient.getRawColor(i);
        if (color.getRed() > 0 || color.getGreen() > 0 || color.getBlue() > 0 || i == endIdx) {
            if (startIdx < i) {
                pGradient.fadeRange(startIdx, i);
                startIdx = i;
            }
        }
    }
}
Also used : RGBColor(org.jwildfire.create.tina.palette.RGBColor)

Example 13 with RGBColor

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

the class MapGradientWriter method getGradientAsMap.

public String getGradientAsMap(RGBPalette pGradient) {
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < RGBPalette.PALETTE_SIZE; i++) {
        RGBColor color = pGradient.getRawColor(i);
        sb.append(alignColValue(color.getRed()));
        sb.append(" ");
        sb.append(alignColValue(color.getGreen()));
        sb.append(" ");
        sb.append(alignColValue(color.getBlue()));
        if (i == 0) {
            sb.append(" \"");
            sb.append(pGradient.getFlam3Name());
            sb.append("\", created with " + Tools.APP_TITLE + " " + Tools.APP_VERSION);
        }
        sb.append("\n");
    }
    return sb.toString();
}
Also used : RGBColor(org.jwildfire.create.tina.palette.RGBColor)

Example 14 with RGBColor

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

the class UgrGradientReader method parsePalette.

private void parsePalette(RGBPalette pPalette, String pUgr) {
    Map<Integer, RGBColor> colors = new HashMap<Integer, RGBColor>();
    StringTokenizer tokenizer = new StringTokenizer(pUgr, " \n\r");
    Pixel pixel = new Pixel();
    while (tokenizer.hasMoreElements()) {
        String token = tokenizer.nextToken();
        String nextToken;
        if (token.startsWith("title=")) {
            StringTokenizer lineTokenizer = new StringTokenizer(token, "\"");
            if (lineTokenizer.hasMoreElements()) {
                lineTokenizer.nextElement();
                if (lineTokenizer.hasMoreElements()) {
                    pPalette.setFlam3Name((String) lineTokenizer.nextElement());
                }
            }
        } else if (token.startsWith("index=") && tokenizer.hasMoreElements() && (nextToken = tokenizer.nextToken()).startsWith("color=")) {
            int index = Integer.parseInt(token.substring(6, token.length()));
            int colorValue = Integer.parseInt(nextToken.substring(6, nextToken.length()));
            pixel.setARGBValue(colorValue);
            RGBColor color = new RGBColor(pixel.b, pixel.g, pixel.r);
            colors.put(index, color);
        }
    }
    boolean doInterpolate = colors.size() < 256;
    boolean doSmooth = pUgr.contains("smooth=yes");
    final int maxIdx = 399;
    if (doInterpolate) {
        if (colors.get(0) == null) {
            colors.put(0, new RGBColor(0, 0, 0));
        }
        if (colors.get(maxIdx) == null) {
            colors.put(maxIdx, new RGBColor(0, 0, 0));
        }
    } else {
        RGBColor lastColor = new RGBColor(0, 0, 0);
        for (int i = 0; i <= maxIdx; i++) {
            RGBColor color = colors.get(i);
            if (color == null) {
                colors.put(i, lastColor);
            } else {
                lastColor = color;
            }
        }
    }
    pPalette.setColors(colors, doInterpolate, doSmooth);
}
Also used : StringTokenizer(java.util.StringTokenizer) HashMap(java.util.HashMap) RGBColor(org.jwildfire.create.tina.palette.RGBColor) Pixel(org.jwildfire.image.Pixel)

Example 15 with RGBColor

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

the class ImgPaletteReader method readPaletteFromMapData.

public List<RGBPalette> readPaletteFromMapData(String pMapData, String pFilename) throws Exception {
    List<RGBPalette> res = new ArrayList<RGBPalette>();
    RGBPalette gradient = new RGBPalette();
    res.add(gradient);
    gradient.setFlam3Name(new File(pFilename).getName());
    SimpleImage img = new ImageReader().loadImage(pFilename);
    if (img.getImageWidth() > 0 && img.getImageHeight() > 0) {
        Map<Integer, RGBColor> colors = new HashMap<Integer, RGBColor>();
        Pixel rgbPixel = new Pixel();
        for (int i = 0; i < img.getImageWidth(); i++) {
            rgbPixel.setARGBValue(img.getARGBValue(i, 0));
            RGBColor color = new RGBColor(rgbPixel.r, rgbPixel.g, rgbPixel.b);
            colors.put(i, color);
        }
        gradient.setColors(colors, false, false);
    }
    return res;
}
Also used : HashMap(java.util.HashMap) RGBPalette(org.jwildfire.create.tina.palette.RGBPalette) SimpleImage(org.jwildfire.image.SimpleImage) ArrayList(java.util.ArrayList) RGBColor(org.jwildfire.create.tina.palette.RGBColor) ImageReader(org.jwildfire.io.ImageReader) File(java.io.File) Pixel(org.jwildfire.image.Pixel)

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