畫一個「手繪」圓圈(某種意義上)

畫一個「手繪」圓圈(某種意義上)

我想要一種更好的方法來繪製近似手繪圓圈的東西tikz

\documentclass{article}
\pagestyle{empty}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}

\begin{tikzpicture}

  \coordinate (A) at (0,0);
  \coordinate (C) at (2in, 0);
  \coordinate (B) at ($(C)!1in!-90:(A)$);

  \draw (A) -- (C) -- (B) -- cycle;

  \coordinate (A/u) at ($(A) + (30:1em)$);
  \coordinate (A/d) at ($(A) + (-10:1em)$);
  \coordinate (A/x) at ($(A) + (120:2em)$);
  \coordinate (A/y) at ($(A) + (-120:2em)$);

  \draw[line width=1pt] (A/d) .. controls (A/x) and (A/y) .. (A/u);

\end{tikzpicture}

\end{document}

在此輸入影像描述

我知道模擬手繪線條。雖然搖擺效果很好,但我想要一些接近我的圓圈的東西,但兩端不太相交。

答案1

在...的幫助下模擬手繪線條,似乎得到了更好的結果(紅色的對於這個特定的應用程序,使用帶有 percusse 的方形形狀decoration=penciline,並且使用 Alain Matthes 的圓形效果更好\freedraw

在此輸入影像描述

代碼:

\documentclass{article}
\pagestyle{empty}
\usepackage{tikz}
\usetikzlibrary{calc,decorations.pathmorphing,patterns,shapes}

%% https://tex.stackexchange.com/questions/39296/simulating-hand-drawn-lines: percusse
\pgfdeclaredecoration{penciline}{initial}{
    \state{initial}[width=+\pgfdecoratedinputsegmentremainingdistance,auto corner on length=1mm,]{
        \pgfpathcurveto%
        {% From
            \pgfqpoint{\pgfdecoratedinputsegmentremainingdistance}
                            {\pgfdecorationsegmentamplitude}
        }
        {%  Control 1
        \pgfmathrand
        \pgfpointadd{\pgfqpoint{\pgfdecoratedinputsegmentremainingdistance}{0pt}}
                        {\pgfqpoint{-\pgfdecorationsegmentaspect\pgfdecoratedinputsegmentremainingdistance}%
                                        {\pgfmathresult\pgfdecorationsegmentamplitude}
                        }
        }
        {%TO 
        \pgfpointadd{\pgfpointdecoratedinputsegmentlast}{\pgfpoint{0.5pt}{1.5pt}}
        }
    }
    \state{final}{}
}

%% https://tex.stackexchange.com/questions/39296/simulating-hand-drawn-lines: Alain Matthes
\pgfdeclaredecoration{free hand}{start}
{
  \state{start}[width = +0pt,
                next state=step,
                persistent precomputation = \pgfdecoratepathhascornerstrue]{}
  \state{step}[auto end on length    = 3pt,
               auto corner on length = 3pt,               
               width=+2pt]
  {
    \pgfpathlineto{
      \pgfpointadd
      {\pgfpoint{2pt}{0pt}}
      {\pgfpoint{rand*0.15pt}{rand*0.15pt}}
    }
  }
  \state{final}
  {}
}
 \tikzset{free hand/.style={
    decorate,
    decoration={free hand}
    }
 } 
\def\freedraw#1;{\draw[free hand] #1;}



\begin{document}

\begin{tikzpicture}
    \coordinate (A) at (0,0);
    \coordinate (C) at (1in, 0);
    \coordinate (B) at ($(C)!1in!-90:(A)$);

    \draw (A) -- (C) -- (B) -- cycle;

    \coordinate (A/u) at ($(A) + (30:1em)$);
    \coordinate (A/d) at ($(A) + (-10:1em)$);
    \coordinate (A/x) at ($(A) + (120:2em)$);
    \coordinate (A/y) at ($(A) + (-120:2em)$);

    \begin{scope}[decoration=penciline]
        \draw[thick, fill=blue!25, fill opacity=.25, draw=red, decorate] ($(A)+(-0.1cm,-0.1cm)$)  rectangle (0.1cm,0.2cm); 
        \draw[thick, draw=brown, radius=0.1cm, decorate] (B)  circle (0.15cm); 
        \draw[thick, draw=blue, x radius=0.15cm, y radius=0.19cm, rotate=30, shape=circle, decorate,] (C) circle {}; 
        \node [above left] at (B) {decoration=penciline};
    \end{scope}
\end{tikzpicture}
\hspace*{0.3cm}
\begin{tikzpicture}
    \coordinate (A) at (0,0);
    \coordinate (C) at (1in, 0);
    \coordinate (B) at ($(C)!1in!-90:(A)$);

    \draw (A) -- (C) -- (B) -- cycle;

    \coordinate (A/u) at ($(A) + (30:1em)$);
    \coordinate (A/d) at ($(A) + (-10:1em)$);
    \coordinate (A/x) at ($(A) + (120:2em)$);
    \coordinate (A/y) at ($(A) + (-120:2em)$);

    \freedraw[thick, draw=blue] ($(A)+(-0.1cm,-0.1cm)$)  rectangle (0.15cm,0.2cm); 
    \freedraw[thick, fill=blue!25, fill opacity=.25, draw=red] (B) circle [radius=0.2cm]; 
    \freedraw[thick, fill=blue!25, fill opacity=.25, draw=red, x radius=0.15cm, y radius=0.19cm, rotate=30, shape=circle,] (C) circle {}; 
    \node [above left] at (B) {\textbackslash freedraw};
\end{tikzpicture}

\end{document}

答案2

我不會開車tikz,所以如果語法不規範請原諒。但我所做的是以\mathcal{O}用戶可定義的方式拉伸和旋轉它:

\documentclass{article}
\pagestyle{empty}
\usepackage{tikz}
\usetikzlibrary{calc}
\newcommand\handoh[3][0]{%
\scalebox{#2}[#3]{\raisebox{1pt}{\kern3pt\rotatebox{#1}{%
  \kern-4.5pt\raisebox{-2pt}{$\mathcal{O}$}\kern-4pt}}\kern2pt}%
}
\begin{document}
\begin{tikzpicture}

  \coordinate (A) at (0,0);
  \coordinate (C) at (2in, 0);
  \coordinate (B) at ($(C)!1in!-90:(A)$);

  \draw (A) -- (C) -- (B) -- cycle;

  \coordinate (A/u) at ($(A) + (30:1em)$);
  \coordinate (A/d) at ($(A) + (-10:1em)$);
  \coordinate (A/x) at ($(A) + (120:2em)$);
  \coordinate (A/y) at ($(A) + (-120:2em)$);


