This article is from the Macintosh hardware FAQ, by Elliotte Rusty Harold email@example.com with numerous contributions by others.
Nine times out of ten this is a symptom of a failing flyback
transformer. It may be accompanied by high-pitched whines and even
the smell of burnt ozone. This is a warning that the demise of the
Mac is imminent! Turn it off and don't use it again till the video
is fixed. If the flyback transformer is in this bad a shape, chances
are that other components either already have failed or soon will.
However many expensive parts of the video subsystem are probably
working just fine so this is one common problem that can often be
fixed much more cheaply by a component-level repair shop than by an
authorized dealer who'll likely swap out the entire video board.