Your retina and pupil is being squeezed so much that it is contracting all the colors in the area and transfers it into your eye while you are rubbing them.
This is what I found while searching it.
posted over a year ago
I was told something along that line when I got this big floater - when I closed or moved my eye suddenly, I would get this burst of colours. The doctor explained it as being caused by the shrinking of the eyeball. The same effect could also happen if you have something seriously wrong with the eye.