Probably your angle is not 0 to 360 degrees? Anyway finding some problem in your code is sort of difficult without seeing it. laugh