rigfxlib
This library works on the palette and bitmap objects of Blitz Basic 2.
Most of its commands read or change the colours of a palette object;
they change only the object, so after a change the palette must be
shown again, with Use Palette, ShowPalette or DisplayPalette,
whichever the program uses.
The functions that read a colour (PalRed, AGAPalRed and the others)
and PalAdjust work on the palette chosen last with PaletteInfo.
Call PaletteInfo first: with runtime error checking, these commands
stop with “No palette selected with PaletteInfo” before it, and
without it they read the colours from address 0.
The commands that fill or copy colours name their palettes themselves.
The plain commands use the 4 bit colour values of the original chip
set, 0 to 15; the commands that begin with AGA use 8 bit values, 0 to
255, which only an AGA machine can show in full. Without runtime error
checking, colour numbers are not checked against the size of the
palette, except by CopyColour; with it, the colour functions and
PalAdjust check them too.
A fade to black in 16 steps: palette 0 keeps the colours of a picture, palette 1, of the same size, gets the faded ones and is shown:
LoadPalette 0,"picture.iff"
LoadPalette 1,"picture.iff"
PaletteInfo 0
For i=16 To 0 Step -1
PalAdjust 1,i/16
VWait
Use Palette 1
NextBased on the RI GFX Lib guide by Reflective Images.
Library number 65.
Commands
AGAFillPalette
Like FillPalette, with red, green and blue from 0 to 255.
Statement. Help text: palette#,r,g,b[,start_col,end_col] - fill palette with AGA r,g,b values
2 forms:
.w, .w, .w, .w.w, .w, .w, .w, .w, .w
AGAPalBlue
The blue value, 0 to 255, of a colour of the palette chosen with PaletteInfo.
Function, result .w. Help text: (colour#)
Arguments: .w
AGAPalGreen
The green value, 0 to 255, of a colour of the palette chosen with PaletteInfo.
Function, result .w. Help text: (colour#)
Arguments: .w
AGAPalRed
The red value, 0 to 255, of a colour of the palette chosen with PaletteInfo.
Function, result .w. Help text: (colour#)
Arguments: .w
CopyColour
Copies a colour from one palette to another, or within one palette. As a function it returns -1 on success and 0 if a colour number is negative or not below the number of colours of its palette.
Statement or function, result .l. Help text: sourcepal#,destpal#,colsource#,coldest#
Arguments: .w, .w, .w, .w
CPUCls
Clears all bitplanes of a bitmap with the processor instead of the blitter.
Statement. Help text: bitmap#
Arguments: .l
A bitmap without a first bitplane is left as it is. With runtime error checking, a bitmap of depth 0 or more than 8 is the error “Illegal BitMap Depth”.
FillPalette
Sets all colours of a palette, or the range start_col to end_col, to one colour, with red, green and blue from 0 to 15.
Statement. Help text: palette#,r,g,b[,start_col,end_col] - fill palette with r,g,b values
2 forms:
.w, .w, .w, .w.w, .w, .w, .w, .w, .w
Unlike PalAdjust, this command names its palette itself and does not
use the one of PaletteInfo. A range is not checked against the size
of the palette. An end_col of 0 fills up to the last colour.
MergeBitplanes
Builds a bitmap from the bitplanes of two others. The target bitmap gets the bitplanes of the first source and then those of the second, numplanes planes in all, and the size of the first source.
Statement. Help text: srcbitmap,srcbitmap,destbitmap,numplanes
Arguments: .w, .w, .w, .w
No bitplane is copied: the target uses the memory of the sources, and
freeing the target does not free it. Both sources must be bitmaps in
use and the target a bitmap number not in use; if not, or if
numplanes is larger than the depths of both sources together,
nothing happens.
PalAdjust
Multiplies the colours of the palette chosen with PaletteInfo by a ratio and stores the result in another palette. A ratio below 1 darkens, above 1 brightens, and 1 copies the colours.
Statement. Help text: palette#,ratio.q[,start_col,end_col]
2 forms:
.w, .q.w, .q, .w, .w
The ratio is a quick or a float; each colour value is limited to the
largest value, so a ratio above 1 cannot overflow. The target palette
must have at least as many colours as the source. With start_col
and end_col, only that range is adjusted and stored.
With runtime error checking, PalAdjust before PaletteInfo, a
colour number the source palette does not have, an end_col below
start_col and a target palette too small for the colours written
are runtime errors. Without it, nothing is checked, so that the
command stays fast, for example for a fade in every frame.
PalBlue
The blue value, 0 to 15, of a colour of the palette chosen with PaletteInfo.
Function, result .w. Help text: (colour#)
Arguments: .w
PaletteInfo
Chooses the palette that PalRed, PalGreen, PalBlue, their AGA forms and PalAdjust read from.
Statement. Help text: palette#
Arguments: .l
PalGreen
The green value, 0 to 15, of a colour of the palette chosen with PaletteInfo.
Function, result .w. Help text: (colour#)
Arguments: .w
PalRed
The red value, 0 to 15, of a colour of the palette chosen with PaletteInfo.
Function, result .w. Help text: (colour#)
Arguments: .w
SaveCMAP
Saves a palette as an IFF ILBM file that holds only the colours. As a function it returns -1 if the file was written, and 0 if it was not, if the palette has no data or if there is no memory.
Statement or function, result .l. Help text: palette#,filename$
Arguments: .l, .l
Amiga mode only. The file name is a long, the address of a name that
ends in a zero byte, for example &f$. The library writes the file
with BSave of the AMOS functions library, which must be installed
too. A palette of 0 colours gives a file with an empty colour chunk.