操作等腰三角形

操作等腰三角形
\documentclass{article}
\usepackage{tikz}
\usepackage{pgf}
    \usetikzlibrary{shapes.geometric}
    \usepgflibrary{decorations.shapes}
    \usetikzlibrary{decorations.shapes, shapes, fit, arrows, positioning, trees, mindmap, calc}
    \tikzset{
        rubber/.style={
            draw=red!50,
            shape border rotate=-90,
            isosceles triangle,
            fill=red!50,
            minimum height=1.5cm,
            minimum width =0.05cm,
        }
    }
    \tikzset{
        ducky/.style={
            draw=red!50,
            shape border rotate=90,
            isosceles triangle,
            fill=red!50,
            minimum height=1.5cm,
            minimum width =0.05cm,
        }
        }
        \begin{document}

        \begin{tikzpicture}

    \node[rubber] at (0,0) {};
    \node[ducky] at (0,0.5) {};
\end{tikzpicture}

\end{document}

有没有什么办法可以让三角形变得更高、更瘦呢?

答案1

您需要两把钥匙:

  • isosceles triangle stretches选项忽略isosceles triangle apex angle(默认设置为30)并且可以使用minimum widthminimum height指定密钥的精确尺寸isosceles triangle
  • 对于非常小的值,您还需要将inner sep键设置为0pt(默认为.3333em)。

我建议你阅读第 428 页。PGF 手册。(您也可以在 PDF 中搜索等腰三角形。)

代码

\documentclass[tikz]{standalone}
\usetikzlibrary{shapes.geometric}
\tikzset{
    rubberduck/.style={
        draw=red!50,
        shape=isosceles triangle,
        fill=red!50,
        minimum height=1.5cm,
        minimum width=0.5cm,
        shape border rotate=#1,
        isosceles triangle stretches,
        inner sep=0pt,
    },
    rubber/.style={rubberduck=+90},
    ducky/.style={rubberduck=-90}}
\begin{document}
\begin{tikzpicture}
\node[rubber] at (0,0) {};
\node[ducky] at (1,1.5) {};
\end{tikzpicture}
\end{document}

输出

在此处输入图片描述

相关内容