我想用 tikz 重现下面的图像,我尝试过但对获得的结果并不满意。
\documentclass[a4paper,12pt]{article}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage{ngerman}
\usepackage{amsmath}
\usepackage{multido}
\usepackage[dvips]{graphicx}
\usepackage[dvipsnames]{xcolor}
\usepackage{tikz}
\usepackage{pgf}
\usepackage{float}
\usepackage[tikz]{bclogo}
\usepackage{pgf,tikz,pgfplots}
\usepackage{tikz-3dplot}
\usetikzlibrary{shadows.blur}
\makeatletter
\tikzset{vertical custom shading/.code={%
\pgfmathsetmacro\tikz@vcs@middle{#1}
\pgfmathsetmacro\tikz@vcs@bottom{\tikz@vcs@middle/2}
\pgfmathsetmacro\tikz@vcs@top{(100-\tikz@vcs@middle)/2+\tikz@vcs@middle}
\pgfdeclareverticalshading[tikz@axis@top,tikz@axis@middle,tikz@axis@bottom]{newaxis}{100bp}{%
color(0bp)=(tikz@axis@bottom);
color(\tikz@vcs@bottom bp)=(tikz@axis@bottom);
color(\tikz@vcs@middle bp)=(tikz@axis@middle);
color(\tikz@vcs@top bp)=(tikz@axis@top);
color(100bp)=(tikz@axis@top)}
\pgfkeysalso{/tikz/shading=newaxis}
}
}
\makeatother
\begin{document}
\begin{tikzpicture}
\filldraw [rounded corners=3pt,left color=black!95,right color=black,middle color=black!70, vertical custom shading=60, shading angle=90] (3,0) -- (4,0) -- (3.87,1) -- (3.13,1) -- cycle;
\node [rounded corners=1pt,fill=gray!30,text=black] {m};
\end{tikzpicture}
\begin{tikzpicture}
\draw[line width=8,line cap=round] (1.6,3.1) to[out=150,in=-90] (1,4)
to[out=90,in=180] (2,5)
to[out=0,in=90] (3,4)
to[out=-90,in=30] (2.4,3.1);
\draw[line width=8,line cap=round] (1.6,3.1) to[out=330,in=90] (2,2.6);
\draw[line width=8,line cap=round] (2,2.6) -- (2,2);
\end{tikzpicture}
\begin{tikzpicture}
\draw[top color=black!65,
bottom color=black!70,
middle color=cyan!30,
vertical custom shading=35, rounded corners=1pt, line width=2pt]
(0,0) rectangle (0.5,3);
\draw [fill=black] (.25,1.5) circle (1 mm);
\draw [line width=.7pt,left color=gray!95,right color=gray,middle color=black, shading angle=135] (2.5,1.5) circle (14 mm);
\draw [opacity=0.5,line width=0.75pt,left color=gray!55,right color=gray!40,middle color=white, shading angle=45] (2.5,1.5) circle (14 mm);
\end{tikzpicture}
\end{document}
答案1
这并不是尝试完成一幅图片,而是一个建议,告诉您如何使用“图片”将您的个人tikzpicture
图片组合成一幅大tikzpicture
图片。
\documentclass[tikz,border=3mm]{standalone}
\usepackage{siunitx}
\usetikzlibrary{calc,patterns}
\makeatletter
\tikzset{vertical custom shading/.code={%
\pgfmathsetmacro\tikz@vcs@middle{#1}
\pgfmathsetmacro\tikz@vcs@bottom{\tikz@vcs@middle/2}
\pgfmathsetmacro\tikz@vcs@top{(100-\tikz@vcs@middle)/2+\tikz@vcs@middle}
\pgfdeclareverticalshading[tikz@axis@top,tikz@axis@middle,tikz@axis@bottom]{newaxis}{100bp}{%
color(0bp)=(tikz@axis@bottom);
color(\tikz@vcs@bottom bp)=(tikz@axis@bottom);
color(\tikz@vcs@middle bp)=(tikz@axis@middle);
color(\tikz@vcs@top bp)=(tikz@axis@top);
color(100bp)=(tikz@axis@top)}
\pgfkeysalso{/tikz/shading=newaxis}
}
}
\makeatother
\begin{document}
\begin{tikzpicture}[pics/weight/.style={code={
\filldraw [rounded corners=3pt,left color=black!95,right color=black,middle
color=black!70, vertical custom shading=60, shading angle=90] (-1,0) --
(1,0) -- (0.7,2) -- (-0.7,2) -- cycle;
\node [rounded corners=1pt,fill=gray!30,text=black] at (0,0.9) {#1};}},
pics/hook/.style={code={
\pgfgettransformentries{\tmpa}{\tmpb}{\tmpc}{\tmpd}{\tmp}{\tmp}%
\pgfmathsetmacro{\myJacobian}{sqrt(abs(\tmpa*\tmpd-\tmpb*\tmpc))}
\draw[line width=\myJacobian*12pt,line cap=round]
(0,-1) -- (0,-0.6) to[out=90,in=0] (-0.1,-0.5)
arc[start angle=250,end angle=0,radius=0.5cm];
}},
pics/disk/.style={code={
\draw [opacity=0.5,line width=0.75pt,left color=gray!55,right color=gray!40,middle color=white, shading angle=45]
(0,0) circle[radius=#1];}},pics/disk/.default=1.4cm,
pics/bar/.style={code={\pgfgettransformentries{\tmpa}{\tmpb}{\tmpc}{\tmpd}{\tmp}{\tmp}%
\pgfmathsetmacro{\myJacobian}{sqrt(abs(\tmpa*\tmpd-\tmpb*\tmpc))}
\draw[top color=black!65,
bottom color=black!70,
middle color=cyan!30,
vertical custom shading=35, rounded corners=1pt, line width=\myJacobian*2pt]
(-0.25,-1.5) rectangle (0.25,1.5);
\draw [fill=black] (0,0) circle[radius=1mm];}},line cap=round,>=stealth,
declare function={alpha=15;}]
\begin{scope}[yshift=-9cm]
\path (0,0) pic[opacity=0.2]{weight=60kg}
(0,0.5) pic{weight=60kg}
(0,2.75)pic[scale=0.2,gray]{hook}
(0,3.5)pic[scale=0.2,rotate=180,gray]{hook}
(0,2.8) edge[thick] (0,3.45)
(0,4.1) pic[xscale=0.5,yscale=0.25]{bar}
(0,4.5) coordinate (L);
\path[bottom color=gray!50!black,top color=gray!10,
postaction={pattern=north east lines}]
(-1.2,0) rectangle (2,-0.4)
(-1.2,0) edge (2,0) ;
\draw[|<->|] (1.2,0) -- node[right]{$\Delta h=\SI{10}{\centi\meter}$} (1.2,0.5);
\end{scope}
\path (0.7,0) ++ (alpha:0.7) -- ++ (alpha-90:2.5) coordinate (H1)
pic[pos=1.05,rotate=180+alpha,scale=0.2,black,opacity=0.5]{hook}
(0.7,1) pic[scale=0.2,gray]{hook}
(0.7,1.75) pic[scale=0.2,gray,rotate=180]{hook}
(0.7,1.05) edge[thick] (0.7,1.7);
\draw[<-,green!70!black] ($(L)!0.5!(0,0)$) -- ++(-1,0)
node[left,black] {$F_S=\SI{600}{\newton}$};
\draw[brown,very thick] (L) --(0,0) arc[start angle=180,end
angle=alpha,radius=0.7cm] coordinate(R) -- ++ (alpha-90:3)
coordinate (H2) pic[pos=1.05,rotate=180+alpha,scale=0.2,black]{hook};
\draw (H1) -- ($(H1)!5mm!90:(H2)$) coordinate (H1')
(H2) -- ($(H2)!5mm!-90:(H1)$) coordinate (H2');
\draw[|<->] (H1') -- node[right]{$\Delta s=\SI{10}{\centi\meter}$} (H2');
\path (0.7,0) pic[scale=0.5]{disk} pic[scale=0.5]{bar};
\path[top color=gray!50!black,bottom color=gray!10,
postaction={pattern=north east lines}]
(-3,2) rectangle (4.4,2.4)
(-3,2) edge (4.4,2) ;
\draw[red,->] ($(R)+(alpha:5mm)+(alpha-90:0.5)$) --
node[right,black]{$F_Z=\SI{600}{\newton}$} ++ (alpha-90:1);
\end{tikzpicture}
\end{document}