Render a graphical pattern where each pixel is colored by the value of 'x xor y' from an arbitrary color table.

#palletteSize = 128
Procedure.f XorPattern(x, y) ;compute the gradient value from the pixel values
  Protected result = x ! y
  ProcedureReturn Mod(result, #palletteSize) / #palletteSize
EndProcedure
 
Procedure drawPattern()
  StartDrawing(ImageOutput(0))
    DrawingMode(#PB_2DDrawing_Gradient)
    CustomGradient(@XorPattern())
    ;specify a gradient pallette from which only specific indexes will be used
    For i = 1 To #palletteSize 
      GradientColor(1 / i, i * $BACE9B) ; or alternatively use $BEEFDEAD
    Next 
    Box(0, 0, ImageWidth(0), ImageHeight(0))
  StopDrawing()
EndProcedure
 
If OpenWindow(0, 0, 0, 128, 128, "XOR Pattern", #PB_Window_SystemMenu)
  CreateImage(0, WindowWidth(0), WindowHeight(0))
  drawPattern()
  ImageGadget(0, 0, 0, ImageWidth(0), ImageHeight(0), ImageID(0))
  Repeat
    event = WaitWindowEvent(20)
  Until event = #PB_Event_CloseWindow
EndIf