# Drawing Königsberg landscape showing the bridges

Just for fun, I was trying to draw the picture (which I found here):

However, I don't know how to create irregular shapes in tikz. Can anybody help?

-
Some ideas using random decorations: decorating-with-random-steps-a-filling-pattern, torn-paper-matching-up-the-torn-edges –  Ignasi Jun 9 at 6:04
By irregular you mean those "jagged" edges? Or you mean non-rectangular, non-ellipse shapes? For the first, the comment of Ignasi applies. For the second, you can use a path composed by a sequence of coordinates, joining them with -- and using "rounded corners", or you can use plot coordinates and a sequence of coordinates, using smooth option, or you can use hooby package which allows metapost syntax and results for a smooth curve passing throug a sequence of points. –  JLDiaz Jun 9 at 7:20
@JLDiaz Thank you. I mean non-rectangular, non-ellipse shapes. I am working on it. –  pushpen.paul Jun 9 at 8:22
Have a look at control points and tension parameter. –  Trefex Jun 9 at 8:32

Here is a possible reproduction of your figure.

I just scaled the image up, and manually traced coordinates (pixels) of the contours in Gimp, and then filled the necessary areas. The code is long, and it is not very nice. :)

\documentclass{article}

\usepackage{xcolor}

\usepackage{tikz}

\usetikzlibrary{decorations.pathmorphing, calc}

\definecolor{land}{HTML}{95EA64}
\definecolor{water}{HTML}{BBE0E3}
\definecolor{bridge}{HTML}{FEFF9E}

\tikzset{%
contour/.style={%
very thick,%
decoration={%
random steps,%
segment length=4pt,%
amplitude=0.5pt%
},%
rounded corners=1pt,%
decorate%
}%
}

\begin{document}

\begin{tikzpicture}[x=10cm, y=9.19cm]
%\node[anchor=south west,inner sep=0, outer sep=0] (image) at (0,0)
%   {\includegraphics[width=10cm, height=9.19cm]{OOeXi.png}};

%water
\filldraw[water] (0, 0) -- (0, 1) -- (1, 1) -- (1, 0) -- cycle;

%bridge top 1
\filldraw[bridge] ($(0, 1) + (0.329, -0.300)$) --
($(0, 1) + (0.423, -0.301)$) -- ($(0, 1) + (0.399, -0.399)$) --
($(0, 1) + (0.328, -0.404)$) -- cycle;
\draw[contour] ($(0, 1) + (0.423, -0.301)$) -- ($(0, 1) + (0.399, -0.399)$)
($(0, 1) + (0.328, -0.404)$) -- ($(0, 1) + (0.329, -0.300)$);

%bridge top 2
\filldraw[bridge] ($(0, 1) + (0.532, -0.302)$) --
($(0, 1) + (0.558, -0.310)$) -- ($(0, 1) + (0.591, -0.338)$) --
($(0, 1) + (0.609, -0.404)$) -- ($(0, 1) + (0.549, -0.388)$) --
cycle;
\draw[contour] ($(0, 1) + (0.591, -0.338)$) -- ($(0, 1) + (0.609, -0.404)$)
($(0, 1) + (0.532, -0.302)$) -- ($(0, 1) + (0.549, -0.388)$) ;

%bridge top 3
\filldraw[bridge] ($(0, 1) + (0.635, -0.328)$) --
($(0, 1) + (0.656, -0.304)$) -- ($(0, 1) + (0.669, -0.276)$) --
($(0, 1) + (0.796, -0.364)$) --
($(0, 1) + (0.776, -0.396)$) -- ($(0, 1) + (0.762, -0.420)$) -- cycle;
\draw[contour] ($(0, 1) + (0.635, -0.328)$) -- ($(0, 1) + (0.762, -0.420)$)
($(0, 1) + (0.669, -0.276)$) -- ($(0, 1) + (0.796, -0.364)$);

%bridge middle right
\filldraw[bridge] ($(0, 1) + (0.658, -0.590)$) --
($(0, 1) + (0.668, -0.546)$) -- ($(0, 1) + (0.778, -0.524)$) --
($(0, 1) + (0.792, -0.554)$) -- ($(0, 1) + (0.796, -0.590)$) --cycle;
\draw[contour] ($(0, 1) + (0.668, -0.546)$) -- ($(0, 1) + (0.778, -0.524)$)
($(0, 1) + (0.658, -0.590)$) -- ($(0, 1) + (0.796, -0.590)$);

