Minecraft coloured beacons?

Minecraft has coloured beacons but what is the colours bit ratio. You can use 1 block for 16 different colours but you can add 2 blocks to make 240 colours. Is there a limit to the amount of blocks you can put on top of a beacon to have it change colours? Or does it work infinately
Also is there a program to help plan out what colours will be made with what blocks because I need a 396 colour rainbow.

You can put as many blocks as you want as long as they are blocks that do not block beacon light.