Author Topic: Line_Color_Fader problems...  (Read 4838 times)

0 Members and 1 Guest are viewing this topic.

Offline GfxFreak

  • ZX 81
  • *
  • Posts: 8
  • Karma: 0
    • View Profile
Line_Color_Fader problems...
« on: August 15, 2012 »
Hi I have a question.
How do you program a line fader effect of oldschool demos?

Code: [Select]
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?

Offline combatking0

  • JavaScript lives!
  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4569
  • Karma: 235
  • Retroman!
    • View Profile
    • Combat King's Barcode Battler Home
Re: Line_Color_Fader problems...
« Reply #1 on: August 15, 2012 »
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.
You are our 9001st visitor.
Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: Line_Color_Fader problems...
« Reply #2 on: August 16, 2012 »
Or, exactly the same but using adding

Code: [Select]
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
Challenge Trophies Won:

Offline GfxFreak

  • ZX 81
  • *
  • Posts: 8
  • Karma: 0
    • View Profile
Re: Line_Color_Fader problems...
« Reply #3 on: August 16, 2012 »
Thx...
This works so. well ever but I want the color of the left move to the right


Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: Line_Color_Fader problems...
« Reply #4 on: August 16, 2012 »
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
Code: [Select]
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
Challenge Trophies Won:

Offline GfxFreak

  • ZX 81
  • *
  • Posts: 8
  • Karma: 0
    • View Profile
Re: Line_Color_Fader problems...
« Reply #5 on: August 16, 2012 »
It works perfect jim but i need an animation from left to right :(

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17409
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: Line_Color_Fader problems...
« Reply #6 on: August 16, 2012 »
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. :)
Shockwave ^ Codigos
Challenge Trophies Won: