Showing changes from revision #3 to #4:
Added | Removed | Changed
Finding a colour given a particular palette or screen mode is provided via several different SWIs. The list below details the methods of finding the appropriate colour.
Input | Output |
---|---|
Palette entry | Nearest/furthest GCOL |
Palette entry | Nearest/furthest colour number |
Palette entry, mode & palette pointer | Nearest/furthest GCOL |
Palette entry, mode & palette pointer | Nearest/furthest colour number |
ColourTrans SWIs use palette pointers, and the following conventions apply:
Value | Meaning |
---|---|
-1 | Current palette to be used |
0 | Default palette for specified screen mode to be used |
SWIs often use the mode term, and the following conventions apply:
Value | Meaning |
---|---|
-1 | Current mode to be used |
ColourTrans uses a weighted least squares function algorithm to calculate the colour in the palette that most closely matches the specified colour. The algorithm works by calculating the distance between the colours.
Where the desired colour is (Rd, (R Bd, Gd), and the trial colour is (Rt, Bt, Gt), then the distance formula is thus:d, Bd, Gd), and the trial colour is (Rt, Bt, Gt), then the distance formula is thus:
Distance = redweight x (Rt-Rd) (Rt-Rd)2 + greenweight x (Gt-Gd) (Gt-Gd)2 + blueweight x (Bt-Bd) (Bt-Bd)2
Where redweight = 2, greenweight = 4 and blueweight = 1. These weights are set to provide the optimum solution.