Qbasicnews.com

Full Version: Color gradient
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
[Image: block2.jpg]
how can i make a color gradient like that buy using this
Code:
OUT &H3C8, color
OUT &H3C9, #
OUT &H3C9, #
OUT &H3C9, #
Sorry, I don't quite understand what you are asking. You seem to know how to change the pallate.
Code:
OUT &H3C8, ColorToEdit%    
OUT &H3C9, R%                  ' Red value      \
OUT &H3C9, G%                  ' Green value       0 to 63
OUT &H3C9, B%                  ' Blue value     /
This can seem a bit confusing because you don't have to specify whether you are setting red, green or blue. You just have to do each one in order.
Quote:
Code:
OUT &H3C8, ColorToEdit%    
OUT &H3C9, R%                  ' Red value      \
OUT &H3C9, G%                  ' Green value       0 to 63
OUT &H3C9, B%                  ' Blue value     /
This can seem a bit confusing because you don't have to specify whether you are setting red, green or blue. You just have to do each one in order.

I just thought of something...

If each color has 64 different values, then there are 262144 different colors, a bit more than 256... does that mean that there can only be 256 colors in the pallate at once? If that is the case, are pallate swapping tricks used often?
i cant get it to come out like in the picture, all the lines i draw change their color to the new values of OUT &H3C9. so it's all one color.
PlayGGY you're absolutely correct.

Diroga, which screen mode are you talking about? If its screen 13 you have 256 colors while in screen 12 you have only 16 colors.

Could you post the code?
Code:
SCREEN 13

OUT &H3C8, 1 'change color 1
OUT &H3C9, 31
OUT &H3C9, 31
OUT &H3C9, 63
LINE (0, 0)-(200, 100), 1, BF

OUT &H3C8, 1 'change color 1
OUT &H3C9, 0
OUT &H3C9, 0
OUT &H3C9, 0

Output will be a black box on black background, changing the palette changes all colors already drawn on screen as well as the ones going to be drawn.

Code:
SCREEN 13

OUT &H3C8, 1 'change color 1
OUT &H3C9, 31
OUT &H3C9, 31
OUT &H3C9, 63
LINE (0, 0)-(200, 100), 1, BF
waitforkey$ = INPUT$(1)

OUT &H3C8, 1 'change color 1
OUT &H3C9, 0
OUT &H3C9, 0
OUT &H3C9, 0
Diroga: To get the gradient you want try this. Also try to learn how I use it.
Code:
SCREEN 13
'Since we are just changing the red and blue values, the green can
'remain constant.

'We are working down from white, so we start off with all values at 63

r = 0
b = 0
FOR col = 1 TO 255
  r = r + (63 / 255)
  b = b + (63 / 255)
  OUT &H3C8, col
  OUT &H3C9, r
  OUT &H3C9, 63
  OUT &H3C9, b
  LINE (col, 0)-(col, 30), col
NEXT
thanks dark, it makes sence now. i was learned that you had to do it like
Code:
SCREEN 13
FOR r = 1 TO 63
FOR b = 1 TO 63
OUT &H3C8, 1
OUT &H3C9, r
OUT &H3C9, g
OUT &H3C9, b
LINE (r, 0)-(r, 200), 1, BF
NEXT b
NEXT r
or some thing. so i a bit confused why you have
Code:
OUT &H3C8, col
Quote:or some thing. so i a bit confused why you have [code]OUT &H3C8, col

The OUT &HC38 sets the color you are modifying. So what it does is tells the computer the color whose RGB values you want to change and the subsequent OUT statements actually change the RGB values.