// 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()) // ----------------------------------------------------------------- // Create a PB image we'll be using as the Palette Mapped Display--- // ----------------------------------------------------------------- Width =GetScreenWidth() Height =GetScreenHeight() Screen =NewPaletteMapImage(Width,Height) // direct all Pb rendering to our screen image RenderToImage Screen // calc center of surface CentX = Width/2 CentY = Height/2 WidthMinus1=Width-1 LockBuffer NUllRGb=Point(0,0) // Fill the bank with colour values.. For ylp =0 To CentY-1 // Fill this row of bytes with For Xlp=0 To CEntX Dist#=GetDistance2D(CentX,CentY,xlp,ylp) ColourIndex = 4096-(Dist#*4) PaletteMappedDot Xlp,ylp,ColourIndex PaletteMappedDot WidthMinus1-Xlp,ylp,ColourIndex Next CopyRect Screen,0,Ylp,Width,yLP+1,Screen,0,(Height-1)-Ylp Next UnLockBuffer // init the raster bar colour banks Dim Colours(16) For lp =0 To 15 Colours(lp)=RndRGB() Next // --------------------------------------------------------- // --[ MAIN LOOP ]------------------------------------------ // --------------------------------------------------------- Do // direct all Pb rendering to our screen image RenderToImage Screen // Update the palette Render_Palette() // Read a colour from the surface mx=MouseX() my=MouseY() // read the RGB colour value from the palette mapped screen ThisRGB =Point(mx,my) // Read the Colour Index from the palette mapped screen directly ColourIndex= PaletteMappedPoint(Mx,my) // render our palette mapped screen to the actual screen RenderToScreen DrawPaletteMapImage(Screen,0,0) SetCursor 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 // --------------------------------------------------------- // --[ Render Scrolling Palette ]---------------------------- // --------------------------------------------------------- Psub Render_Palette() // ------------------------------------ // Pick the Palette main colour // ------------------------------------ If ScrollX=0 // pick a random colour that we'll use to seed the palette For lp =15 To 0 Step -1 Colours(lp+1)=Colours(lp) Next Colours(0)=RndRGB() EndIf // ------------------------------------ // Fill the palette with all 256 shades // ------------------------------------ // fill the palette array with all the shades of this colour Offset=ScrollX AngleScale#=(180.0/256) For lp =0 To 255 ; scroll the data in the palette array to create motion Level=Sin(AngleScale#*lp)*100 For ColourBank=0 To 16 ThisColour =Colours(ColourBank) Palette(ColourBank*256+offset)=RGBFade(ThisCOlour,Level) Next offset++ Next // current offset the of the scrolling palette ScrollX=(ScrollX+2) And 255 EndPsub |