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());
}
}
}
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;
}
}
}
}
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();
}
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);
}
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;
}
Aggregations