// Limit the program to 75 frames per second or less SetFPS 75 // Include the palette Mapping library #Include "PaletteMapping" // ----------------------------------------------------------------- // Set Up Palette -------------------------------------------------- // ----------------------------------------------------------------- // Define a palette array big enough to hold 2^16 colours Dim Palette($10000) // Give palette mapping library address of the palette // we're using. SetPalette(Palette()) // Set Colour 10 as purple colour Palette(10) = RGB(0,0,0) // Set Colour 1024 as purple colour Palette(1024) = RGB(230,40,250) Palette(3333) = RGB(255,60,10) // ----------------------------------------------------------------- // Create a PB image we'll be using as the Palette Mapped Display // ----------------------------------------------------------------- Screen=NewPaletteMapImage(GetScreenWidth(),GetScreenHeight()) Do // direct all Pb rendering to our screen image RenderToImage Screen // Fill The Screen with colour index #10. // CLS doesn't understand palette mapping, so we have to // convert our colur index into RGB form for drawing to // the screen Cls IndexToRgb(10) // Draw Box using colour 1024 from our palette BoxC 200,200,400,300,true,IndexToRGB(1024) // Draw Box using colour 1024 from our palette BoxC 500,100,700,150,true,IndexToRGB(3333) // Read a colour from the surface mx=MouseX() my=MouseY() // read the RGB colour value from the palette mapped screen ThisRGB =Point(mx,my) // Convert the RGB colour back to an Colour/Palette INDEX ColourIndex= RgbToIndex(ThisRGB) // render our palette mapped screen to the actual screen RenderToScreen DrawPaletteMapImage(Screen,0,0) // Show what colour index the mouse is currently over Print "Mouse Over Palette Index #"+Str$(ColourINdex) Print "Actual RGB Value:"+Str$(ThisRGB) // show everything to the user Sync Loop EscKey()=true |