Dark Bit Factory & Gravity
PROGRAMMING => Freebasic => Topic started by: GfxFreak on August 15, 2012
-
Hi I have a question.
How do you program a line fader effect of oldschool demos?
For i As Integer = 0 To 255
line, (i +20.20) - (i, 30), RGB (r, g, b)
Next
Which algorithm for the colors should I use?
-
You may want to store 2 values for each colour component - the "base" values (which for orange, might be
rBase = 1,
gBase = 0.5,
bBase = 0), and then multiply these base values by the i variable (
rOut = rBase * i,
gOut = gBase * i,
bOut = bBase * i).
This may result in floating point values, so be sure to convert them to integers before applying them as the line colours.
-
Or, exactly the same but using adding
r = 0
g = 0
b = 0
rBase = 1
gbase = 0.5
bBase = 0
For i As Integer = 0 To 255
line, (i +20.20) - (i, 30), RGB (r, g, b)
r = r + rBase
g = g + gBase
b = b + bBase
Next
Jim
-
Thx...
This works so. well ever but I want the color of the left move to the right
-
If you fill in startRGB and endRGB then this will do a line from any colour to any other colour over a number of steps
steps = 255
startR = ?
startG = ?
startB = ?
endR = ?
endG = ?
endB = ?
r = startR
g = startG
b = startB
rBase = (endR - startR) / steps
gBase = (endG - startG) / steps
bBase = (endB - startB) / steps
For i As Integer = 0 To steps
line, (i +20.20) - (i, 30), RGB (r, g, b)
r = r + rBase
g = g + gBase
b = b + bBase
Next
Jim
-
It works perfect jim but i need an animation from left to right :(
-
I believe that this;
http://www.dbfinteractive.com/forum/index.php?topic=1555.msg23684#msg23684
Will give you the effect you're looking for... Just restrict the height to 1 line. :)