答案1
除了@user177954's
使用得到很好的答案之外straight lines
,您还可以使用库decorations
中可用的选项来实现它TikZ
。
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{calc,patterns,
decorations.pathmorphing,
decorations.markings}
\begin{document}
\begin{tikzpicture}
\draw[help lines, step=1] (-2,-1)grid(2,2);
\tikzstyle{spring}=[thick,decorate,decoration={zigzag,pre length=0cm,post
length=0cm,segment length=8}]
% the line
\path (-2,1) node (p1) {};
\path (2,1) node (p2) {};
\draw[very thick] (p1) to (p2);
%the triangles
\draw (-1.86,0.975)
-- (-1.96,0.875)-- (-1.76,0.875)
-- cycle;
\draw (1.86,0.975)
-- (1.96,0.875)-- (1.76,0.875)
-- cycle;
\draw[spring] ($(p1.east)-(-0.3,0)$) -- ( $(p1.east)-(-0.3,1)$);
\draw[spring] ($(p2.west)-(0.3,0)$) -- ( $(p2.west)-(0.3,1)$);
% ground
\draw[very thick] ($(p1.east)-(0,1)$) to ($(p1.east)-(-0.6,1)$);
\fill [pattern = north east lines] ($(p1.east)-(0,1)$) rectangle ($(p1.east)-(-0.6,1.3)$);
\draw[very thick] ($(p2.west)-(0,1)$) to ($(p2.west)-(0.6,1)$);
\fill [pattern = north east lines] ($(p2.west)-(0,1)$) rectangle ($(p2.west)-(0.6,1.3)$);
\end{tikzpicture}
\end{document}
这将给你:
为了方便参考,您还可以grid lines
在环境中使用它来辅助绘制和引用您的节点。当您掌握它时,您可以随时跳过(不幸的是,我不会 ;))。
答案2
真的只是为了好玩(因为我想试试看一个人能滥用多少/.list
。)
\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{shapes.geometric,patterns}
\begin{document}
\begin{tikzpicture}[trian/.style={anchor=north,regular polygon,regular polygon
sides=3},zig/.style={insert path={-- ++(-#1,-#1) -- ++(#1,0)}}]
\draw[very thick] (0,0) node[trian,thin,draw,anchor=north]{} -- (9,0)
node[trian,thin,draw,anchor=north]{};
\draw[thick] (3,0) [zig/.list={0.5,0.5,0.5,0.5}] node[below,pattern=north east
lines,minimum width=0.5cm,minimum height=0.3cm,xshift=-0.25cm]{};
\draw[thick] (6,0) [zig/.list={0.5,0.5,0.5,0.5}] node[below,pattern=north east
lines,minimum width=0.5cm,minimum height=0.3cm,xshift=-0.25cm]{};
\end{tikzpicture}
\end{document}
答案3
简单的直线,不需要任何经验tikz
:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw (0.9840,6.7461) -- (0.7801,6.4168) -- (1.2036,6.4168) -- (0.9840,6.7461);
\draw (2.7719,6.7461) -- (2.4426,6.2756) -- (2.7876,6.2700) -- (2.4426,5.8992) -- (2.7876,5.8992) -- (2.4426,5.5709) -- (2.7876,5.5698) -- (2.4426,5.2405) -- (2.7876,5.2405);
\draw (2.4426,5.2405) -- (2.3245,5.0793);
\draw (2.5609,5.2405) -- (2.4428,5.0793);
\draw (2.6792,5.2405) -- (2.5611,5.0793);
\draw (2.7975,5.2405) -- (2.6794,5.0793);
\draw (6.1885,6.7461) -- (6.3924,6.4168) -- (5.9690,6.4168) -- (6.1885,6.7461);
\draw(4.5091,6.7461) -- (4.1798,6.2756) -- (4.5248,6.2700) -- (4.1798,5.8992) -- (4.5248,5.8992) -- (4.1798,5.5709) -- (4.5248,5.5698) -- (4.1798,5.2405) -- (4.5248,5.2405);
\draw (4.1798,5.2405) -- (4.0617,5.0793);
\draw (4.2981,5.2405) -- (4.1800,5.0793);
\draw (4.4164,5.2405) -- (4.2983,5.0793);
\draw (4.5347,5.2405) -- (4.4166,5.0793);
\draw (0.9840,6.7461) -- (6.1885,6.7461);
\end{tikzpicture}
\end{document}