This is a related (more general) question to the previous post
Tikz: Drawing a line inside of certain shape
The answer given in the above question works perfectly if the given shape can be described by a single path. However, it doesn't work with any shape containing 2x2 block.
Let me illustrate my problem with the following example.
Like the picture above, I have a connected shape which is a union of square blocks. Now, I want to draw red lines so that these red lines form a "shrinked" version of the shape. However, I can not simply scale the shape as the new shape fomed by red lines is not exactly similar to the original shape.
Here is my code:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw (-3, -3) grid (5, 5);
\draw[dashed, color=red] (0+0.1, 0-0.1) -- (1+0.1, 0-0.1) -- (1+0.1, 2-0.1)-- (2+0.1, 2-0.1) -- (2+0.1, 4-0.1) -- (3-0.1, 4-0.1) -- (3-0.1, 1+0.1) -- (3-0.1, -1+0.1) -- (-0+0.1, -1+0.1) -- (0+0.1, 0-0.1);
\end{tikzpicture}
\end{document}
Although I can manually add or substract a small number to every vertex of the original shape to create red lines, but I am looking for a simpler solution. Thanks in advance.