如何在 tikz 中创建带有自定义头部的路径?

如何在 tikz 中创建带有自定义头部的路径?

我想制作一个半圆形边框,作为 tikz 图中箭头的形状。

有人知道如何打造这种风格吗?

答案1

使用箭头库和一些 PGF 代码,您可以执行以下操作(改编自手动的,见第 74.2 节)。

\documentclass[a4paper]{article}
\usepackage{tikz}
\usetikzlibrary{arrows}

\begin{document}

% Code for the new arrow tip, called halfcirc.
\pgfarrowsdeclare{halfcirc}{halfcirc}
{
\arrowsize=0.2pt
\advance\arrowsize by .5\pgflinewidth
\pgfarrowsleftextend{-4\arrowsize-.5\pgflinewidth}
\pgfarrowsrightextend{.5\pgflinewidth}
}
{
\arrowsize=0.2pt
\advance\arrowsize by .5\pgflinewidth
\pgfsetdash{}{0pt} % do not dash
\pgfsetroundjoin % fix join
\pgfsetroundcap % fix cap
\pgfpathmoveto{\pgfpoint{-4\arrowsize}{4\arrowsize}}
\pgfpatharc{90}{-90}{4\arrowsize}
\pgfusepathqstroke
}

% Declare a reversed version called revhalfcirc.
\pgfarrowsdeclarereversed{revhalfcirc}{revhalfcirc}{halfcirc}{halfcirc}

% Demonstration of the arrow tip.
\begin{tikzpicture}
\draw[help lines] (-3,-2) grid (3,2);
\draw[line width=10pt, revhalfcirc-halfcirc] (-2,0) -- (0,0);
\end{tikzpicture}

\end{document}

在此处输入图片描述

相关内容