It appears to be either a bad graphics card, or bad capacitors on the motherboard.
If you have a non-iSight G5 iMac, you can take the back off your iMac and inspect the capacitors visually. There are 28-30 capacitors standing up off the board like tiny little cylinders. Look for dark spots, bulges, or leaks. If they okay, it's probably the graphics card.
I had a similar situation, and mine was a bad graphics card.
Capacitors can be replaced by an experienced electronics repair person for about $250-$350. The capacitors themselves are cheap, it's the labor.
The graphics card could probably be replaced, but it would be a used replacement part and probably similar costs.
Better to use the money on upgrading to a new computer.