Issues with my gradient function

Just making a pretty basic function to draw a gradient from one colour to another over the whole stage. My issue is that I'm using the same script for all of the different parts of the colour but it seems to only work for the hue, could anyone point out to me what i'm doing wrong?
Project link:
Snap! Gradient (berkeley.edu)

alright i worked it out, stupid mistake i was not using the same script for all of them
had to be x2-x1 and i was using x1-x2