Trying to understand using colors!
Harley
Posts: 997
Anyone have a clear explanation for this?
I've been using colors blindly it appears, but was looking at the Hydra volume and trying to relate the 'vgacolors' table (below) from PTP Paint demo with what's described on pg 239, 240 in Fig 14:4 and Table 14:2.
I don't get much of an agreement between the two. Are these referring to the same color codes?
And, with the 16 colors, is it just any 4 of the 16 that are allowed at any one time? Or is there a way to display all 16 colors on a screen?
I've been using colors blindly it appears, but was looking at the Hydra volume and trying to relate the 'vgacolors' table (below) from PTP Paint demo with what's described on pg 239, 240 in Fig 14:4 and Table 14:2.
I don't get much of an agreement between the two. Are these referring to the same color codes?
DAT vgacolors long long $F00CF00C 'blue background with yellow letters long $F0F00C0C long $08A808A8 'green long $0808A8A8 long $50005000 'blue long $50500000 long $FC00FC00 'white long $FCFC0000 long $FF80FF80 'red/white long $FFFF8080 long $FF20FF20 'green/white long $FFFF2020 long $FF28FF28 'cyan/white long $FFFF2828 long $00A800A8 'grey/black long $0000A8A8 long $FFC03000 '16'Colors for Graphics spcl long $F0FF9C0C '17 'Color0 white long $F0C09C0C '18 Color1 red long $F030000C '19 Color2 green long $F000000C '20 Color3 black long $FF0C9C0C '21 fill screen long $000C9C0C '22 clear screen long $FF0C9C0C '23 line mode long $FF0C9C0C '24 dots mode long 0
And, with the 16 colors, is it just any 4 of the 16 that are allowed at any one time? Or is there a way to display all 16 colors on a screen?
Comments
Here's what I understand. (Sorry if you already have figured this out, hopefully it will save someone some time.)
Each set of colors for text color and background color are defined by to longs in the DAT section. The pattern of text color bytes and background color bytes is:
long text, background, text, background
long text, text, background, background
I use the following method to generate the pattern at runtime. This way I can use more than sixteen color combinations. I'm still limited to sixteen combinations per screen but when I change screens after a menu choice I can create a new set of colors to choose from. One reason I like this ability, is I can easily invert the colors of the text and the background to indicate cursor position. (The prefix "F" as in _FRed stands for faint (unsaturated).)
Here's the method I use to built the patterns. I leave color 0 (light blue on dark blue) alone, so I never change more than 15 colors on a page (screen).
The method just takes the parameters of text color and background color and overwites the patterns in the DAT section. I make sure I print all text of one color combination together so I don't use up the sixteen possible color combinations with repeats. (Hence the oldColor variables.)
You can display sixteen colors on the screen. I think PTP_Paint uses some of the colors to display buttons. Notice the colors at "spcl" don't follow the normal pattern illustrated above. You can change these to color patterns of your choosing. (I think changing them will mess up the "buttons" in PTP_Paint.)
Sorry I can't help with the Hydra stuff. I'm going to buy that book one of these days (last time I placed an order with Parallax it was sold out).
There is some reson for the values of each color. As the comments in the VGA object explain there is a binary code discribing the red, green and blue values.
Duane
Re: the Hydra book, it is filled with info; unfortunately the binding isn't very durable and it is a thick book too, making that worse. One has to use iit carefully. LIFE!!
I didn't understand why those two longs
long text, background, text, background
long text, text, background, background
are necessary. I'll have to ponder that for a while. Many thanks for your time.
http://www.rayslogic.com/propeller/Programming/Colors.htm
Harley, make sure you check out the link Rayman gave. It explains a lot.
Thanks for the tip about the Hydra book. I'll be hesitant to loan it out once I buy one. I'm often "pushing" my other Propeller books on to others. I just think Props are so fun and useful, I can't understand when others aren't as anxious to learn about the wonders of the Propeller chip as I am.
Duane
Note: the ROM character bitmaps have two characters per word. So to select the even character you give the colors as FBFB (F=foreground color, B=background color), but for the odd character you give the colors as FFBB.
I reviewed your 16 color code and note there are only 12 colors in the CON and DAT, but the vgacolors and menucolors total 16.
Was there anything missing from them?
I used all of your suggested code in a highly modified PTP Paint demo source. Right now I just put constants in a SetColor(text,background) call. Painful way to view all 16 colors, one at a time, but works.
I only listed 12 colors because that's all I'm using right now. I think there are 64 possible colors. I know I can use 16 different colors on one screen if I limit myself to text. I think there are different rules about colors with graphics. I took out all the graphics stuff from PTP_Paint.
I'm not so sure I had 16 different colors on the screen at once. I had 16 different text and background combinations. I'll have to experiment some more and read Rayman's page about color.
Colors can range from %00000000 ($00) to %11111100 ($FC). The first non black color is %00000100 ($04) (it still looks black to me). The last two bits are ignored (according to Rayman), the first two bits are the red value, the third and fourth bits are the green value and the fifth and sixth bits are the blue values (I learned this from one of the VGA objects, Rayman also has this information). So %00110000 ($30) is all green without any red or blue. So now you can add what ever colors (of the 64) you want to your pallette.
Ah ha:idea:, that's why $FC and $FF look the same. The last two bits are ignored. Thanks Rayman. I understand a little more.
I hope my ramblings aren't making things worse for you Harley. I'm very willing to answer questions, I'm just not sure I'm the one to ask. I am anxious to share what little I have learned.
Propeller are a lot of fun. Thanks Chip.
Duane
$00, $04, $08, $0C, $10, $14, $18, $1C, $20, $24, $28, $2C, $30, $34, $38, $3C, $40, $44, $48, $4C, $50, $54, $58, $5C, $60, $64, $68, $6C, $70, $74, $78, $7C, $80, $84, $88, $8C, $90, $94, $98, $9C, $A0, $A4, $A8, $AC, $B0, $B4, $B8, $BC, $C0, $C4, $C8, $CC, $D0, $D4, $D8, $DC, $E0, $E4, $E8, $EC, $F0, $F4, $F8, $FC
Tah dah. All VGA colors. I should have already known that.
OK, I think I'm getting to understand a bit more about using colors. Before I just used whatever colors the source I was using w/modifications left it; because I just didn't understand what was going on. And, for instance, from the Hydra book, I didn't want to read ALL of that tome just to understand what I needed for my little 'slice' of the world. Though, maybe on the other hand, If I'd at least browsed every page I may have caught something of use (if by then it could all be recalled and pieced together to make sense).
I'm working on displaying as many colors as I can. Will try to get a decent pic of that when done. But, don't hold your breath; the schedule this week is filled with appointments.
I tried to create 16 color boxes. Yes, I get vertical rectangles on the LCD OK, but only two or 4 colors, depending on what I select in and out [gr.color(i) or SetColor(0, i)]. I had four colors at one time. Now only 2 colors.
I must not be using your SetColor PUB properly.
And, that CON set of colors, shouldn't it have some label to reference it sometime? Boy, am I ever 'lost in the woods' of color; and don't even have a compass or paddle!
Sorry, I haven't experimented with the colors using the graphics object. Plain text is enough for my needs right now. From my limited understanding of the material on Rayman's page, you're much more limited in the number of colors available per tile in graphics mode.
I have a Hydra book on the way so ask me again in a year and hopefully I should be able to help.
The color constants do have a label of sorts.
is the same as
So,
is the same as
which calls the method
I've call these variables strings but I'm not sure if that the right term.
Do you know what the code
does? My guess is you do, but if you'd like clarification, let me know.
Sorry if I over simplified, or didn't clarify enough. Let me know if I should go into more detail with the memory location stuff. I'm afraid I'm not much help with using colors with graphics yet.
Duane
After reading and re-reading LaMothe's text over and over, it finally dawned on me there could only be 4 colors at any one time, though there was a pallete of 16 colors to choose any four from. 32 bit LONG holds 4 bytes for the 4 colors. That's it, dummy, 4 colors at any one time.
So decided to not try graphics any more, just do text with background. Here's the result. An index from 0..15 is used for background and index-15 for text. Weird thing is when index goes from 6 to 7 the background on the LCD changes from original black to this light blue. I've yet to figure that one out. (I did note in Graphics object they mask color with 03 so only 4 colors could be used; changing that mask to 0F didn't work.)
Now to play with the text/background color codes to improve the colors, if possible.
I'm working on a menu program for Rayman's PTP. I've almost got a demo finished. I've redone the SetColor method so you don't have to feed it like colored items together. It keeps track of earlier color sets so it doesn't repeat a text and background pair. I hope to have something to post today. I don't have any work to do today on my day job so I can spend most of the day working on this. This is text only I haven't tried using graphics yet.
I'll probably head over to Kinko's (it's not called that any more) and have my Hydra book rebound. Your right about the bad binding. My wife and I could both hear the binding snap crackle and pop as I tried to carefully read it. I really like the content of the book.
Duane
I've been trying to come up with an easy way to create menus. This what I've come up with so far. The Color Menus have several levels. The LED Array menu doesn't have an exit (you'll have to reset the Prop).
I am pleased with the way most of the menu information is contained in the DAT section. I also like the way it automatically keeps track of where the buttons are on each menu. There are still a couple things I'd like to smooth out. Like, how can I include what method I want a button to lead to in the DAT section?
I like the way I can access lists of memory locations without the @@ operator.
Let me know what you think.
Harley, As I mentioned earlier, I've redone the SetColors method. It's more user friendly now.
Check out the colors. There are lots of repeated colors but all 64 colors should be there somewhere.
Most menus can be exited by pressing the top right corner. The blues menu leaves a really small area of the corner.
It was nice to have a day to work on this.
Duane
PTP_TextMenu05b - Archive [Date 2010.08.30 Time 15.50].zip