绘制柯尼斯堡风景,展示桥梁

绘制柯尼斯堡风景,展示桥梁

只是为了好玩,我试着画了这幅画(我发现这里):

但是,我不知道如何在中创建不规则形状tikz。有人可以帮忙吗?

答案1

这是您的身材的可能复制品。

我只是将图像放大,然后在 Gimp 中手动追踪轮廓的坐标(像素),然后填充必要的区域。代码很长,而且不太好。:)

\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}

答案2

如果您不介意没有精确的复制品,那么可以相当简单地获取所需图像的要点:

\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}

在此处输入图片描述

答案3

接受挑战!

开始时间:01:22

...

第一个里程碑:凌晨 1:30

使用 Portrace 描摹,现在有一个 svg 文件

原来的:

原来的

SVG:

SVG

当然,可以优化跟踪...只是为了提高速度。

下一步:搜索 svg2tikz 转换器...

更新时间:01:46

成立如何在 Inkscape 中使用 LaTeX 将 SVG 图像转换为 PNG?(svg2tikz)

结束时间:01:59

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

我把代码放在这里:

https://github.com/manuelkuehner/tex.stackexchange.com/blob/master/2014-06-09_01

以下是第一行:

\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 输出:

在此处输入图片描述

放大:

在此处输入图片描述

在 Inkscape 中如何完成:

在此处输入图片描述

在此处输入图片描述

不使用Export to Clipboard会导致错误:

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'

我必须登录 Github 才能从https://github.com/kjellmf/svg2tikzextensions。然后我将和文件夹中的文件inkexlib直接放入C:\Program Files (x86)\Inkscape\share\extensions。其中一些文件已经在那里了。

最后的话:

这个答案被否决了。不知道为什么……以为这是一个“只是为了好玩”的问题。

相关内容