Issue 56 in gnuxaos: Idea for extra palette generation mode

2 views
Skip to first unread message

codesite...@google.com

unread,
Feb 16, 2011, 5:32:12 PM2/16/11
to xaos-...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 56 by rhialto....@gmail.com: Idea for extra palette generation
mode
http://code.google.com/p/gnuxaos/issues/detail?id=56

Suggestion, not a problem:

Once upon a time I made a Mandelbrot generator for the Amiga. (So long ago
that I can't find it on AmiNet any more). I included a wonderful palette
generation option, called Rainbow Mode, which provided very nice gradual
colour ranges.
As far as I can remember and recreate from some code that I'm looking at,
it worked as follows.

There are 3 colour sliders, for Red, Green and Blue (CMY could work too, I
suppose). They range over the palette entries. For the red slider, the
position indicates which palette entry has a maximum red component. The two
palette entries next to it have a slightly lower red component, the 2
entries 1 further away even less, etc, until at some (selectable) distance,
the red component is 0. (Similar for the other 2 colours).

I originally used a linear interpolation between maximum and minimum
component value, but maybe a sinus or something else would work nicely too.

UAE (the Amiga Emulator) seems to crash on me right now, or I'd try to
include a screen shot.

The code which calculates the palette (12 bits per colour, 4 bits per
component):

STATIC ModifyColors()
{
ULONG newred, newgreen, newblue;

newred = ((struct PropInfo *)
ColorTemplateGadgets[COLOR_RED].SpecialInfo)->HorizPot;
newgreen = ((struct PropInfo *)
ColorTemplateGadgets[COLOR_GREEN].SpecialInfo)->HorizPot;
newblue = ((struct PropInfo *)
ColorTemplateGadgets[COLOR_BLUE].SpecialInfo)->HorizPot;

if (RainbowMode) {
USHORT NewPalette[MAXCOL];
SHORT i;
SHORT distance;

for (i=0; i<MAXCOL; i++) NewPalette[i] = 0;
NewPalette[0] = GetRGB4(vp->ColorMap, 0L);
RainbowRMax = (newred * MaxColor + ONE_HALF) >> 16;
RainbowGMax = (newgreen * MaxColor + ONE_HALF) >> 16;
RainbowBMax = (newblue * MaxColor + ONE_HALF) >> 16;

if (RainbowRMax == RRMax && RainbowGMax == RGMax &&
RainbowBMax == RBMax) return;

RRMax = RainbowRMax;
RGMax = RainbowGMax;
RBMax = RainbowBMax;

for (distance=0; distance < RainbowDistance; distance++) {
i = 15 - (16.0 * ((float) distance / RainbowDistance)) + 0.5;
if (i < 0) i = 0;

NewPalette[1 + mod(RainbowBMax + distance, MaxColor)] |= i;
NewPalette[1 + mod(RainbowBMax - distance, MaxColor)] |= i;
i <<= 4;
NewPalette[1 + mod(RainbowGMax + distance, MaxColor)] |= i;
NewPalette[1 + mod(RainbowGMax - distance, MaxColor)] |= i;
i <<= 4;
NewPalette[1 + mod(RainbowRMax + distance, MaxColor)] |= i;
NewPalette[1 + mod(RainbowRMax - distance, MaxColor)] |= i;
}

LoadRGB4(vp, &NewPalette[0], MaxColor + 1L);
} else { /* Normal RGB mode */
SetRGB4(vp, (ULONG) CurrentColor, newred >> 12, newgreen >> 12,
newblue >> 12);
}
}


codesite...@google.com

unread,
Feb 16, 2011, 6:25:00 PM2/16/11
to xaos-...@googlegroups.com

Comment #1 on issue 56 by rhialto....@gmail.com: Idea for extra palette
generation mode
http://code.google.com/p/gnuxaos/issues/detail?id=56

Well, screen shots need not be done only from emulated Amigas :-)

Attachments:
pict3267a.jpg 177 KB
pict3268a.jpg 184 KB

Reply all
Reply to author
Forward
0 new messages