Shop OBEX P1 Docs P2 Docs Learn Events
Color with the graphics object — Parallax Forums

Color with the graphics object

mcstarmcstar Posts: 144
edited 2006-06-14 05:37 in Propeller 1
I'm looking for some help with getting color to work well on the Graphics object using the TV output.· I've been grappling with trying to get correct colors in the correct place.· Right now I've got some simple sprites defined using a syntax like

wall··················· word
······················· byte··· 1,8,0,17
······················· word··· %%00003300
······················· word··· %%33303330
······················· word··· %%33003300······
······················· word··· %%33303330
······················· word··· %%30003303
······················· word··· %%33303333
······················· word··· %%33003030
······················· word··· %%30000030

This is being displayed with a call to gr.pix(...., @wall)
This is just an adaption of the "dog" from the default graphics demo.· Right now the '0' displays as a black pixel and the 3 displays as a white one.·· A 1 and a 2 display·shades of ·grey pixels.·· If I set gr.color() to a value like $9C then I get colors like blue-green, white and grey.· My question is, how would I display the colors I want for this sprite?· For instance, I'd like the 0's to be maroon and the 3's to be tan, is there a way to do this?·

It appears that 0 is a tranparent pixel, is this correct?
·

Comments

  • cgraceycgracey Posts: 14,133
    edited 2006-06-13 05:52
    Each pixel is two bits, and each 16x16 pixel block on the screen has an associated long that defines 4 colors for that block's pixels. For 256x192 graphics, there are 16x12 of these blocks. The GRAPHICS_DEMO sets up the colors so that for the whole screen %00 is black, %01 is a rainbow pattern that changes with each row of colors, %10 is white, and %11 is blue. You will need to get into that loop that sets the colors and put in the ones you want.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    Chip Gracey
    Parallax, Inc.
  • mcstarmcstar Posts: 144
    edited 2006-06-13 11:22
    This array of 16x12 blocks that define color, is that what's called a "Tile" in the source code? If so it sounds like tile is the smallest block that can have it's own unique color set, correct?
    It sounds like I need to define my own colors for the tiles. How do the longs map to specific colors? Can I just "And" the color values from the graphics pallete demo? In other words, how do I change the %01 value?

    BTW Chip, thanks for all the hard work in make the Propeller a reality. I enjoy programming it more than C#!
  • cgraceycgracey Posts: 14,133
    edited 2006-06-14 05:37
    16 pixel longs plus one color long make up a tile. You're right that every 16x16 pixel tile can only have four unique colors within it. The color long has 4 bytes in it, right? From least- to most-significant, these bytes can be numbered 0..3. Well, those 16 two-bit pixel codes within each pixel long say which of these 0..3 colors that particular pixel is. To reassign the colors, you must write to that list of 192 longs which provide the colors for·the 192 tiles.

    I'm not sure I understand your question about ANDing. When the graphics.spin object affects pixels, it writes both·bits in a pixel at the same time to affect its color. It doesn't do any masking within a pixel, although it does mask 2-bit pixel pairs as it performs read-modify-write operations on your pixel data.
    mcstar said...
    This array of 16x12 blocks that define color, is that what's called a "Tile" in the source code? If so it sounds like tile is the smallest block that can have it's own unique color set, correct?
    It sounds like I need to define my own colors for the tiles. How do the longs map to specific colors? Can I just "And" the color values from the graphics pallete demo? In other words, how do I change the %01 value?

    BTW Chip, thanks for all the hard work in make the Propeller a reality. I enjoy programming it more than C#!
    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    Chip Gracey
    Parallax, Inc.
Sign In or Register to comment.