%bridge bottom 1
\filldraw[bridge] ($(0, 1) + (0.350, -0.826)$) --
($(0, 1) + (0.410, -0.804)$) -- ($(0, 1) + (0.422, -0.794)$) --
($(0, 1) + (0.412, -0.708)$) -- ($(0, 1) + (0.372, -0.702)$) --
($(0, 1) + (0.336, -0.695)$) -- cycle;
\draw[contour] ($(0, 1) + (0.422, -0.794)$) -- ($(0, 1) + (0.412, -0.708)$)
($(0, 1) + (0.350, -0.826)$) -- ($(0, 1) + (0.336, -0.695)$);

%bridge bottom 2
\filldraw[bridge] ($(0, 1) + (0.596, -0.700)$) --
($(0, 1) + (0.535, -0.708)$) -- ($(0, 1) + (0.523, -0.784)$) --
($(0, 1) + (0.581, -0.777)$) -- cycle;
\draw[contour] ($(0, 1) + (0.535, -0.708)$) -- ($(0, 1) + (0.523, -0.784)$)
($(0, 1) + (0.596, -0.700)$) -- ($(0, 1) + (0.581, -0.777)$);

%bridge bottom 3
\filldraw[bridge] ($(0, 1) + (0.581, -0.777)$) --
($(0, 1) + (0.660, -0.862)$) -- ($(0, 1) + (0.858, -0.717)$) --
($(0, 1) + (0.837, -0.702)$) -- ($(0, 1) + (0.826, -0.688)$) --
($(0, 1) + (0.785, -0.668)$) -- cycle;
\draw[contour] ($(0, 1) + (0.581, -0.777)$) -- ($(0, 1) + (0.785, -0.668)$)
($(0, 1) + (0.660, -0.862)$) -- ($(0, 1) + (0.858, -0.717)$);

%land top
\filldraw[land] (0, 1) --
($(0, 1) + (0, -0.287)$) -- ($(0, 1) + (0.080, -0.287)$) --
($(0, 1) + (0.161, -0.281)$) -- ($(0, 1) + (0.178, -0.273)$) --
($(0, 1) + (0.257, -0.289)$) -- ($(0, 1) + (0.280, -0.287)$) --
($(0, 1) + (0.329, -0.300)$) -- ($(0, 1) + (0.423, -0.301)$) --
($(0, 1) + (0.532, -0.302)$) -- ($(0, 1) + (0.558, -0.310)$) --
($(0, 1) + (0.591, -0.338)$) -- ($(0, 1) + (0.635, -0.328)$) --
($(0, 1) + (0.656, -0.304)$) -- ($(0, 1) + (0.669, -0.276)$) --
($(0, 1) + (0.720, -0.246)$) -- ($(0, 1) + (0.741, -0.233)$) --
($(0, 1) + (0.780, -0.210)$) -- ($(0, 1) + (0.824, -0.206)$) --
($(0, 1) + (0.874, -0.178)$) -- ($(0, 1) + (0.931, -0.169)$) --
($(0, 1) + (0.969, -0.161)$) -- ($(1, 1) + (0, -0.149)$) --
(1, 1) -- cycle;
\draw[contour] ($(0, 1) + (0, -0.287)$) -- ($(0, 1) + (0.080, -0.287)$) --
($(0, 1) + (0.161, -0.281)$) -- ($(0, 1) + (0.178, -0.273)$) --
($(0, 1) + (0.257, -0.289)$) -- ($(0, 1) + (0.280, -0.287)$) --
($(0, 1) + (0.329, -0.300)$) -- ($(0, 1) + (0.423, -0.301)$) --
($(0, 1) + (0.532, -0.302)$) -- ($(0, 1) + (0.558, -0.310)$) --
($(0, 1) + (0.591, -0.338)$) -- ($(0, 1) + (0.635, -0.328)$) --
($(0, 1) + (0.656, -0.304)$) -- ($(0, 1) + (0.669, -0.276)$) --
($(0, 1) + (0.720, -0.246)$) -- ($(0, 1) + (0.741, -0.233)$) --
($(0, 1) + (0.780, -0.210)$) -- ($(0, 1) + (0.824, -0.206)$) --
($(0, 1) + (0.874, -0.178)$) -- ($(0, 1) + (0.931, -0.169)$) --
($(0, 1) + (0.969, -0.161)$) -- ($(1, 1) + (0, -0.149)$);

