Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Which part gets colored and how can I control it? I have a rounded block and my goal is to have the center filled with a certain color chosen by that parameter. Here's the picture: http://i847.photobucket.com/albums/ab33/Mspb0x/Unbenannt-2_zps90562da3.png

When I draw it with Color.Red for example, just nothing happens. Simply creating the texture in these colors I need won't help, I want to create the colors very dynamic. That's a very simply texture but I also want to apply it on harder ones.

The center is transparent already.

share|improve this question

2 Answers 2

What you would do in this case, is draw a colored rectangle behind this texture first, and then draw this texture on top of the colored texture. This is assuming the center portion of your graphic is transparent.

SpriteBatch.Draw(BlankTexture, new Rectangle(Area, Of, Your, Texture), null, YourColor, 0, Vector2.Zero, SpriteEffects.None, 1);
SpriteBatch.Draw(YourTexture, new Rectangle(Area, Of, Your, Texture), null, Color.White, 0, Vector2.Zero, SpriteEffects.None, 0)

Just make sure your BlankTexture is white, and it should draw to whatever color you specify in your Spritebatch draw call.

share|improve this answer
    
This is right. Trying to colour transparency is the problem. No matter what colour you make it, it's going to be invisible. –  Phil May 11 '13 at 23:21
    
This works very well on simple shapes, but what about a triangle? I figured out changing the center color to something non-transparent does change the color - but it also changes the borders. Two solutions I can think about is setting the color manually with setData or creating a "mask" texture. The mask represents these parts which should get colored inside and gets drawn above the object - and setting the color there should work. On setData I don't know how much performance it will cost. –  Robin Betka May 12 '13 at 10:51
    
The mask option is the better solution. Quicker, and it is what I would do. –  Jon May 12 '13 at 12:34

Which part gets colored and how can I control it?

All of it and you can't unless you make your own shader.

I have a rounded block and my goal is to have the center filled with a certain color chosen by that parameter.

Tinting does not to solve this problem. What you want is making which was covered pretty thoroughly here.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.