Author Topic: Copperbars - an attempt at least!  (Read 577 times)

0 Members and 1 Guest are viewing this topic.

Offline DrewPee

  • I Toast Therefore I am
  • Pentium
  • *****
  • Posts: 562
  • Karma: 25
  • Eat Cheese - It's good for you!
    • View Profile
    • Retro Computer Museum
Copperbars - an attempt at least!
« on: September 16, 2006 »


Hello again guys.
Cos i understand how the tinyptc library works now ive just knocked this together . . .
Point me in the right direction please if im doing it wrong - Im very happy with it though!
See what you think?

DrewPee
DrewPee
aka Falcon of The Lost Boyz (Amiga)
Ex-Amiga Coder and Graphic Designer
Administrator of > www.retrocomputermuseum.co.uk

Offline MrP

  • Atari ST
  • ***
  • Posts: 176
  • Karma: 18
    • View Profile
Re: Copperbars - an attempt at least!
« Reply #1 on: September 16, 2006 »
Well cant fault that really. They are indeed coppers, or at least as close as you can get to them on the pc......


I've seen your last few posts on here and i'd like to say you seem to be coming on very well indeed, everything you have posted has been a progression from your last effort, keep going like that and you'll soon be on the way to a full blown demo.....
« Last Edit: September 16, 2006 by MrP »

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 16784
  • Karma: 439
  • evil/good
    • View Profile
    • My Homepage
Re: Copperbars - an attempt at least!
« Reply #2 on: September 16, 2006 »
Keep it coming dude, they are indeed copper bar look alikes, add a few more in a sine pattern and a scroll and you have an intro :)
Shockwave ^ Codigos
Challenge Trophies Won:

Offline MrP

  • Atari ST
  • ***
  • Posts: 176
  • Karma: 18
    • View Profile
Re: Copperbars - an attempt at least!
« Reply #3 on: September 16, 2006 »
Heres something I wrote a bit back to generate colors for copper bars.....

change the copper_height variable to determine how wide your bars should be (dont go above 254)

change the r_end, g_end, b_end values to determine the overall copper color

Hope its of some use....

Code: [Select]
'copper color generator - MrP.........

screenres 640, 480, 32, 2, 1, 75
screenset 0, 1
setmouse 0, 0, 0

dim copper_height = 30

dim copper_array(copper_height, 3) as ubyte

r_start = 0     'start rgb values for copper (top and bottom color of bar)
g_start = 0
b_start = 0

r_end = 255     'highest rgb values for copper (middle of bar)
g_end = 0
b_end = 0

r_inc = (r_end - r_start) / (copper_height / 2)      'calculate how much we need to increment each color to get a smooth bar
g_inc = (g_end - g_start) / (copper_height / 2)
b_inc = (b_end - b_start) / (copper_height / 2)

r_value = r_start       'setup the rgb values  for storing into array
g_value = g_start
b_value = b_start

copper_line = 0         'start line of copper in our array

while copper_line < copper_height - 1                   
    copper_array(copper_line, 1) = r_value          'store red component in array
    copper_array(copper_line, 2) = g_value          'store green component in array
    copper_array(copper_line, 3) = b_value          'store blue compnent in array
   
    if copper_line = (copper_height / 2) - 1 then   'check to see if were in the middle of the bar
        r_inc = -r_inc                              'if we are make the color increments negative so we fade back out
        g_inc = -g_inc
        b_inc = -b_inc
    end if

    r_value += r_inc            'add the color increment to rgb colors
    g_value += g_inc
    b_value += b_inc
   
    if r_value > 255 then r_value = 255     'make sure none of them go above 255
    if g_value > 255 then g_value = 255
    if b_value > 255 then b_value = 255
   
    copper_line += 1            'increment our line in the array
wend

while inkey$ = ""
    for copper_y = 0 to copper_height - 1
        for copper_x = 0 to 639
            pset(copper_x, copper_y), rgb(copper_array(copper_y, 1), copper_array(copper_y, 2), copper_array(copper_y, 3))
        next copper_x
    next copper_y
    screensync
    flip
wend
end



Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 16784
  • Karma: 439
  • evil/good
    • View Profile
    • My Homepage
Re: Copperbars - an attempt at least!
« Reply #4 on: September 16, 2006 »
Works fine as long as you don't use an odd number for the bar height :)
Shockwave ^ Codigos
Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 16784
  • Karma: 439
  • evil/good
    • View Profile
    • My Homepage
Re: Copperbars - an attempt at least!
« Reply #5 on: September 16, 2006 »
Here's a fix. Seems to work but I hope I didn't break anything when I was fixing it, I've had a few tonight!

Code: [Select]
'copper color generator - MrP.........

screenres 640, 480, 32, 2, 1, 75
screenset 0, 1
setmouse 0, 0, 0

dim copper_height = 53
'dim shared r_inc,g_inc,b_inc as double
dim copper_array(copper_height, 3) as ubyte

r_start = 0     'start rgb values for copper (top and bottom color of bar)
g_start = 0
b_start = 0

r_end = 255     'highest rgb values for copper (middle of bar)
g_end = 100
b_end = 50

r_inc = (r_end - r_start) / (copper_height / 2)      'calculate how much we need to increment each color to get a smooth bar
g_inc = (g_end - g_start) / (copper_height / 2)
b_inc = (b_end - b_start) / (copper_height / 2)

r_value = r_start       'setup the rgb values  for storing into array
g_value = g_start
b_value = b_start

copper_line = 0         'start line of copper in our array

while copper_line < copper_height - 1                   
    copper_array(copper_line, 1) = r_value          'store red component in array
    copper_array(copper_line, 2) = g_value          'store green component in array
    copper_array(copper_line, 3) = b_value          'store blue compnent in array
   
    'if copper_line = (copper_height / 2)  then   'check to see if were in the middle of the bar
        'r_inc = -r_inc                              'if we are make the color increments negative so we fade back out
        'g_inc = -g_inc
        'b_inc = -b_inc
        'end if
   
if copper_line <= (copper_height / 2)  then
    r_value + = r_inc            'add the color increment to rgb colors
    g_value + = g_inc
    b_value + = b_inc
    else
    r_value - = r_inc            'dec the color increment to rgb colors
    g_value - = g_inc
    b_value - = b_inc
    end if
   
    if r_value > 255 then r_value = 255     'make sure none of them go above 255
    if g_value > 255 then g_value = 255
    if b_value > 255 then b_value = 255
   
    copper_line += 1            'increment our line in the array
wend

while inkey$ = ""
    for copper_y = 0 to copper_height - 1
        for copper_x = 0 to 639
            pset(copper_x, copper_y), rgb(copper_array(copper_y, 1), copper_array(copper_y, 2), copper_array(copper_y, 3))
        next copper_x
    next copper_y
    screensync
    flip
wend
end
Shockwave ^ Codigos
Challenge Trophies Won:

Offline DrewPee

  • I Toast Therefore I am
  • Pentium
  • *****
  • Posts: 562
  • Karma: 25
  • Eat Cheese - It's good for you!
    • View Profile
    • Retro Computer Museum
Re: Copperbars - an attempt at least!
« Reply #6 on: September 16, 2006 »
Thanks for the encouragement guys! Means a lot to a newbie like me . . . and thanks for the code!

DrewPee
DrewPee
aka Falcon of The Lost Boyz (Amiga)
Ex-Amiga Coder and Graphic Designer
Administrator of > www.retrocomputermuseum.co.uk