use of org.jwildfire.create.tina.palette.RGBColor in project JWildfire by thargor6.
the class StrongHueRandomGradientGenerator method generateKeyFrames.
@Override
public List<RGBColor> generateKeyFrames(int pKeyFrameCount) {
HSLPixel hslPixel = new HSLPixel();
Pixel rgbPixel = new Pixel();
List<RGBColor> keyFrames = new ArrayList<RGBColor>();
hslPixel.saturation = Math.random() * 0.1 + 0.8999;
for (int i = 0; i < pKeyFrameCount; i++) {
hslPixel.luminosity = Math.random() * 0.90;
double rnd = Math.random() + Math.random() + Math.random() + Math.random() + Math.random();
if (rnd > 4.0)
hslPixel.hue = 0.8 + (rnd - 4.0) / 7.0;
else if (rnd > 3.0)
hslPixel.hue = 0.2 + (rnd - 3.0) / 7.0;
else if (rnd > 2.0)
hslPixel.hue = 0.0 + (rnd - 2.0) / 7.0;
else if (rnd > 1.0)
hslPixel.hue = 0.6 + (rnd - 1.0) / 7.0;
else
hslPixel.hue = 0.4 + rnd / 7.0;
HSLTransformer.hsl2rgb(hslPixel, rgbPixel);
RGBColor col = new RGBColor(rgbPixel.r, rgbPixel.g, rgbPixel.b);
keyFrames.add(col);
}
return keyFrames;
}
use of org.jwildfire.create.tina.palette.RGBColor in project JWildfire by thargor6.
the class BlackAndWhiteRandomFlameGenerator method postProcessFlameBeforeRendering.
@Override
protected Flame postProcessFlameBeforeRendering(RandomFlameGeneratorState pState, Flame pFlame) {
if (Math.random() < 0.42) {
if (Math.random() < 0.5) {
pFlame.setBgColorType(BGColorType.SINGLE_COLOR);
pFlame.setBgColorRed(0);
pFlame.setBgColorGreen(0);
pFlame.setBgColorBlue(0);
} else {
pFlame.setBgColorType(BGColorType.GRADIENT_2X2);
pFlame.setBgColorRed((int) (Math.random() * 64));
pFlame.setBgColorGreen((int) (Math.random() * 64));
pFlame.setBgColorBlue((int) (Math.random() * 64));
}
List<RGBColor> colors = new ArrayList<RGBColor>();
colors.add(new RGBColor(255, 255, 255));
RGBPalette gradient = RandomGradientGenerator.generatePalette(colors, true, true);
for (Layer layer : pFlame.getLayers()) {
layer.setPalette(gradient);
}
} else {
if (Math.random() < 0.5) {
pFlame.setBgColorType(BGColorType.SINGLE_COLOR);
pFlame.setBgColorRed(255);
pFlame.setBgColorGreen(255);
pFlame.setBgColorBlue(255);
} else {
pFlame.setBgColorType(BGColorType.GRADIENT_2X2);
pFlame.setBgColorRed((int) (255 - Math.random() * 64));
pFlame.setBgColorGreen((int) (255 - Math.random() * 64));
pFlame.setBgColorBlue((int) (255 - Math.random() * 64));
}
List<RGBColor> colors = new ArrayList<RGBColor>();
colors.add(new RGBColor(0, 0, 0));
RGBPalette gradient = RandomGradientGenerator.generatePalette(colors, true, true);
for (Layer layer : pFlame.getLayers()) {
layer.setPalette(gradient);
}
}
pFlame.setGamma(0.45 + Math.random() * 1.5);
pFlame.setGammaThreshold(0.2 * Math.random());
pFlame.setSaturation(1.0);
pFlame.setBrightness(3.0 + Math.random() * 2.0);
pFlame.setContrast(2.5);
pFlame.setBGTransparency(false);
return pFlame;
}
use of org.jwildfire.create.tina.palette.RGBColor in project JWildfire by thargor6.
the class FlameMorphService method morphFlames_morph.
private static Flame morphFlames_morph(Prefs pPrefs, Flame pFlame1, Flame pFlame2, int pFrame, int pFrames) {
if (pFrame < 1 || pFrames < 2)
return pFlame1;
double fScl = (double) (pFrame - 1) / (pFrames - 1);
if (fScl <= MathLib.EPSILON) {
return pFlame1;
} else if (fScl >= 1.0 - MathLib.EPSILON) {
return pFlame2;
}
Flame res = pFlame1.makeCopy();
res.getLayers().clear();
int layerSize1 = pFlame1.getLayers().size();
int layerSize2 = pFlame2.getLayers().size();
int maxLayerSize = layerSize1 > layerSize2 ? layerSize1 : layerSize2;
for (int lIdx = 0; lIdx < maxLayerSize; lIdx++) {
Layer layer = new Layer();
res.getLayers().add(layer);
// Morph layers
if (lIdx < layerSize1 && lIdx < layerSize2) {
Layer layer1 = pFlame1.getLayers().get(lIdx);
Layer layer2 = pFlame2.getLayers().get(lIdx);
layer.assign(layer1);
layer.getXForms().clear();
layer.getFinalXForms().clear();
layer.setWeight(morphValue(layer1.getWeight(), layer2.getWeight(), fScl));
// morph XForms
{
int size1 = layer1.getXForms().size();
int size2 = layer2.getXForms().size();
int maxSize = size1 > size2 ? size1 : size2;
for (int i = 0; i < maxSize; i++) {
XForm xForm1 = i < size1 ? layer1.getXForms().get(i) : null;
if (xForm1 == null) {
xForm1 = new XForm();
xForm1.addVariation(0.0, VariationFuncList.getVariationFuncInstance("linear3D", true));
xForm1.setWeight(0.0);
}
XForm xForm2 = i < size2 ? layer2.getXForms().get(i) : null;
if (xForm2 == null) {
xForm2 = new XForm();
xForm2.addVariation(0.0, VariationFuncList.getVariationFuncInstance("linear3D", true));
xForm2.setWeight(0.0);
}
XForm morphedXForm = morphXForms(pPrefs, xForm1, xForm2, fScl, pFrame, pFrames);
layer.getXForms().add(morphedXForm);
}
}
// morph final XForms
{
int size1 = layer1.getFinalXForms().size();
int size2 = layer2.getFinalXForms().size();
int maxSize = size1 > size2 ? size1 : size2;
for (int i = 0; i < maxSize; i++) {
XForm xForm1 = i < size1 ? layer1.getFinalXForms().get(i) : null;
if (xForm1 == null) {
xForm1 = new XForm();
xForm1.addVariation(0.0, VariationFuncList.getVariationFuncInstance("linear3D", true));
xForm1.setWeight(0.0);
}
XForm xForm2 = i < size2 ? layer2.getFinalXForms().get(i) : null;
if (xForm2 == null) {
xForm2 = new XForm();
xForm2.addVariation(0.0, VariationFuncList.getVariationFuncInstance("linear3D", true));
xForm2.setWeight(0.0);
}
XForm morphedXForm = morphXForms(pPrefs, xForm1, xForm2, fScl, pFrame, pFrames);
layer.getFinalXForms().add(morphedXForm);
}
}
// morph colors
RGBPalette palette1 = layer1.getPalette();
RGBPalette palette2 = layer2.getPalette();
for (int i = 0; i < RGBPalette.PALETTE_SIZE; i++) {
RGBColor color1 = palette1.getColor(i);
RGBColor color2 = palette2.getColor(i);
int red = Tools.roundColor(color1.getRed() + (color2.getRed() - color1.getRed()) * fScl);
int green = Tools.roundColor(color1.getGreen() + (color2.getGreen() - color1.getGreen()) * fScl);
int blue = Tools.roundColor(color1.getBlue() + (color2.getBlue() - color1.getBlue()) * fScl);
layer.getPalette().setColor(i, red, green, blue);
}
} else // fade out layer1 to black
if (lIdx < layerSize1) {
Layer layer1 = pFlame1.getLayers().get(lIdx);
layer.assign(layer1);
layer.setWeight(morphValue(layer1.getWeight(), 0.0, fScl));
} else // fade in layer2 from black
if (lIdx < layerSize2) {
Layer layer2 = pFlame2.getLayers().get(lIdx);
layer.assign(layer2);
layer.setWeight(morphValue(0.0, layer2.getWeight(), fScl));
}
}
// morph camera settings etc.
morphFlameValues(pFlame1, pFlame2, fScl, res);
return res;
}
use of org.jwildfire.create.tina.palette.RGBColor in project JWildfire by thargor6.
the class GradientOverlay method drawGradient.
private void drawGradient(Graphics2D g, RGBPalette pGradient) {
g.setColor(FlamePanelConfig.XFORM_COLOR);
g.drawRect(xMin - 1, yMin - 1, xMax - xMin + 1, yMax - yMin + 2);
for (int i = 0; i < GRADIENT_SIZE; i++) {
int cxMin = xPos[i], cxMax = xPos[i + 1] - 1;
RGBColor color = pGradient.getColor(i);
g.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue()));
for (int cx = cxMin; cx <= cxMax && cx >= xMin && cx <= xMax; cx++) {
g.drawLine(cx, yMin, cx, yMax);
}
}
}
use of org.jwildfire.create.tina.palette.RGBColor in project JWildfire by thargor6.
the class GradientOverlay method drawMarker.
private void drawMarker(Graphics2D g, RGBPalette pGradient, int pMarkerIdx) {
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g.setColor(FlamePanelConfig.XFORM_COLOR);
int mPos = markerPos[pMarkerIdx];
int x = xPos[mPos] + (xPos[mPos + 1] - xPos[mPos]) / 2;
if (x >= xMin && x <= xMax) {
x += 1;
int size2 = GRADIENT_MARKER_SIZE / 2;
int yOff = yMax + 1 + size2;
int[] xPoints = { x - size2 + 1, x, x + size2 - 1 };
int[] yPoints = { yOff + size2, yOff - size2, yOff + size2 };
g.fillPolygon(xPoints, yPoints, xPoints.length);
g.fillOval(x - size2, yOff + size2, 2 * size2, 2 * size2);
markerHandleYMin = yOff - size2;
markerHandleYMax = yOff + size2;
markerColorSelYMin = markerHandleYMax;
markerColorSelYMax = yOff + 3 * size2;
markerXMin[pMarkerIdx] = x - size2;
markerXMax[pMarkerIdx] = x + size2;
RGBColor color = pGradient.getColor(mPos);
g.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue()));
g.fillOval(x - size2 + 2, yOff + size2 + 2, 2 * size2 - 4, 2 * size2 - 4);
}
}
Aggregations