Update gradient.class.js

Ok now it works on all cases.