A programmable collimator for radiotherapy