%land bottom
\filldraw[land] ($(0, 1) + (0, -0.890)$) -- ($(0, 1) + (0.067, -0.880)$) --
($(0, 1) + (0.067, -0.880)$) -- ($(0, 1) + (0.085, -0.860)$) --
($(0, 1) + (0.111, -0.858)$) -- ($(0, 1) + (0.139, -0.849)$) --
($(0, 1) + (0.161, -0.860)$) -- ($(0, 1) + (0.212, -0.847)$) --
($(0, 1) + (0.242, -0.830)$) -- ($(0, 1) + (0.350, -0.826)$) --
($(0, 1) + (0.410, -0.804)$) -- ($(0, 1) + (0.422, -0.794)$) --
($(0, 1) + (0.450, -0.784)$) -- ($(0, 1) + (0.523, -0.784)$) --
($(0, 1) + (0.581, -0.777)$) -- ($(0, 1) + (0.660, -0.862)$) --
($(0, 1) + (0.672, -0.882)$) -- ($(0, 1) + (0.679, -0.924)$) --
($(0, 1) + (0.698, -0.968)$) -- ($(0, 1) + (0.714, -0.990)$) --
(0.718, 0) -- (0, 0) -- cycle;
\draw[contour] ($(0, 1) + (0, -0.890)$) -- ($(0, 1) + (0.067, -0.880)$) --
($(0, 1) + (0.067, -0.880)$) -- ($(0, 1) + (0.085, -0.860)$) --
($(0, 1) + (0.111, -0.858)$) -- ($(0, 1) + (0.139, -0.849)$) --
($(0, 1) + (0.161, -0.860)$) -- ($(0, 1) + (0.212, -0.847)$) --
($(0, 1) + (0.242, -0.830)$) -- ($(0, 1) + (0.350, -0.826)$) --
($(0, 1) + (0.410, -0.804)$) -- ($(0, 1) + (0.422, -0.794)$) --
($(0, 1) + (0.450, -0.784)$) -- ($(0, 1) + (0.523, -0.784)$) --
($(0, 1) + (0.581, -0.777)$) -- ($(0, 1) + (0.660, -0.862)$) --
($(0, 1) + (0.672, -0.882)$) -- ($(0, 1) + (0.679, -0.924)$) --
($(0, 1) + (0.698, -0.968)$) -- ($(0, 1) + (0.714, -0.990)$) --
(0.718, 0);

