Hi pip. There are a few explanations: What they call 'light in the head phenomenon', which usually happens in semi darkness, or a third eye strobe (flash) that can happen anytime.
But if you are looking at designs it's something else, called hypnopompia, and is not that rare if you wake up at the 'right' time. I tend to see geometric patterns in that state too, as opposed to moving scenery when I'm going unconscious.