public abstract String getName();
public abstract List<RGBColor> generateKeyFrames(int pKeyFrameCount);
public static final RGBPalette generatePalette(List<RGBColor> pKeyFrames, boolean pFadeColors) {
RGBPalette res = new RGBPalette();
if (pKeyFrames.size() == 1) {
RGBColor c = pKeyFrames.get(0);
for (int i = 0; i < RGBPalette.PALETTE_SIZE; i++) {
res.addColor(c.getRed(), c.getGreen(), c.getBlue());
}
}
else {
double idxScl = (double) (RGBPalette.PALETTE_SIZE) / (double) (pKeyFrames.size() - 1);
for (int i = 0; i < RGBPalette.PALETTE_SIZE; i++) {
double x = (double) i / idxScl;
int lIdx = (int) x;
double relX = x - (double) lIdx;
RGBColor lColor = pKeyFrames.get(lIdx);
int r, g, b;
if (pFadeColors) {
RGBColor rColor = pKeyFrames.get(lIdx + 1);
r = Tools.roundColor((double) lColor.getRed() + ((double) (rColor.getRed() - lColor.getRed())) * relX);
g = Tools.roundColor((double) lColor.getGreen() + ((double) (rColor.getGreen() - lColor.getGreen())) * relX);
b = Tools.roundColor((double) lColor.getBlue() + ((double) (rColor.getBlue() - lColor.getBlue())) * relX);
}
else {
r = lColor.getRed();
g = lColor.getGreen();
b = lColor.getBlue();
}
res.addColor(r, g, b);
// System.out.println(i + ": " + r + " " + g + " " + b);
}
}
return res;
}