Fixed the mdgradient code.
P.S. Please, that piece of code is perfectly valid, there's no need to
break it every month. There is nothing wrong with it, still it was
changed (and simultaneously broken) 4 or 5 times already.
That code use a smart trick to draw the multi diagonal gradient using
integer operations, that is perfectly valid and moreover is much faster
than the classical floating point calculation algorithm that was used
before, so there is no need to randomly 'fix' it every now and then.
If you don't understand how it works please ask.