%land right
\filldraw[land] (1, 0) -- ($(0, 1) + (0.978, -0.975)$) --
($(0, 1) + (0.954, -0.908)$) -- ($(0, 1) + (0.921, -0.829)$) --
($(0, 1) + (0.900, -0.810)$) -- ($(0, 1) + (0.880, -0.775)$) --
($(0, 1) + (0.858, -0.717)$) -- ($(0, 1) + (0.837, -0.702)$) --
($(0, 1) + (0.826, -0.688)$) -- ($(0, 1) + (0.785, -0.668)$) --
($(0, 1) + (0.796, -0.623)$) -- ($(0, 1) + (0.796, -0.590)$) --
($(0, 1) + (0.792, -0.554)$) -- ($(0, 1) + (0.778, -0.524)$) --
($(0, 1) + (0.764, -0.466)$) -- ($(0, 1) + (0.762, -0.420)$) --
($(0, 1) + (0.776, -0.396)$) -- ($(0, 1) + (0.796, -0.364)$) --
($(0, 1) + (0.838, -0.368)$) -- ($(0, 1) + (0.864, -0.380)$) --
($(0, 1) + (0.910, -0.384)$) -- ($(0, 1) + (0.946, -0.392)$) --
($(0, 1) + (0.971, -0.394)$) -- ($(0, 1) + (1, -0.414)$) -- cycle;
\draw[contour] (1, 0) -- ($(0, 1) + (0.978, -0.975)$) --
($(0, 1) + (0.954, -0.908)$) -- ($(0, 1) + (0.921, -0.829)$) --
($(0, 1) + (0.900, -0.810)$) -- ($(0, 1) + (0.880, -0.775)$) --
($(0, 1) + (0.858, -0.717)$) -- ($(0, 1) + (0.837, -0.702)$) --
($(0, 1) + (0.826, -0.688)$) -- ($(0, 1) + (0.785, -0.668)$) --
($(0, 1) + (0.796, -0.623)$) -- ($(0, 1) + (0.796, -0.590)$) --
($(0, 1) + (0.792, -0.554)$) -- ($(0, 1) + (0.778, -0.524)$) --
($(0, 1) + (0.764, -0.466)$) -- ($(0, 1) + (0.762, -0.420)$) --
($(0, 1) + (0.776, -0.396)$) -- ($(0, 1) + (0.796, -0.364)$) --
($(0, 1) + (0.838, -0.368)$) -- ($(0, 1) + (0.864, -0.380)$) --
($(0, 1) + (0.910, -0.384)$) -- ($(0, 1) + (0.946, -0.392)$) --
($(0, 1) + (0.971, -0.394)$) -- ($(0, 1) + (1, -0.414)$);

%island
\filldraw[land] ($(0, 1) + (0.241, -0.622)$) -- ($(0, 1) + (0.235, -0.587)$) --
($(0, 1) + (0.240, -0.540)$) -- ($(0, 1) + (0.249, -0.524)$) --
($(0, 1) + (0.252, -0.498)$) -- ($(0, 1) + (0.266, -0.482)$) --
($(0, 1) + (0.271, -0.462)$) -- ($(0, 1) + (0.288, -0.454)$) --
($(0, 1) + (0.300, -0.434)$) -- ($(0, 1) + (0.308, -0.418)$) --
($(0, 1) + (0.320, -0.412)$) -- ($(0, 1) + (0.328, -0.404)$) --
($(0, 1) + (0.399, -0.399)$) -- ($(0, 1) + (0.453, -0.393)$) --
($(0, 1) + (0.518, -0.386)$) -- ($(0, 1) + (0.549, -0.388)$) --
($(0, 1) + (0.609, -0.404)$) -- ($(0, 1) + (0.624, -0.410)$) --
($(0, 1) + (0.644, -0.438)$) -- ($(0, 1) + (0.663, -0.486)$) --
($(0, 1) + (0.670, -0.519)$) -- ($(0, 1) + (0.668, -0.546)$) --
($(0, 1) + (0.658, -0.590)$) -- ($(0, 1) + (0.648, -0.612)$) --
($(0, 1) + (0.636, -0.648)$) -- ($(0, 1) + (0.633, -0.666)$) --
($(0, 1) + (0.617, -0.677)$) -- ($(0, 1) + (0.596, -0.700)$) --
($(0, 1) + (0.535, -0.708)$) -- ($(0, 1) + (0.500, -0.709)$) --
($(0, 1) + (0.457, -0.717)$) -- ($(0, 1) + (0.412, -0.708)$) --
($(0, 1) + (0.372, -0.702)$) -- ($(0, 1) + (0.336, -0.695)$) --
($(0, 1) + (0.291, -0.679)$) -- ($(0, 1) + (0.268, -0.652)$) --
cycle;
\draw[contour] ($(0, 1) + (0.241, -0.622)$) -- ($(0, 1) + (0.235, -0.587)$) --
($(0, 1) + (0.240, -0.540)$) -- ($(0, 1) + (0.249, -0.524)$) --
($(0, 1) + (0.252, -0.498)$) -- ($(0, 1) + (0.266, -0.482)$) --
($(0, 1) + (0.271, -0.462)$) -- ($(0, 1) + (0.288, -0.454)$) --
($(0, 1) + (0.300, -0.434)$) -- ($(0, 1) + (0.308, -0.418)$) --
($(0, 1) + (0.320, -0.412)$) -- ($(0, 1) + (0.328, -0.404)$) --
($(0, 1) + (0.399, -0.399)$) -- ($(0, 1) + (0.453, -0.393)$) --
($(0, 1) + (0.518, -0.386)$) -- ($(0, 1) + (0.549, -0.388)$) --
($(0, 1) + (0.609, -0.404)$) -- ($(0, 1) + (0.624, -0.410)$) --
($(0, 1) + (0.644, -0.438)$) -- ($(0, 1) + (0.663, -0.486)$) --
($(0, 1) + (0.670, -0.519)$) -- ($(0, 1) + (0.668, -0.546)$) --
($(0, 1) + (0.658, -0.590)$) -- ($(0, 1) + (0.648, -0.612)$) --
($(0, 1) + (0.636, -0.648)$) -- ($(0, 1) + (0.633, -0.666)$) --
($(0, 1) + (0.617, -0.677)$) -- ($(0, 1) + (0.596, -0.700)$) --
($(0, 1) + (0.535, -0.708)$) -- ($(0, 1) + (0.500, -0.709)$) --
($(0, 1) + (0.457, -0.717)$) -- ($(0, 1) + (0.412, -0.708)$) --
($(0, 1) + (0.372, -0.702)$) -- ($(0, 1) + (0.336, -0.695)$) --
($(0, 1) + (0.291, -0.679)$) -- ($(0, 1) + (0.268, -0.652)$) --
($(0, 1) + (0.241, -0.622)$);
\end{tikzpicture}

