John Kauffman
11-10-2010, 09:46 PM
I am trying to understand how shapes are colored in Graphics_demo.spin. I have broken the PUB start down to a very simple section (other blocks unchanged). Graphics.spin is instantiated as ‘gr’.
'draw small box with text
gr.colorwidth(1,14)
gr.box(-120,0,50,50)
It runs, putting a box on the screen which is tri-colored shades of green.
I am trying to understand the concept of colorwidth. There are no hits in the Help search and the term is not listed in the Prop Manual or the McGraw text. It does not show up in Wikipedia, so I assume it is a Prop-specific concept.
I traced the gr.colorwidth method back to Graphics.spin where there is:
'' Set pixel color and width
color(c)
width(w)
I traced that to graphics.color and get:
'' c - color code in bits[1..0]
setcommand(_color, @colors[c & 3]) 'set color
Traced to SetCommand, I get following, which I am guessing puts the command into the memory of the raster map.
PRI setcommand(cmd, argptr)
command := cmd << 16 + argptr 'write command and pointer
repeat while command 'wait for command to be cleared
I traced the @colors to DAT which is:
colors long %%0000000000000000
long %%1111111111111111
long %%22222222222202222
long %%3333333333333333
Here I get lost. I expected in the DAT something like “red = %10101010”
Question:
How does gr.colorwidth determine the color of the box?
Thanks.
'draw small box with text
gr.colorwidth(1,14)
gr.box(-120,0,50,50)
It runs, putting a box on the screen which is tri-colored shades of green.
I am trying to understand the concept of colorwidth. There are no hits in the Help search and the term is not listed in the Prop Manual or the McGraw text. It does not show up in Wikipedia, so I assume it is a Prop-specific concept.
I traced the gr.colorwidth method back to Graphics.spin where there is:
'' Set pixel color and width
color(c)
width(w)
I traced that to graphics.color and get:
'' c - color code in bits[1..0]
setcommand(_color, @colors[c & 3]) 'set color
Traced to SetCommand, I get following, which I am guessing puts the command into the memory of the raster map.
PRI setcommand(cmd, argptr)
command := cmd << 16 + argptr 'write command and pointer
repeat while command 'wait for command to be cleared
I traced the @colors to DAT which is:
colors long %%0000000000000000
long %%1111111111111111
long %%22222222222202222
long %%3333333333333333
Here I get lost. I expected in the DAT something like “red = %10101010”
Question:
How does gr.colorwidth determine the color of the box?
Thanks.