I've made a nice gradient function
set display mode 1024,768,32
sync rate 0
sync on
colour1 = rgb(255,255,255)
colour2 = rgb(0,128,255)
xmax = 1023
for x = 0 to xmax
ink gradc(colour1,colour2,x,xmax),0
box x,0,x,767
next x
sync
wait key
end
rem === FUNCTIONS ===
function gradc(colour1,colour2,i,imax)
rem rules for factoring both colours
f1# = (imax-i)/(imax+.0)
f2# = i/(imax+.0)
rem apply the factoring rules to the colours
r1# = rgbr(colour1)*f1#
g1# = rgbg(colour1)*f1#
b1# = rgbb(colour1)*f1#
r2# = rgbr(colour2)*f2#
g2# = rgbg(colour2)*f2#
b2# = rgbb(colour2)*f2#
rem add the colours together
r = r1# + r2#
g = g1# + g2#
b = b1# + b2#
endfunction rgb(r,g,b)
Now I'm going to see what effects I can add to this.
Are there any speed issues with resizing bitmaps? My first thought is to draw one big title bar (the biggest possible) then squeeze it into any size we need. Alternatively (and I think quite a neat idea) it could only use the part of the title bar image that the title bar is on, i.e. if there is a gradient of white to black from left to right and we have a window on the left of the screen its title bar will be mainly white but if we move it to the right it will become more black.
Or this could be an option for the user.
[edit]
Here's a simple effect made by layering one gradient on top of another.
Takes quite a while to generate on my old PC but I'm guessing this would only need to generate once.
set display mode 1024,768,32
sync rate 0
sync on
colour1 = rgb(255,255,255)
colour2 = rgb(0,128,255)
colour3 = rgb(0,32,64)
xmax = 1023
ymax = 767
cls rgb(255,0,255)
for y = 0 to ymax
for x = 0 to xmax
tempc = gradc(colour1,colour2,y,ymax)
newc = gradc(tempc,colour3,x,xmax)
ink newc,0
dot x,y
next x
next y
sync
wait 10
wait key
end
rem === FUNCTIONS ===
function gradc(colour1,colour2,i,imax)
rem rules for factoring both colours
f1# = (imax-i)/(imax+.0)
f2# = i/(imax+.0)
rem apply the factoring rules to the colours
r1# = rgbr(colour1)*f1#
g1# = rgbg(colour1)*f1#
b1# = rgbb(colour1)*f1#
r2# = rgbr(colour2)*f2#
g2# = rgbg(colour2)*f2#
b2# = rgbb(colour2)*f2#
rem add the colours together
r = r1# + r2#
g = g1# + g2#
b = b1# + b2#
endfunction rgb(r,g,b)
[edit]
Woah! I totally messed up the radial gradient but this is pretty funky
set display mode 1024,768,32
sync rate 0
sync on
colour1 = rgb(255,255,255)
colour2 = rgb(0,128,255)
colour3 = rgb(0,32,64)
xmax = 1023
ymax = 767
cls rgb(255,0,255)
for y = 0 to ymax
for x = 0 to xmax
` tempc = gradc(colour1,colour2,y,ymax)
` newc = gradc(tempc,colour3,x,xmax)
rad = sin(x*(360/(xmax+.0)))*xmax + cos(y*(360/(ymax+.0)))*xmax
radialc = gradc(colour1,colour2,rad,xmax)
ink radialc,0
dot x,y
next x
next y
sync
wait 10
wait key
end
rem === FUNCTIONS ===
function gradc(colour1,colour2,i,imax)
rem rules for factoring both colours
f1# = (imax-i)/(imax+.0)
f2# = i/(imax+.0)
rem apply the factoring rules to the colours
r1# = rgbr(colour1)*f1#
g1# = rgbg(colour1)*f1#
b1# = rgbb(colour1)*f1#
r2# = rgbr(colour2)*f2#
g2# = rgbg(colour2)*f2#
b2# = rgbb(colour2)*f2#
rem add the colours together
r = r1# + r2#
g = g1# + g2#
b = b1# + b2#
endfunction rgb(r,g,b)
[edit]
I am confused, this is as close as I can get to a radial gradient
set display mode 1024,768,32
sync rate 0
sync on
colour1 = rgb(255,255,255)
colour2 = rgb(0,128,255)
colour3 = rgb(0,32,64)
xmax = 1023
ymax = 767
cls rgb(255,0,255)
for y = 0 to ymax
for x = 0 to xmax
` tempc = gradc(colour1,colour2,y,ymax)
` newc = gradc(tempc,colour3,x,xmax)
radx = abs(sin(x*(360/(xmax+.0)))) *90
rady = abs(cos(y*(360/(ymax+.0)))) *90
rad = sin(radx + rady)*ymax
radialc = gradc(colour1,colour2,rad,ymax)
ink radialc,0
dot x,y
next x
next y
sync
wait 10
wait key
end
rem === FUNCTIONS ===
function gradc(colour1,colour2,i,imax)
rem rules for factoring both colours
f1# = (imax-i)/(imax+.0)
f2# = i/(imax+.0)
rem apply the factoring rules to the colours
r1# = rgbr(colour1)*f1#
g1# = rgbg(colour1)*f1#
b1# = rgbb(colour1)*f1#
r2# = rgbr(colour2)*f2#
g2# = rgbg(colour2)*f2#
b2# = rgbb(colour2)*f2#
rem add the colours together
r = r1# + r2#
g = g1# + g2#
b = b1# + b2#
endfunction rgb(r,g,b)
I don't know why I want to do a radial gradient but it would be cool.