Here is one way of doing this in ConTeXt. To set the color of a page, we need:
\definebackgrounds[page][background=color, backgroundcolor=...name...]
At each page, the setups
specified in definebackgrounds
are re-evaluated. So, to change the color of each page, we can simply change the value of the background color to a random color. It is easier to do so in Lua. So, here is a complete example:
\startluacode
local random = math.random
local format = string.format
commands.change_color = function()
options = { format("r=%0.3f, g=%0.3f, b=%0.3f", random(), random(), random()) }
context.definecolor( {"randomcolor"}, options)
end
\stopluacode
\startsetups change:color
\ctxcommand{change_color()}
\stopsetups
\setupbackgrounds
[page]
[
background=color,
setups=change:color,
backgroundcolor=randomcolor,
]
% Just to visualize the result
\setuppapersize[A6][A2,landscape]
\setuppaper[nx=5,ny=3]
\setuparranging[XY]
\starttext
\dorecurse{15}{\null\page}
\stoptext
which gives
