Class TPaletteDemo (unit PalDemo) |
TCustomControl
Demostration of palettes and animation in a Delphi component. Copyright © 1997 Tempest Software, Inc. The TPaletteDemo component displays a color gradient, with a user-specified starting and ending color, and number of color steps between them. The gradient works on all systems. The Animate procedure randomly shifts the starting and ending colors, and animates the palette to change the display of the gradient without repainting. Palette animation works only on displays that use a palette, namely, 256-color video adapters.
Constructors |
Functions |
Change the top color.
Properties |
Events |
Variables |
Constructors |
Create and initialize the palette demo control. Initialize the color deltas to random values, but make sure they are at least 1, so the colors really animate. Zero would be boring. Start with 64 steps because most palette devices use 18 bits per pixel, which means 6 bits per color, or 64 distinct colors.
Functions |
Mutate the colors and animate the system palette for those new colors.
Animate the control by mutating the color and then telling Windows to use the new colors.
Destroy the control. Clean up by freeing the palette resource and memory.
Destroy the palette after the control is done using it.
Destroy the palette and free the palette memory.
Delphi calls GetPalette for every control. Return the palette handle to let Delphi take care of selecting and realizing that palette when it paints this control.
Return the palette handle.
Create the gradient palette and return its handle.
Make a gradient palette and return the palette handle. Call this once when initializing the control. After that, just change the palette entries without making a new palette. If the user changes the number of steps, then recreate the palette with a new size.
Randomly mutate the colors and change the palette entries.
Change the colors to animate the palette.
Paint this control by drawing the gradient.
Paint the gradient. Tell Windows to use the palette when painting this control, even if the display does not use a system palette. To do this, we must explicitly select the palette and use PaletteIndex as the color. To paint the gradient, divide the canvas into NumSteps bands, and fill each band with a solid color, chosen from the palette.
Change the colors in the new palette.
Update the palette and tell Windows to use that new palette in the control. You must select the palette before animating it. Note that AnimatePalette does nothing on systems that do not use a display palette (that is, <> 256 colors).
Change the bottom color.
size of LogPal memory
Change the top color.
Change the number of steps in the gradient. Note that this requires rebuilding the palette with a new size.
Properties |
Return the control's canvas.
Events |
Variables |
Delta for changing the color each iteration
Colors for the end pointersin the gradient
The same colors after mutation.
Number of steps in the gradient
handle to the palette
Palette information
pointer to logical palette