\node (D) [label=left:{\textbackslash handoh[160]\{2.5\}\{3\}}] 
  at (A) {\handoh[160]{2.5}{3}};

\node (E) [label=left:{\textbackslash handoh[45]\{1.3\}\{1.7\}}] 
  at (B) {\handoh[45]{1.3}{1.7}};

\node (F) [label=below:{\textbackslash handoh[-70]\{2.5\}\{1.5\}}] 
  at (C) {\handoh[-70]{2.5}{1.5}};
\end{tikzpicture}
\end{document}

在此輸入影像描述

答案3

如果圓的另一側沒有另一個中點,則很難獲得您想要的真正的圓形形狀。此 MWE 增加了另一個中點,並對控制點進行了一些調整,使其具有某種圓形、某種不規則的形狀。

事實上,雖然「擺動」效果對於較直的線段來說很好,但大多數時候我發現小圓圈是非常平滑的線條,只是通常是橢圓形...

微量元素:

\documentclass{article}
\pagestyle{empty}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}

\begin{tikzpicture}

  \coordinate (A) at (0,0);
  \coordinate (C) at (2in, 0);
  \coordinate (B) at ($(C)!1in!-90:(A)$);

  \draw (A) -- (C) -- (B) -- cycle;

  \coordinate (A/u) at ($(A) + (40:.8em)$);
  \coordinate (A/d) at ($(A) + (-20:1.1em)$);
  \coordinate (A/l) at ($(A) + (180:.7em)$);
  \coordinate (A/x) at ($(A) + (50:1em)$);
  \coordinate (A/y) at ($(A) + (120:1.2em)$);
  \coordinate (A/v) at ($(A) + (-120:1.6em)$);
  \coordinate (A/w) at ($(A) + (-30:1.8em)$);

  \draw[line width=1pt] (A/d) .. controls (A/x) and (A/y) .. (A/l) .. controls (A/v) and (A/w) .. (A/u);

\end{tikzpicture}

\end{document}

給出:

圓 三角形

相關內容