In principle, moving the GScript to outside the function declaration will speed up compilation of the function calls (and hence script loading), but the difference is unlikely to be noticeable. It doesn't affect the 'run-time' - GScript acts purely at 'compile-time'.
I'm not sure if the slowness here comes from the StackVertical or the Spline function - I will look into it and see if it can be made faster in some way.
In your code
Code:
r=int(spline(i,0,ared,int(gheight/2),bred,gheight,cred,true)/float(gheight)*255)
... etc ...
why do you effectively multiply by 255/gheight?
I get better results with just r=int(spline(...))