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