# How do I edit a Texture2D at run-time to visually indicate connected tiles?

I'm making a 2D sandbox game in C# and MonoGame, and I have a couple of tile sprites. These tile are loaded in-game as Texture2Ds. I want to have blocks visually connect to adjacent blocks.

An example:

This is how a tile would look if it was connected to another tile to its right side:

Here's if all of its sides were connected:

If none of its sides were connected at all:

I think you see the idea. Starbound and Terraria do a similar thing.

I don't want to have like 10 different textures for each block for every combination of every side, as that needlessly takes up space.

What can I do in the code to edit my existing sprites to look like this? Am I just better off going with 10 different textures? Or maybe there's something better I've missed?

• Rocking first question! ★ I'd be interested in an answer that actually creates appropriate tile textures at runtime. Then you could even procedurally generate the tile sprites themselves. – Anko Sep 28 '14 at 19:01
• Thanks, for both that comment and editing (nearly my whole post) to make it more understandable. I was a little tired when writing that. – Zambonie Sep 29 '14 at 20:47