4

Please.

Dynamometer

\documentclass{standalone}
\usepackage{tkz-euclide}

\begin{document}

\begin{tikzpicture}[scale=1, transform shape,every node/.style={scale=1.0}]

%argola
\definecolor{meu_cinzento}{RGB}{116, 123, 129}
\tkzDefPoint(02,25){O1}
\tkzDefPoint(02,23){O2}
\tkzDefPoint(02,20){O3}
\tkzDrawArc[R,line width = 6pt,color=meu_cinzento](O1,2)(0,360)
\tkzDrawSegment[line width = 3pt,color=meu_cinzento](O2,O3)

%gancho
\definecolor{meu_cinzento}{RGB}{116, 123, 129}
\tkzDefPoint(02,5){O1}
\tkzDefPoint(02,7){O2}
\tkzDefPoint(02,9){O3}
\tkzDrawArc[R,line width = 6pt,color=meu_cinzento](O1,2)(90,360)
\tkzDrawSegment[line width = 6pt,color=meu_cinzento](O2,O3)

%espelho do dinamómetro
\definecolor{meu_cinzento}{RGB}{175, 191, 196}
\tkzDefPoint(02,10){O}
\tkzDrawCircle[R,meu_cinzento!20,fill=meu_cinzento,opacity=1](O,2)
\tkzDrawArc[R,line width = 3pt,color=black](O,2)(180,0)
\tkzDefPoint(02,20){O}
\tkzDrawCircle[R,meu_cinzento!20,fill=meu_cinzento,opacity=1](O,2)
\tkzDrawArc[R,line width = 3pt,color=black](O,2)(0,180)
\tkzDefPoint(00,10){P1}
\tkzDefPoint(00,20){P2}
\tkzDefPoint(04,20){P3}
\tkzDefPoint(04,10){P4}
\tkzDrawPolygon[fill=meu_cinzento!20,color=meu_cinzento](P1,P2,P3,P4)
\tkzDrawSegment[line width = 3pt,color=black](P1,P2)
\tkzDrawSegment[line width = 3pt,color=black](P3,P4)

%ranhura do ponteiro
\tkzDefPoint(02,10){P1}
\tkzDefPoint(02,20){P2}
\tkzDrawSegment[line width = 3pt,color=black](P1,P2)

%escala
\foreach \i in {0,...,20}{%
    \tkzDefPoint(1.5,{10+0.5*\i}){O\i}}
\foreach \i in {0,...,20}{%
    \tkzDefPoint(2.5,{10+0.5*\i}){P\i}}
\foreach \i in {0,...,20}{%
    \tkzDrawSegment[line width = 0.5pt,color=black](O\i,P\i)}

%ponteiro
\tkzDrawSegment[line width = 5pt,color=red](O5,P5)

\end{tikzpicture}
\end{document}

3
  • 2
    You don't need to use \definecolor multiple times if you don't re-define the color. Also, you don't need to repeat the same \foreach expression three times. Apart from that, I would probably just use plain tikz to draw this ... But: what exactly is your question? Jan 16 at 11:45
  • I don't like the way the segments join each other Jan 16 at 11:48
  • I agree with @JasperHabicht you need to use tikz-pgf and not tkz-euclide. Jan 16 at 12:04

3 Answers 3

7

There may be a way to connect tkz-euclide macros so that they join nicely (which I am not aware of), or you could use the line cap option.

But, I think it is much easier to draw this with plain tikz and not load tkz-euclide. The code would be a lot shorter then:

\documentclass{standalone}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}

\definecolor{meu_cinzento-1}{RGB}{116, 123, 129}
\definecolor{meu_cinzento-2}{RGB}{175, 191, 196}

%argola
\draw[line width=6pt, meu_cinzento-1] (2,25) circle (2);
\draw[line width=3pt, meu_cinzento-1] (2,23) -- ++(0,-3);

%gancho
\draw[line width=6pt, meu_cinzento-1] (2,9) -- ++(0,-2) arc (90:360:2);

%espelho do dinamómetro
\draw[line width=3pt, fill=meu_cinzento-2] (4,20) arc (0:180:2) -- ++(0,-10) arc (180:360:2) -- cycle; 

%ranhura do ponteiro
\draw[line width=3pt] (2,20) -- ++(0,-10); 

%escala (com ponteiro)
\foreach \i in {0,...,20}{
    \ifnum\i=5
        \draw[line width=5pt, red] 
    \else
        \draw[line width=0.5pt] 
    \fi
        (1.5,{10+0.5*\i}) -- ++(1,0);
}

