1

How to make these codes more expressive??

\begin{tikzpicture}[scale=.8, font=\footnotesize]
    \begin{axis}[domain=-1:15, xmin=-1, xmax=13, ymin=-1, ymax=14, axis y line=center, axis x line=middle]  


    \node[purple,visible on=<2->] (O) [below left] at (axis cs:0,0) {$0$};

        \draw [fill, purple,visible on=<3->] (axis cs: 0,10) circle [radius=3pt];
        \draw [fill, purple,visible on=<3->] (axis cs: 10,0) circle [radius=3pt];
        \node [visible on=<4>] at (axis cs: 6,10) {Connect the points};
        \addplot +[mark=none,fill,opacity=3, blue,visible on=<4->,thick,<->,domain=-1:11] {10-x}  node[pos=0] (blue) {};
        \node[right = of blue,visible on=<5->] () {\color{blue}\footnotesize {$x+y=10$}};

        \node[purple,visible on=<5->] (B) [above right] at (axis cs:8,5) {\Large It's Easy!};
    \end{axis}
    \end{tikzpicture}

I am using the above codes to generate a small example of "How to construct a line for school children?" in beamer.

How one can improve these codes more expressive?

for example, if I can connect the points (10,0) to (0,10) by tracing its quite good to realize rather than not just showing the line in the next slide.

Suggestion are welcome?

Should I have to go with animate? or any easy way to do that?

What I got is this.. enter image description here

David
  • 1,964
  • Please always post a *complete* MWE which people can compile. It matters a great deal, for example, that you are using a non-standard class and loading various packages! – cfr Jul 28 '16 at 13:02

1 Answers1

4

Just an idea using pencil and ruler from symbols of pencil, ruler and compass

enter image description here

First I've taken Harish code and adapted to:

\documentclass[tikz,border=0cm]{standalone}
\usepackage{tikz}

\tikzset{
    pencil/.pic={
        \fill[gray!50] (0,4) -- (0.4,4) -- (0.4,0) --(0.3,-0.15) -- (0.2,0) -- (0.1,-0.14) -- (0,0) -- cycle;
      \draw[color=white] (0.2,4) -- (0.2,0);
      \fill[red] (0,3.5) -- (0.2,3.47) -- (0.4,3.5) -- (0.4,4) arc(30:150:0.23cm);
      \fill[brown!40] (0,0) -- (0.2,-0.8)node[coordinate,pos=0.75](a){} -- (0.4,0)node[coordinate,pos=0.25](b){} -- (0.3,-0.15) -- (0.2,0) -- (0.1,-0.14) -- cycle;
      \fill[red] (a) -- (0.2,-0.8) -- (b) -- cycle;
    },
    ruler/.pic={
            \begin{scope}[rotate=0, transform shape]
            \draw (-0.2,0) rectangle (10.2,1);
            %% Upper divisions
            \foreach \x in {0,1,...,10}{
            \draw (\x,1) -- (\x,0.8)node[below,scale=0.4]{\x};
            }
            \foreach \x in {0.1,0.2,...,9.9}{
            \draw (\x,1) -- (\x,0.925);
            }
            \foreach \x in {0.5,1,...,9.5}{
            \draw (\x,1) -- (\x,0.85);
            }
                \end{scope}
    }
}   
\begin{document}
        \begin{tikzpicture}
        \draw pic[]{ruler=10cm};
        \end{tikzpicture}
        \begin{tikzpicture}
        \draw pic[]{pencil};
        \end{tikzpicture}
\end{document}

I've tried to use pencil and ruler as pics inside beamer presentation but I couldn't afford it (mainly due to scale problems), so i finally converted it to external graphics which where included in presentation with \includegraphics inside a node.

The code for previous presentation is:

\documentclass{beamer}
\usepackage{pgfplots}
\usetikzlibrary{positioning}

\tikzset{
    invisible/.style={opacity=0},
    visible on/.style={alt={#1{}{invisible}}},
    alt/.code args={<#1>#2#3}{%
      \alt<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}} % \pgfkeysalso doesn't change the path
    }
}    

\begin{document}

\begin{frame}[fragile]{}
\begin{tikzpicture}[scale=.8, font=\footnotesize]
    \begin{axis}[domain=-1:15, xmin=-1, xmax=13, ymin=-1, ymax=14, axis y line=center, axis x line=middle, clip =false]  

    \node[purple,visible on=<2->] (O) [below left] at (axis cs:0,0) {$0$};
    \draw [fill, purple,visible on=<3->] (axis cs: 0,10) circle [radius=3pt];
    \draw [fill, purple,visible on=<3->] (axis cs: 10,0) circle [radius=3pt];
    \node [visible on=<4>, inner sep=0pt, outer sep=0pt, anchor=170, rotate=-50] at (axis cs:0,10) {\includegraphics[page=1]{ruler-pencil}};

    \node [visible on=<5-8>, inner sep=0pt, outer sep=0pt, anchor=170, rotate=-37.7] at (axis cs:0,10) {\includegraphics[page=1]{ruler-pencil}};

    \node [visible on=<6>, inner sep=0pt, outer sep=0pt, anchor=south, rotate=-20] at (axis cs:-1,11) {\includegraphics[page=2,scale=.75]{ruler-pencil}};

    \node [visible on=<7>, inner sep=0pt, outer sep=0pt, anchor=south, rotate=-20] at (axis cs:4,6) {\includegraphics[page=2,scale=.75]{ruler-pencil}};

    \node [visible on=<8>, inner sep=0pt, outer sep=0pt, anchor=south, rotate=-20] at (axis cs:11,-1) {\includegraphics[page=2]{ruler-pencil}};

    \addplot +[mark=none,fill,opacity=3, red,visible on=<7>,thick,<->,domain=-1:4] {10-x}  node[pos=0] (blue) {};

    \addplot +[mark=none,fill,opacity=3, red,visible on=<8->,thick,<->,domain=-1:11] {10-x}  node[pos=0] (blue) {};

    \node[right = of blue,visible on=<9->] () {\color{red}\footnotesize {$x+y=10$}};
    \node[purple,visible on=<9->] (B) [above right] at (axis cs:8,5) {\Large It's Easy!};
    \end{axis}
\end{tikzpicture}
\end{frame}
\end{document}

I should say that rotation angle for ruler has been found by trial and error because x and y axis scales are different.

Ignasi
  • 136,588