[comp.sys.amiga] Novice Intuition Graphics Questions

nor1675@dsacg2.UUCP (Michael Figg) (06/30/88)

What is the preffered way to save workbench/colortable settings before 
changing them in a program. Is there an easy way to save 1 or 2 pen values
(entries) and restore them before termination. It looks like GetRGB4 and
SetRGB4 have conflicting formats. Does the whole colormap need to be saved
and is always 64bytes? (It is 64 isn't it?)

Along the same lines, any ideas on how to do good fades? I would assume cycling
thru desired colorvalues with SetRGB4 would do it but does anything need to
refreshed or relinked after changing the value? 

						     Thanks,

Hot Damm! Grot cakes again. Heavy on the fourty weight.


-- 
"Don't quote me on this!"                      Michael Figg
					       DLA Systems Automation Center
					       Columbus, Oh.
					       (614)-238-9036

peter@sugar.UUCP (Peter da Silva) (07/02/88)

In article <216@dsacg2.UUCP>, nor1675@dsacg2.UUCP (Michael Figg) writes:
> What is the preffered way to save workbench/colortable settings before 
> changing them in a program. Is there an easy way to save 1 or 2 pen values
> (entries) and restore them before termination. It looks like GetRGB4 and
> SetRGB4 have conflicting formats. Does the whole colormap need to be saved
> and is always 64bytes? (It is 64 isn't it?)

OK. You shouldn't be modifying the Workbench colormap. If you want your own
set of colors, you open a new screen with the appropriate number of bitplanes
for the number of colors you want. Then you can SetRGB4 the colors in the new
screen.

You don't have to set them back. When you close the screen it disappears.

> Along the same lines, any ideas on how to do good fades? I would assume cycling
> thru desired colorvalues with SetRGB4 would do it but does anything need to
> refreshed or relinked after changing the value? 

No. The trickyest part about getting fades right is fading down the R, G, and B
values at the same rate. The best way of doing it is to use what I call the
variable duty cycle algorithm... after the article about it in Byte some years
back. Let's say you have N colors you want to fade to black. Here's some
pseudocode. This is written, and adapted to multiple colors, pretty much
from memory. Excuse any errors...

FadeToBlack(colors: integer[M][3], M: integer, faderate: integer):
  counter: integer[M][3];
  initial: integer[M][3];
  maxcolor: integer;

  maxcolor = max(colors);  -- get maximum value of the colors.

  initial = colors;  -- save initial value of all the colors.

  counter = maxcolor;  -- set each counter to maxcolor;

  while not done:
    done = true;
    for each color

nor1675@dsacg2.UUCP (Michael Figg) (07/05/88)

In article <216@dsacg2.UUCP>, nor1675@dsacg2.UUCP (Michael Figg) writes:
> What is the preffered way to save workbench/colortable settings before 
> changing them in a program. Is there an easy way to save 1 or 2 pen values
> (entries) and restore them before termination. It looks like GetRGB4 and
> SetRGB4 have conflicting formats. Does the whole colormap need to be saved
> and is always 64bytes? (It is 64 isn't it?)
> 

As Peter says, I probably shouldn't play around with the WB colors but I am
and for no reasonable purpose either. This is what I've tried.

USHORT  colorsave[4];
 
void main()
{
   .                                 /* Open Libraries and Window */
   .
   for( i=0; i<4; i++)
   {
     colorsave[i] = (USHORT)(*(vp->ColorMap->ColorTable[i]));
     printf("%d = %x\n",i,colorsave[i]);
   }

   (void)demo();                    /* play around with colors and other 
					      things*/
   Wait(1<<wnd->UserPort->mp_SigBit);

   LoadRGB4(vp,colorsave,4);

   (void)CloseWindow(wnd);
}

this gave me a black screen when I closed window and zero values in the 
colorsave table(which I assume gave me the black screen).

I also tried 

     colorsave[i] = GetRGB4(vp->ColorMap,i);

instead of

     colorsave[i] = (USHORT)(*(vp->ColorMap->ColorTable[i]));

This did give me some values in the printf for the first two entries but
zero for the second two. It also gave me a lime green background and gray-
blue text and borders where I had started with a slate gray background and
white letters and borders. To me it looks like both of these approaches 
should do the same thing but neither is doing it. As soon as I figure this
out then I will stop playing with the WB colors, I promise. :-)

					 Thanks,
					   
-- 
"Better graphics with crayons"                 Michael Figg
					       DLA Systems Automation Center
					       Columbus, Oh.
					       (614)-238-9036