\end{document}

-
WOW! Just great! I was (in a way) working on it, but much worse than your's. –  pushpen.paul Jun 9 at 10:38
How much time did you waste? :-) –  pushpen.paul Jun 9 at 10:39
@pushpen.paul About an hour and a half. :) –  szantaii Jun 9 at 10:40

If you don't mind not having an exact reproduction, it is possible to get the gist of the required image fairly simply:

\documentclass[tikz,border=5]{standalone}
\usetikzlibrary{decorations.pathmorphing,topaths}
\begin{document}
\tikzset{sketch/.style={decorate,
decoration={random steps, amplitude=1pt, segment length=5pt},
line join=round, draw=black!80, very thick, fill=#1
}}
\begin{tikzpicture}

\clip [preaction={fill=cyan!10}] (0,0) rectangle (10,10);

\foreach \p/\r/\w/\h in
{(3,1)/5/1/4, (3,9)/-5/1/-4, (5,1)/-5/0.75/4, (5,9)/5/0.75/-4,
(5,5)/-90/0.75/4, (5,1)/-50/1/4, (6,8)/50/0.75/-4}
\draw [sketch=yellow!25]
[shift={\p}, rotate=\r] rectangle +(\w,\h);

\draw [sketch=green!50]
(-1,-1) -- (-1,0) to [bend left, looseness=0.5] (6,2) to [bend left] (7,-1)
(11,-1) to [bend left] (8,6) to [bend left] (11,6) -- cycle
(-1,9) to [bend right, looseness=0.5] (7,8) to [bend left]
(11,9) -- (11,11) -- (-1,11) -- cycle
(2,4) to [bend left, looseness=0.5] (2.5,6) to [bend left]
(6,6) to [bend left] (6,3.5) to [bend left] (2,4) -- cycle;
\end{tikzpicture}
\end{document}


-

Challenge accetped!

Start: 01:22 o'clock

...

First Milestome: 01:30 o'clock

Traced it using Portrace and having a svg file now

Original:

SVG:

Sure the tracing can be optimised...justr aiming for speed.

Next step: Seaching a svg2tikz converter...

Update: 01:46 o'clock

Found How to convert an SVG image with LaTeX in Inkscape, to PNG? (svg2tikz)

End: 01:59 o'clock

   LaTeX code too large too be posted (received an error message here)


I put the code here:

Here are the first lines:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}

\begin{document}
\definecolor{cf7f899}{RGB}{247,248,153}
\definecolor{cb9dee1}{RGB}{185,222,225}
\definecolor{c90aba4}{RGB}{144,171,164}
\definecolor{c93e862}{RGB}{147,232,98}
\definecolor{c8ee760}{RGB}{142,231,96}
\definecolor{c9ca86a}{RGB}{156,168,106}
\definecolor{c79c956}{RGB}{121,201,86}
\definecolor{c78948a}{RGB}{120,148,138}
\definecolor{c6b9e58}{RGB}{107,158,88}
\definecolor{c586d50}{RGB}{88,109,80}

