
//============================================================
//BGColors v1.02
//------------------------------------------------------------
//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've worked hard to write clean, simple and commented 
source code. You are free to look at the source and 
to inspire yourself with it if you want.

   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
--------------------------------------------------------------

   First, you need LiteStep or LiteStep compatible shell
to be installed on your system. Then, you need to load a 
desktop module like jdesk or desktop2.
(This module uses the window of a desktop module to draw
and will not work if no desktop module is loaded.)

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.02

Note : Be sure to load bgcolors after loading your
desktop module if you are using NetLoadModule.

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

That's it, should work now, but there are some details 
you might want to know...

Incompatibility :
Unfortunately for the users of the IconDesk and 
IconDesktop modules, the color effect is drawn over the
icons since they use the same method for drawing.
The LSDesk module also gets drawn over.
But other desktop icon modules like those still work :

deskfolder
folderview
icon


   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 setting higher values in
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 32bits 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.02 : 11 Nov 2003
Code now object based
New source file structure
Added many bang commands
Added many config options
Added logo animation
Added reaction to LM_REFRESH
No known bug left

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

1.00 : 2 nov 2003
Initial release


Config Options :

BGColorsRefreshInterval	50
BGColorsChangeSpeed	5
BGColorsStartValueR	0
BGColorsStartValueG	15
BGColorsStartValueB	45
BGColorsStartValues     0 15 45
BGColorsNoLogo
BGColorsStartPaused


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
;Insane

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 calcul : 
ColorComponement = 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 ChangeSpeed divided by 100 each RefreshInterval
milisecond.
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.


4. BGColorsStartValues

   This does just the same as for number 3 but it changes 
the three values in one line. The order is R G B.
This option will be used instead of the number 3 if both 
are present.

If you know your maths and know which
cycle you want, you can calculate your settings, if not,
here are some that I calculated :

BGColorsStartValues	0 0 0
;They are all the same, so cycle between white and black

BGColorsStartValues	31 0 0
;Gay blue - Red

BGColorsStartValues	31 31 0
;Blue - Yellow

BGColorsStartValues	31 0 31
;Green - Violet

BGColorsStartValues	20 40 0
;Violet - Blue - Green - Yellow - Orange

BGColorsStartValues	20 0 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.


5. BGColorsNoLogo :

   I added a little animation that whows when the module
loads. It consists of the LiteStep Icon and a short about 
string. The logo stretch from the top of the sreen and 
then disapears stretching to the left. The speed at which
the logo is displayed depends on the refreshinterval.
The logo is drawn using double buffering to avoid flikering
so it uses a little more resources but after a few seconds,
when the module disapears, these resources are liberated.
This option tells the module not to show the logo animation
when the module loads. Logo animation can still be shown
anytime (when not paused) with !BGColorsLogo


6. BGColorsStartPaused :

   This tells the module to start in paused mode so
module won't do anything until it receives !BGColorsStart


BANG ! BANG !! Lucky Luke

I added bang modules so you can change all settings on
the fly and even get them back to the original settings
if you don't like your changes. You might also use 
these in scripts for some reason.

Tha list of da Bang Commands :

!BGColorsNewInt 	30
!BGColorsNewSpeed 	20
!BGColorsNewValues	0 15 45
!BGColorsNewValueR	0
!BGColorsNewValueG	15
!BGColorsNewValueB	45
!BGColorsReload
!BGColorsStart
!BGColorsPause
!BGColorsLogo


Details :

1. !BGColorsNewInt :

   Change on the fly the refresh interval so you don't have
to recycle to test settings and may be used in scripts or
something.


2. !BGColorsNewSpeed :

   Change the speed on the fly.


3. !BGColorsNewValues :

   Change the color values on the fly.


4. !BGColorsNewValueR, G and B :

   Change individual color values on the fly.


5. !BGColorsReload :

   Reset the values changed by the previous bang commands
to their value from when module was loaded.


6. !BGColorsStart :

   If module is in paused mode, it will start.


7. !BGColorsPause :

   This will put the module in paused mode so it will not
do anything until it receives !BGColorsStart.

8. !BGColorsLogo :

   Tells the module to display the logo animation.


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

   A trouble with this module is that is has to 
fight with the background to draw (it shows when you drag 
windows and such). Althoug this problem is partly resovled
considering there is almost no flicker when using a high
refresh interval, it would be cool if this simple code could
be added to the a desktop module so that the part that
would draw this color effect would be the background window
and so should redrawing would be faster.

   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 and 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.
(I received nothing yet)

   I've made pretty much all I wanted to do with this module.
I'll release another version only if a bug is found or if
features are proposed. I'm thinking maybe to make a .exe
to do the same with the explorer shell but I'm doubting
the result can be good.

Don't be afraid to give some feedback to me

--= [D4 3ND] =-----------------------------------------------
