palette-randomize-c!

Synopsis

(palette-randomize-c! palette number)

Parameters

  • palette: A colormap with dimensions 65536x1 or 256x256
  • number: The number of intermediate colors (positive including 0)

Description

This procedure inserts random color pixels at the following positions:

  • At the very beginning of the palette (index 0)
  • At the very end (index 65535)
  • At number random positions in between. If one of the positions is already defined or set (not (rgb 0 0 0)), this position is not altered and left untouched, thus allowing to preset certain positions in the palette.

Side Effects

The palette colormap is changed following the rules above.

Return Value

The palette colormap is also returned and ready for interpolation.

Example

> (define palette (palette-create))
palette
> (palette-randomize-c! palette 5)
#<colormap orow:-1 ocol:-1 xres:-1 yres:-1 w:65536 h:1>
> (palette-writepng palette "palette-rnd.png")
ok
>

The resulting palette displays as follows (note the pixels): palette-rnd.png

> (palette-interpolate! palette)
#<colormap orow:-1 ocol:-1 xres:-1 yres:-1 w:256 h:256>
> (palette-writepng palette "palette-rnd-ip.png")
ok
>

After linear interpolation the palette now displays as follows: palette-rnd-ip.png