\end{tikzpicture}
\end{document}

enter image description here

Some additional remarks:

  • You don't need to define a color multiple times, and I would suggest that you name different colors differently.
  • You can include more than just one drawing command in a \foreach macro. So, there is no need to repeat the very same \foreach definition multiple times here.
1
  • 1
    Thank you all. I've found that my classes adapt better to TKZ, with a smaller set of commands, than to TikZ-pgf. You're right, but I think I should go for the simpler solution and hope that they'll then evolve into a more labor-intensive solution, from their point of view. Jan 16 at 13:01
5

You need to add : line cap=round,line join=round and it is better to use TikZ, tkz-euclide is for euclidean geometry.

\documentclass{standalone}
\usepackage{tkz-euclide}

\begin{document}

\begin{tikzpicture}[scale=1, transform shape,every node/.style={scale=1.0},line cap=round,line join=round]

%argola
\definecolor{meu_cinzento}{RGB}{116, 123, 129}
\tkzDefPoint(02,25){O1}
\tkzDefPoint(02,23){O2}
\tkzDefPoint(02,20){O3}
\tkzDrawArc[R,line width = 6pt,color=meu_cinzento](O1,2)(0,360)
\tkzDrawSegment[line width = 3pt,color=meu_cinzento](O2,O3)

%gancho
\tkzDefPoint(02,5){O1}
\tkzDefPoint(02,7){O2}
\tkzDefPoint(02,9){O3}
\tkzDrawArc[R,line width = 6pt,color=meu_cinzento](O1,2)(90,360)
\tkzDrawSegment[line width = 6pt,color=meu_cinzento](O2,O3)

%espelho do dinamómetro
\definecolor{meu_cinzento}{RGB}{175, 191, 196}
\tkzDefPoint(02,10){O}
\tkzDrawCircle[R,meu_cinzento!20,fill=meu_cinzento,opacity=1](O,2)
\tkzDrawArc[R,line width = 3pt,color=black](O,2)(180,0)
\tkzDefPoint(02,20){O}
\tkzDrawCircle[R,meu_cinzento!20,fill=meu_cinzento,opacity=1](O,2)
\tkzDrawArc[R,line width = 3pt,color=black](O,2)(0,180)
\tkzDefPoint(00,10){P1}
\tkzDefPoint(00,20){P2}
\tkzDefPoint(04,20){P3}
\tkzDefPoint(04,10){P4}
\tkzDrawPolygon[fill=meu_cinzento!20,color=meu_cinzento](P1,P2,P3,P4)
\tkzDrawSegments[line width = 3pt,color=black](P1,P2 P3,P4)

%ranhura do ponteiro
\tkzDefPoint(02,10){P1}
\tkzDefPoint(02,20){P2}
\tkzDrawSegment[line width = 3pt,color=black](P1,P2)

%escala
\foreach \i in {0,...,20}{%
    \tkzDefPoint(1.5,{10+0.5*\i}){O\i}
    \tkzDefPoint(2.5,{10+0.5*\i}){P\i}
    \tkzDrawSegment[line width = 0.5pt,color=black](O\i,P\i) }

%ponteiro
\tkzDrawSegment[line width = 5pt,color=red](O5,P5)

\end{tikzpicture}

enter image description here

3

Try this (minimalist):

\documentclass[border=10pt]{standalone}
\usepackage{tikz,calc}


\begin{document}
    
    \begin{tikzpicture}[scale=1]
        \draw[gray,line width=12pt] (0,0) arc (180:0:2);
        \filldraw[brown] (-1,0) rectangle (5,-22);
            \node[white] at (2.1,-.5) (a) {\bfseries \large Range: 0-18.5 kg};
        \draw[cyan,line width=20pt,centered] (2.1,-1)--(2.1,-21);
        \foreach \i in {0,1,...,18}{
            \pgfmathsetmacro\h{-2-\i};
            \pgfmathsetmacro\j{-2.5-\i};
            \pgfmathsetmacro\k{.5+\i};
            \draw[white,line width=3pt] (1.6,\h)--(1.2,\h) node[left] (\i) {\bfseries \large $\i$};
            \draw[white,line width=3pt] (2.6,\j)--(3.0,\j) node[right] (\i) {\bfseries \large $\k$};
        }
        \draw[red,line width=3] (1.5,-2)--(2.7,-2);
        \draw[gray,line width=12pt] (2.1,-22)--(2.1,-23) arc (90:360:2);
    \end{tikzpicture}
        
\end{document}

Output: enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.