Re: Gradient Background??
- Posted by Brian Broker <bkb at CNW.COM> Dec 10, 2000
- 565 views
On Sun, 10 Dec 2000 12:51:55 -0500, Brian wrote: >I'm having a hard time creating a gradient background. I want it to fill in >the background from black at top to a dark blue at the bottom. I keep >getting a "Trying to redefine intY" error. Here's the code I'm using. > >procedure gradientbg() > atom intY > sequence gradcolor > for intY = 1 to 480 by 1 > gradcolor = {0, 0, floor(intY / 480) * 255} > draw_line(gradcolor, {{1, intY},{640, intY}}) > next > end for >End Procedure > >Any ideas why this is happening? > >Draw line repeated 480 times seems a little inefficient. Any ideas on a >better way of doing this? I'm hoping that you are not actually running the above code. - As David mentioned, you don't need to declare loop variables - you don't need to specify "by 1" in your loop, that is the default - you are missing a "do" in your "for" - there is no "next" in Euphoria - in DOS, you have to work with the DOS palette to set your colors Here is a working demo: ------------------------ include graphics.e include get.e -- set graphics mode (missing error message) if graphics_mode( 257 ) then abort(1) end if procedure gradientbg() sequence gradcolor for i = 0 to 63 do -- use palette range 192 (black) to 255 (blue) gradcolor = palette( i+192, {0, 0, i} ) for j = 1 to 8 do draw_line( i+192, {{0, i*8+j},{639, i*8+j}}) end for end for end procedure gradientbg() -- wait for user to end program, look at pretty gradient if wait_key() then abort(0) end if -- restore graphics mode (missing error message) if graphics_mode(-1) then abort(1) end if -- good luck, -- Brian