Hello and welcome.
-Which exact model Mac?
-Which version of OS X?
-Is it totally random, or does it happen when using the same application - i.e. Adobe After Effects?
Normally, that is a sign that the video card or display is failing, but it could be a software issue depending on the answers to the above questions.
C