Hexadecimal colours

I just wanted to experiment with generating colours with numbers. I created a function or two which can convert a percentage into a hexadecimal, so that, for example, you could specify 35% red, and receive that value as a hexadecimal.

From this I would like to look at experimenting mathematically with generating different combinations of colours. From there, I wonder if I could create a page which could generate colour themes which look good but which are randomly arrived at. This could then be a good tool in creating mock web pages. I'm sure this already exists in lots of places, but I'm interested in exploring the idea.

In exploring this idea, I created a function which returns a random colour which is then set as the background colour with jquery. I then have a few tables of colours, which generate different colours according to the row and column they are in. Code can be made slightly more efficient, but it's just an experiment.