This explains and shows a small Amos program i (Mike) created which loads and examines a guide image the user would create, and generates a set of rainbow instructions to change a color index's RGB value at every scan-line needed to perfectly recreate the colors of the guide image.
You can download the actual Amos program RainbowRipper here: https://drive.google.com/file/d/1YwnW4thNOOSqSjJ7fvgswQ17GnXUK0Rh/view