\begin{tikzpicture}[y=0.80pt,x=0.80pt,yscale=-1, inner sep=0pt, outer sep=0pt]
\begin{scope}[shift={(0.06625,0)}]% g2995
% path3015
\path[fill=cf7f899] (0.0000,148.0000) -- (0.0000,0.0000) -- (161.0000,0.0000) --
(322.0000,0.0000) -- (322.0000,148.0000) -- (322.0000,296.0000) --
(161.0000,296.0000) -- (0.0000,296.0000) -- (0.0000,148.0000) -- cycle;

% path3013
\path[fill=cb9dee1] (0.0000,148.0000) -- (0.0000,0.0000) -- (161.0000,0.0000) --
(322.0000,0.0000) -- (322.0000,148.0000) -- (322.0000,296.0000) --
(161.0000,296.0000) -- (0.0000,296.0000) -- (0.0000,148.0000) --
cycle(216.5000,247.0000) .. controls (219.2500,244.8117) and
(221.8897,243.0165) .. (222.3660,243.0106) .. controls (222.8423,243.0046) and
(225.4437,241.3765) .. (228.1468,239.3922) .. controls (230.8499,237.4079) and
(235.4102,234.9010) .. (238.2808,233.8213) .. controls (241.1514,232.7416) and
(248.4500,228.5664) .. (254.5000,224.5430) .. controls (260.5500,220.5197) and
(266.9625,216.4900) .. (268.7500,215.5882) .. controls (270.5375,214.6865) and
(272.0000,213.4879) .. (272.0000,212.9247) .. controls (272.0000,212.3616) and
(270.4756,210.3313) .. (268.6125,208.4129) .. controls (265.1773,204.8757) and
(260.7332,203.0000) .. (255.7880,203.0000) .. controls (254.2891,203.0000) and
(242.6651,208.1750) .. (229.9570,214.5000) .. controls (217.0891,220.9045) and
(205.6141,226.0000) .. (204.0590,226.0000) .. controls (201.0839,226.0000) and
(191.0000,229.8125) .. (191.0000,230.9373) .. controls (191.0000,231.9585) and


TikZ output:

Zoomed in:

How it is done in Inkscape:

Not using Export to Clipboard lead to an error:

Traceback (most recent call last):

File "tikz_export.py", line 1415, in <module>

main_inkscape()

File "tikz_export.py", line 1403, in main_inkscape

effect.affect()

File "C:\Program Files (x86)\Inkscape\share\extensions\inkex.py", line 216, in affect

if output: self.output()

File "tikz_export.py", line 1346, in output

f = codecs.open(self.options.outputfile, 'w', 'utf8')

File "C:\Program Files (x86)\Inkscape\python\Lib\codecs.py", line 870, in open

file = __builtin__.open(filename, mode, buffering)

IOError: [Errno 13] Permission denied: 'Test'


I had to sign in to Github in order to download the files from https://github.com/kjellmf/svg2tikz. Then I put the files from the extensions and the inkexlib folder directly to C:\Program Files (x86)\Inkscape\share\extensions. Some of them were already there.

Last words:

The answer was down voted. Don't know why...thought it was a "just for fun" question.

-
Inkscape can export to TikZ... –  Bordaigorl Jun 9 at 11:36
Thanks. I see. Don't know where to find iz in Inkscape yet. In the extensions there is no tikz entry. At least I don't see it. –  Manuel Kuehner Jun 9 at 11:48
@ManuelKuehner Inkscape can export directly to TikZ after you install the following extension: inkscape2tikz. Make sure you restart Inkscape after you installed the extension. –  szantaii Jun 9 at 11:51
@ManuelKuehner You should post the tex code somewhere- may be at github. –  pushpen.paul Jun 9 at 13:00
Done! I updated the answer and added the link github.com/manuelkuehner/tex.stackexchange.com/blob/master/… –  Manuel Kuehner Jun 9 at 15:46