TV Graphics colors
RobertW
Posts: 66
I am trying to understand how the colors are defined.· I have taken the Graphics_Demo.spin as a starting point and made some modifications.· From reading other post on the Forum,·I can see how the following code fills in the colors array:
· 'init colors
· repeat i from 0 to 63
··· colors[noparse][[/noparse]i] := $00001010 * (i+4) & $F + $2B060C02
With is, when I use: gr.color(0), gr.color(1), ..., gr.color(3) I can generate 4 different colors on the screen.· But when I try anything·greater than·a '3' in the gr.colors(x)·operation, the screen just shows black.· If I am understanding the other posts,·only seeing 4 colors is due to each array location containing 4 colors.· I don't understand how I can access the other·color arrays that were defined at the begining of the program.
I am trying to design a model railroad layout display starting with a simple oval.· The oval is broken into 8 different segments that would show the status of that particular section of track (white = no train, green = clear to proceed red = occupied, etc.).
Any help would be appreciated, thank you.
· 'init colors
· repeat i from 0 to 63
··· colors[noparse][[/noparse]i] := $00001010 * (i+4) & $F + $2B060C02
With is, when I use: gr.color(0), gr.color(1), ..., gr.color(3) I can generate 4 different colors on the screen.· But when I try anything·greater than·a '3' in the gr.colors(x)·operation, the screen just shows black.· If I am understanding the other posts,·only seeing 4 colors is due to each array location containing 4 colors.· I don't understand how I can access the other·color arrays that were defined at the begining of the program.
I am trying to design a model railroad layout display starting with a simple oval.· The oval is broken into 8 different segments that would show the status of that particular section of track (white = no train, green = clear to proceed red = occupied, etc.).
Any help would be appreciated, thank you.
Comments
The end goal I have is to build a screen like you are talking about that will show a layout of the track and the different sections of the track will change colors depending on where the train is and which way the switches are flipped.
I am sure there are other people out there with the same idea....
See if this breakdown makes a little more sense.· The demo uses the value of·· ' i·'·· to create a color gradient for the purpose of the demo.
In the example below, I have replaced the gradient with a fixed value for Color 0,1,2, and 3.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
http://www.rayslogic.com/propeller/Programming/GraphicsDemo.htm
I think that might answer your question...
I had just started splashing around in the graphics demo yesterday and so needed the information on that page you linked to.
Edit: Actually, the whole site looks pretty invaluable.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"They may have computers, and other weapons of mass destruction." - Janet Reno
Post Edited (WNed) : 3/6/2009 3:12:34 AM GMT
With the TV graphics, there are a total of 192 graphics-tiles that form a 12 x 16 tile array.· Each graphics-tile is 16 pixels wide by 16 pixels high.· Since there are only 64 available color-tiles you don't have enough color-tiles to fill up all of the graphics-tiles with a unique color-tile.· The solution is to double up with some of the color-tiles.· So for this example I will assign 4 graphics-tiles to 1 color-tile... we'll call it a "quad-tile".
Example 1:
...Ok, in Example1, this just covers the first three "quad-tiles".· To do this for all 48 quad-tiles in this fashion would require a rather large chunk of code, but hopefully you get the idea, and see a pattern.
Figure 1:
Looking at Example 1 at the 'case' pattern and comparing it to Figure 1, you can see that in order to assign the quad-tile to the color-tile 1 you must specify the graphics tiles 0,1,16, and 17 ... likewise for the second quad-tile 2,3,18, and 19 ... and the third quad-tile 4,5,20, and 21.
I mention earlier that this method would require a large portion of code, it's mainly to understand and see what's going on.· A second method, I have come up with fills all 48 quad-tiles and associates them to the corresponding color-tile.· This method is a little bit harder to follow, but it does use an algorithm to generate the same sequence of patterns you see in Example 1 and uses a relatively small amount of code ... i.e. [noparse][[/noparse]0,1,16, and 17], [noparse][[/noparse]2,3,18, and 19], [noparse][[/noparse]4,5,20, and 21], etc.··
Example 2:
I hope that this has helped, and not further confused the matter.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
Post Edited (Beau Schwabe (Parallax)) : 3/6/2009 8:50:25 PM GMT
colors[noparse][[/noparse]0] := $BB_2A_5B_02
|| || || ||
|| || || Color 0 (Black)
|| || Color 1 (Green)
|| Color 2 (Dark Blue)
Color 3 (Red)
colors := $9D_CD_FC_BC
|| || || ||
|| || || Color 0 (Orange)
|| || Color 1 (Purple)
|| Color 2 (Pink)
Color 3 (Yellow)
If yes, how can I change which color tile is being used? For example, if I have a straight line drawn on the screen, and based on a certain condition I would like the line to be green and based on another condition, the line would need to be yellow, which is defined in a different color tile. How would this be done? I have figured out how to draw a line and pull a particular color out of the color tile but, as best as I inderstand the demo program, I am limited to only the 4 colors defined in the color tile. I know that more colors are possible since the demo draws a few graphics with a range of colors but don't know enough on how to get there.
Again, any help is appreciated. Thank you.
Thanks for the link. I will give your program a try. I would still like to learn how to use the graphics.spin program but in the interest of time. I will be sure to see if I can get your program to do what I am looking for. Thanks again.
·
"...do I have to define all 64 tiles? Based on Beau's top most explanation, could I have 2 color tiles?" - No, you do not need to define all 64 color-tiles.· If there are only a few colors that you will be using, then you only need to define the color tiles·you will be using up to 64 of them.
·
"If yes, how can I change which color tile is being used?" - You can redefine just that section of graphics tiles where your line is or you can redefine all 192 graphics tiles by running the " 'init tile screen " once again with the adjusted parameters.
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
Thank you for the additional information. I will give it a try.