Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Gradually changing color
Message
From
15/03/2013 22:18:20
 
 
To
15/03/2013 20:57:36
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
01568559
Message ID:
01568564
Views:
62
>I'm doing the running text.
>
>how can I made it change color gradually?
>
>thanks for the help
>
>Jerry


Add eight properties to your form:
(1) color_red
(2) color_grn
(3) color_blu
(4) step_red
(5) step_grn
(6) step_blu
(7) counter = 100
(8) incrementing = .f.

Somewhere (in your timer's Init() event) set those values to your starting colors, and the difference you want to your ending colors, and the number of steps between. Initialize your counter for how many steps you want to fire. Set the timer to fire however often, and execute the code to change the color by a step:
PROCEDURE Timer.Init()
* Assuming you start out with orange RGB(255,192,128) and want to end up with yellow RGB(255,255,0) in 50 steps:
thisForm.color_red = 255
thisForm.color_grn = 192
thisForm.color_blu = 128
thisForm.step_red = (255 - 255) / 50
thisForm.step_grn = (192 - 255) / 50
thisForm.step_blu = (128 - 0) / 50
thisForm.counter = 50
thisForm.incrementing = .f.
Then on your timer event:
PROCEDURE Timer.Timer()
thisForm.color_red = thisForm.color_red + (IIF(thisForm.incrementing, -1, 1) * thisForm.step_red)
thisForm.color_grn = thisForm.color_grn + (IIF(thisForm.incrementing, -1, 1) * thisForm.step_grn)
thisForm.color_blu = thisForm.color_blu + (IIF(thisForm.incrementing, -1, 1) * thisForm.step_blu)
thisForm.lblWhatever.ForeColor = RGB(thisForm.color_red, thisForm.color_grn, thisForm.color_blu)
thisForm.counter = thisForm.counter - 1
IF thisForm.counter = 0
     * Time to trigger the reversal, or to start back over, your choice

     * If starting back over:
     this.init()

     * If going back to the original starting color
     thisForm.counter = 50
     thisForm.incrementing = !thisForm.incrementing
ENDIF
Hope this helps!
Previous
Reply
Map
View

Click here to load this message in the networking platform