
//============================================================
//BGColors v1.01
//------------------------------------------------------------
//Filename 	:	bgcolors.dll
//Author	:	Antoine W. Campagna  aka  AntAgna
//E-Mail	:	AntoineW@Campagna.org

//	This LiteStep module displays cool Colors in 
//	the background.


//--= CONTENTS =----------------------------------------------
   I:	Introduction/Disclamer
   II:	Installation and Loading
   III:	Changes/Configuration
   IV:	Future
--------------------------------------------------------------


--------------------------------------------------------------
I: Introduction/Disclamer
--------------------------------------------------------------

   I've always like the possibilities the Windows GDI 
interface has and I've tried many things with it. It
is really easy to display changing colors in a window. 
And by using a Sinusoidal function, we can have wonderful
color cycles.

   And one day, I thought that drawing these colors onto the
background would have a cool effect. So I looked at how I 
could do this and I did it.

   This module should work on most LiteStep versions and 
on any version of Windows. It should also use less 
than 5%	of your cpu time even on old computers and with 
really high resolutions. The module adapts itself to 
resolution changes after a few seconds.

   I would like to be advised of any bug, suggestion,
comments, etc... by Mail : AntoineW@Campagna.org

As necessary ... 

Copyright (C) 2003, Antoine W. Campagna

   This piece of software is provided "as is" and without
any warranty. The author can not be liable for any claim 
relied with this piece of software.


--------------------------------------------------------------
II: Installation and Loading
--------------------------------------------------------------

   Just place the BGColors.dll file in your LiteStep module
directory and add this line in your step.rc confing file :

LoadModule $ModulesDir$BGColors.dll

   There was a bug in the first release that made the module
load incorectly when using NetLoadModule. This is 
corrected now so if you are using an OTS2 compliant 
LiteStep distribution, instead of using the above
line, you can load it like this :

*NetLoadModule bgcolors-1.01

More details on OTS2 and NetLoadModule here : 
http://o-t-s.sourceforge.net/

   It is preferable to disable the background picture
from the display options of Windows and use a plain color
instead, it will draw faster. Setting your screen refresh
rate higher will give a better effect (especially when
changing the config options). You can change your
screen refresh rate in the advanced options of the Windows
Display settings or by using the module razrez-0.4.
Setting your color depth to 32 will improve dramatically
the visual quality. On lower color depths, the color
change will be less fluid (the effect on a color depth
of 16 colors is quite funny). The color depth can also
be changed in the Windows Display setting or with
the razrez-0.4 module.


--------------------------------------------------------------
III: Changes/Configuration
--------------------------------------------------------------

History :

1.01 :
NetLoadModule bug corrected
Major code rewrite
5 config options added
Many minor bug fixes
Added reaction to LM_GETREVID

1.00 : 
Initial release

There was a bug when loaded with NetLoadModule so I rewrote
most of the code. The code is a lot more clean and a lot more
like the code a LiteStep module should be like, sort of. And
somehow, it looks like it uses even less CPU time now.

I also added these configuration settings :
(The values indicated here are the default ones)

BGColorsRefreshInterval	50
BGColorsChangeSpeed	5
BGColorsStartValueR	0
BGColorsStartValueG	15
BGColorsStartValueB	45

Now the details :

1. BGColorsRefreshInterval :

   Values allowed : 1 to 1000

   This is the interval in milisecond at which the screen
is redrawn with a new color. Lower values will increse speed
but might use more CPU time. High values will slow the speed
so it will use less CPU time but reaction time when windows
are moved around the screen will also increase. 5 is a good
value if you have a fast computer and you really want the
screen to be refreshed often. A better setting for a 
non-maniac user would be between 20 and 60. Values of over
300 are not recommended since the background is not
redraw often enough. Values under 5 will look quite like
with a value of 5.

2. BGColorsChangeSpeed :

   Values allowed : 1 to 1000

   This is the speed at which the color changes. Higher
values increase the speed. A value of 1 is really slow
and the change of color will be slow even with a refresh
interval of 1. A value of 20 is faster but still very fluid.
Values of over 40 starts to be less fluid but can still
appear fluid if you use a low refresh interval. Values
over 160 are not fluid but can still be used if you want
to give a flashy effect.

Recommended settings :

The default value does just what I wanted the module to do.
But by changing these values, you might get a different but
still very cool effect, try these :

BGColorsRefreshInterval 1000
BGColorsChangeSpeed 	1000
;Looks like a random color every second

BGColorsRefreshInterval 100
BGColorsChangeSpeed 	1
;Extremely slow color change

BGColorsRefreshInterval 20
BGColorsChangeSpeed 	40
;Rapid color change

BGColorsRefreshInterval 5
BGColorsChangeSpeed 	100
;Extremely rapid color change

BGColorsRefreshInterval 5
BGColorsChangeSpeed 	350
;Unbearable

3. BGColorsStartValueR , G and B

   Values allowed : 1 to 61

   These are the start point of the color componements. These
values will be divided by 10 and used to calculate the 
0 to 255 color componement value using this : 
sin(SV / 10 + I) * 255
where sin is the radian sinusoidal function, SV is the start
value and I is the increment that starts at 0 and goes up by
steps of RefreshInterval divided by 100.
Note that a value of 62 is the equivalent of 0 (2 * pi * 10).
This means that changing this will change the color that
appears initially and will also change the color cycle. The
change in the color cycle will depend on the difference
between the 3 values. If you know your maths and know which
cycle you want, you can calculate your settings, if not,
here are some that I calculated :

BGColorsStartValueR	0
BGColorsStartValueG	0
BGColorsStartValueB	0
;They are all the same, so cycle between white and black

BGColorsStartValueR	31
BGColorsStartValueG	0
BGColorsStartValueB	0
;Gay blue - Red

BGColorsStartValueR	31
BGColorsStartValueG	31
BGColorsStartValueB	0
;Blue - Yellow

BGColorsStartValueR	31
BGColorsStartValueG	0
BGColorsStartValueB	31
;Green - Violet

BGColorsStartValueR	20
BGColorsStartValueG	40
BGColorsStartValueB	0
;Violet - Blue - Green - Yellow - Orange

BGColorsStartValueR	20
BGColorsStartValueG	0
BGColorsStartValueB	40
;Yellow - Grean - Blue - Violet - Orange 

Other settings will give other effects, play with it as
you like and keep the settings you like best.

--------------------------------------------------------------
IV:  Future
--------------------------------------------------------------

   The biggest trouble with this module is that is has to 
fight with LiteStep to draw the backgroud (it shows when 
you drag windows and such). It would be cool if this simple
code could be added to the core of LiteStep so that the part
that would draw this color effect would be the background 
window of LiteStep.

   The second trouble is the GDI brushes cleaning that needs
to be done. A new brush has to be created each time the module
draws to the screen. I am currently using the FillRect 
function from the GDI to draw to the screen. But this function
doesn't like to have its brush cleaned or something.
So I found an ugly way to make it work correctly. I'll look
for a less ugly way soon. I would like to receive comments
from people who have Ideas on how I could do this.

   Now that I've added the configuration options, I'd like
to be able to change these options via bang commands. This
shouldn't be hard to do. I have corrected a few small bugs
from the previous version but it seems that there are still
some that remains. I saw once ore twice other modules not
drawing themselves correctly and even my module drawing
on top of everything.


--= [THE END] =-----------------------------------------------
