1. spirals
- Posted by Vic <cybrgod at IBM.NET>
Feb 22, 1997
-
Last edited Feb 23, 1997
Hello,
Check out this program...neat spiral effect and a good example of palette
rotation.
Sorry, but I don't have many comments in the program...
--------
----------------------------------------------------------------------------
--------
include graphics.e
constant PI=3.14159265359 --pi
--the following constant: the Red, Green, and Blue values
of colors
constant shades={{ 0, 0, 0}, --color 16={0,0,0} BLACK
{ 5, 5, 5}, --color 17={5,5,5}
{ 8, 8, 8}, --18
{11,11,11}, --19
{14,14,14}, --20...
{17,17,17},
{20,20,20},
{24,24,24},
{28,28,28},
{32,32,32},
{36,36,36},
{40,40,40},
{45,45,45},
{50,50,50},
{56,56,56},
{63,63,63}} --color 31 WHITE
integer mode
mode=graphics_mode(19) --320x200x256
function rad(atom theta) --convert radians to degrees
return ((theta*PI)/180)
end function
--========
procedure spiral() --makes the neat spiral
integer x,y
atom deg, radius
for loop1=31 to 16 by -1 do
deg=0
radius=loop1+30 --this value controls how big the circle is, big number
leave holes in the
--circles, wonder why?
while radius>= 0 do
x=floor(radius*cos (rad (deg))) --get the cos in degrees
y=floor(radius*sin (rad (deg))) --get the sin in degrees
pixel (loop1,{x+160,y+100})
deg=deg+0.4
radius=radius-0.0175 --increase or decrease this number!
end while
end for
end procedure
--=========
integer useless
useless=16
--===============
procedure Pal() --fades all the colors to a lower color, ex:20 becomes 19...
object change_palette
useless=16
for loop1=16 to 31 by 1 do
change_palette=palette(loop1,shades[useless])
useless=useless-1
end for
useless=1
end procedure
--===============
procedure Pal2() --opposite of Pal()
object change_palette
useless=1
for loop2=16 to 31 by 1 do
change_palette=palette(loop2,shades[useless])
useless=useless+1
end for
useless=16
end procedure
spiral() --make the spiral
integer key
--==========EXECUTION stars here
while 1 do
text_color(BRIGHT_WHITE)
position(1,8)
puts(1,"You are getting sleepy...")
key=get_key()
if key !=-1 then
if key=27 then
mode=graphics_mode(-1)
abort(1)
end if
end if
Pal() --rotate palette
Pal2() --rotate palette, reversed
--one thing I hate: the flashing WHITE border!, works fine in mode
257 though
end while
----------------------------------------------------------------------------
-----------
end-------------------------------------------------------------------------
-----------
:)
/.ViC./
______________________________________________________________________
| http://www.geocities.com/SiliconValley/Heights/8858/home.htm |
| Veni vidi, vici. Fiat lux. |
|______________________________________________________________________|