0 Members and 1 Guest are viewing this topic.

#### GfxFreak

• ZX 81
• Posts: 7
• Karma: 0
« 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 255line, (i +20.20) - (i, 30), RGB (r, g, b)Next`
Which algorithm for the colors should I use?

#### combatking0

• JavaScript lives!
• Senior Member
• Posts: 4202
• Karma: 183
• Retroman!
« 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:

#### Jim

• Founder Member
• Posts: 5257
• Karma: 394
« Reply #2 on: August 16, 2012 »
Or, exactly the same but using adding

Code: [Select]
`r = 0g = 0b = 0rBase = 1gbase = 0.5bBase = 0For i As Integer = 0 To 255line, (i +20.20) - (i, 30), RGB (r, g, b)r = r + rBaseg = g + gBaseb = b + bBaseNext`
Jim
Challenge Trophies Won:

#### GfxFreak

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

#### Jim

• Founder Member
• Posts: 5257
• Karma: 394
« 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 = 255startR = ?startG = ?startB = ?endR = ?endG = ?endB = ?r = startRg = startGb = startBrBase = (endR - startR) / stepsgBase = (endG - startG) / stepsbBase = (endB - startB) / stepsFor i As Integer = 0 To steps  line, (i +20.20) - (i, 30), RGB (r, g, b)  r = r + rBase  g = g + gBase  b = b + bBaseNext`
Jim
Challenge Trophies Won:

#### GfxFreak

• ZX 81
• Posts: 7
• Karma: 0
« Reply #5 on: August 16, 2012 »
It works perfect jim but i need an animation from left to right

#### Shockwave

• good/evil
• Founder Member
• Posts: 17297
• Karma: 489
• evil/good