Advertisement
makispaiktis

Document 5 - Basics in Tikz (10-11)

Oct 8th, 2021 (edited)
628
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Latex 10.34 KB | None | 0 0
  1. \documentclass{beamer}
  2. \usepackage[utf8]{inputenc}
  3. \usepackage{amsmath}
  4. \usepackage{amssymb}
  5. \usepackage{tikz}
  6. \usepackage{xcolor}
  7.  
  8. \title{Document 5 - Basics in TikZ}
  9. \author{Thomas Boufikos}
  10. \date{October 2021}
  11. \usetheme{Boadilla}
  12. \usecolortheme{whale}
  13.  
  14. \begin{document}
  15.    
  16.    \begin{frame}{Basics TikZ commands}
  17.        There is a red dot
  18.        \begin{tikzpicture}
  19.            \draw[fill=red] (0,0) circle [radius = 0.2];
  20.        \end{tikzpicture}
  21.        in the center of this sentence. \\ \\
  22.        The red dot is now centered. \\
  23.        \begin{center}
  24.            \begin{tikzpicture}
  25.                    \draw[fill=red] (0,0) circle [radius = 0.2];
  26.            \end{tikzpicture}
  27.        \end{center}
  28.    \end{frame}
  29.    
  30.    \begin{frame}{Drawing lines}
  31.        \begin{center}
  32.            \begin{tikzpicture}
  33.                \draw (0,0) -- (3,2);
  34.                \draw[red] (3,0) -- (0,2);
  35.                \draw[yellow] (0,0) rectangle (3,2);
  36.                \draw[blue] (-0.2, -0.2) -- (3.2, -0.2) -- (3.2, 2.2) -- (-0.2, 2.2) -- cycle;
  37.                \draw[green, fill=green] (1.2, 0.8) rectangle (1.8, 1.2);
  38.            \end{tikzpicture}
  39.        \end{center}
  40.    \end{frame}
  41.    
  42.    \begin{frame}{Shapes}
  43.        This shape is a rectangle: \\
  44.        \begin{tikzpicture}
  45.            \draw[blue, fill=blue] (0,0) rectangle (2,3);
  46.        \end{tikzpicture} \\ \\
  47.        This one is a circle:
  48.        \begin{tikzpicture}
  49.            \draw[red, fill=green] (4,4) circle [radius = 0.5];
  50.        \end{tikzpicture}
  51.    \end{frame}
  52.    
  53.    \begin{frame}{Polar coordinates}
  54.        I Will create an octagon with 8 angles (0, 45, ...., 315, 360). \\ \\
  55.        \begin{center}
  56.            \begin{tikzpicture}
  57.                \draw[red, fill=red] (0:3) -- (45:3) -- (90:3) -- (135:3) -- (180:3) -- (225:3) -- (270:3) -- (315:3) -- cycle;
  58.            \end{tikzpicture}
  59.        \end{center}
  60.    \end{frame}
  61.    
  62.    \begin{frame}{Relative Coordinates}
  63.        \begin{center}
  64.            \begin{tikzpicture}
  65.                \draw[red, fill=red] (0,0) -- ++(2,0) -- ++(0,4);
  66.                \draw[blue, fill=blue] (3,0) -- ++(2,0) -- ++(0,4);
  67.                \draw[yellow, fill=yellow] (0,3) -- ++(2,0) -- ++(0,4);
  68.                \draw[green, fill=green] (3,3) -- ++(2,0) -- ++(0,4);
  69.            \end{tikzpicture}
  70.        \end{center}
  71.    \end{frame}
  72.    
  73.    \begin{frame}{Circle, ellipsis}
  74.        Now, I am gonna draw 1 circle and 1 ellipsis.
  75.        \begin{center}
  76.            \begin{tikzpicture}
  77.                \draw[blue, fill=blue] (0,0) circle [radius = 2];
  78.                \draw[red] (0,0) circle [x radius = 2, y radius = 3];
  79.                \draw[red, rotate = 45] (0,0) circle [x radius = 2, y radius = 3];
  80.                \draw[yellow] (0,0) circle [y radius = 2, x radius = 3];
  81.                \draw[yellow, rotate = -45] (0,0) circle [x radius = 2, y radius = 3];
  82.            \end{tikzpicture}
  83.        \end{center}
  84.    \end{frame}
  85.    
  86.    \begin{frame}{Random Shape}
  87.        \begin{center}
  88.            \begin{tikzpicture}
  89.                \draw[red, fill=red] (0,0) -- (2.2, 2.6) -- ++ (1.5, 1.5) -- ++(270, 1.2) -- cycle;
  90.                \draw[green, fill=green] (1,1) rectangle (2,2);
  91.                \draw[cyan, fill=cyan] (4,4) -| (5,5) -- cycle;
  92.            \end{tikzpicture}
  93.        \end{center}
  94.    \end{frame}
  95.    
  96.    \begin{frame}{Nodes 1}
  97.        \begin{center}
  98.            \begin{tikzpicture}
  99.                \draw (0,0) node[draw] {A};
  100.                \draw (0,2) node[draw] {B};
  101.                \draw (3,2) node[draw] {C};
  102.            \end{tikzpicture}
  103.        \end{center}
  104.    \end{frame}
  105.    
  106.    \begin{frame}{Nodes 2}
  107.        \begin{center}
  108.            \begin{tikzpicture}
  109.                \draw (0,0) node[draw] {A} -- (0,2) node[draw] {B} -- (3,2) node[draw] {C};
  110.            \end{tikzpicture}
  111.        \end{center}
  112.    \end{frame}
  113.    
  114.    \begin{frame}{Nodes 3}
  115.        \begin{center}
  116.            \begin{tikzpicture}
  117.                \draw (0,0) node[draw, fill=white] {A} -- (0,2) node[draw, fill=white] {B} -- (3,2) node[draw, fill=white] {C};
  118.            \end{tikzpicture}
  119.        \end{center}
  120.    \end{frame}
  121.    
  122.    \begin{frame}{Code Order Matters 1}
  123.        \begin{center}
  124.            \begin{tikzpicture}
  125.                \draw (0,0) node[fill=white] {Node A};
  126.                \draw (-1,-1) -- (1,1);
  127.                \draw (-1,1) -- (1,-1);
  128.            \end{tikzpicture}
  129.        \end{center}
  130.    \end{frame}
  131.    
  132.    \begin{frame}{Code Order Matters 2}
  133.        \begin{center}
  134.            \begin{tikzpicture}
  135.                \draw (-1,-1) -- (1,1);
  136.                \draw (0,0) node[fill=white] {Node A};
  137.                \draw (-1,1) -- (1,-1);
  138.            \end{tikzpicture}
  139.        \end{center}
  140.    \end{frame}
  141.    
  142.    \begin{frame}{Code Order Matters 3}
  143.        \begin{center}
  144.            \begin{tikzpicture}
  145.                \draw (-1,-1) -- (1,1);
  146.                \draw (-1,1) -- (1,-1);
  147.                \draw (0,0) node[fill=white] {Node A};
  148.            \end{tikzpicture}
  149.        \end{center}
  150.    \end{frame}
  151.    
  152.    \definecolor{color1}{RGB}{128, 128, 128}
  153.    \definecolor{color2}{RGB}{100, 228, 178}
  154.    \definecolor{color3}{RGB}{188, 28, 218}
  155.    \definecolor{color4}{RGB}{228, 18, 18}
  156.    
  157.    \begin{frame}{Random RGB colors and shift}
  158.        \begin{center}
  159.            \begin{tikzpicture}
  160.                \draw[color1, fill=color1] (-1.5, -1.5) rectangle (0.5, 0.5);
  161.                \draw[color2, fill=color2, shift={(0.5, 0.5)}] (-1,-1) rectangle (1,1);
  162.                \draw[color3, fill=color3, shift={(1.5, 1.5)}] (-1,-1) rectangle (1,1);
  163.                \draw[color4, fill=color4, shift={(2.5, 2.5)}] (-1,-1) rectangle (1,1);
  164.            \end{tikzpicture}
  165.        \end{center}
  166.    \end{frame}
  167.    
  168.    
  169.    \colorlet{color5}{red!0!blue}
  170.    \colorlet{color6}{red!25!blue}
  171.    \colorlet{color7}{red!50!blue}
  172.    \colorlet{color8}{red!75!blue}
  173.    \colorlet{color9}{red!100!blue}
  174.    
  175.    \begin{frame}{Colorlet package 1}
  176.        Now, I will mix 2 colors: red and blue. This will happen 5 times. \\
  177.        Each time in different proportion: 0 \% blue, 25 \%, 50\% and 75\% 100\%. \\ \\
  178.        \begin{center}
  179.            \begin{tikzpicture}
  180.                \draw[color5, fill=color5] (-1.5, -1.5) rectangle (0.5, 0.5);
  181.                \draw[color6, fill=color6, shift={(0.5, 0.5)}] (-1,-1) rectangle (1,1);
  182.                \draw[color7, fill=color7, shift={(1.5, 1.5)}] (-1,-1) rectangle (1,1);
  183.                \draw[color8, fill=color8, shift={(2.5, 2.5)}] (-1,-1) rectangle (1,1);
  184.                \draw[color9, fill=color9, shift={(3.5, 3.5)}] (-1,-1) rectangle (1,1);
  185.            \end{tikzpicture}
  186.        \end{center}
  187.    \end{frame}
  188.    
  189.    
  190.    \colorlet{color5}{white!0!blue}
  191.    \colorlet{color6}{white!20!blue}
  192.    \colorlet{color7}{white!40!blue}
  193.    \colorlet{color8}{white!60!blue}
  194.    \colorlet{color9}{white!80!blue}
  195.    \colorlet{color0}{white!100!blue}
  196.    
  197.    
  198.    \begin{frame}{Colorlet package 2}
  199.        Now, I will mix 2 colors: white and blue. This will happen 6 times. \\
  200.        Each time in different proportion: 0 \% blue, 20 \%, 40\%, 60\%, 80\% and 100\%. \\ \\
  201.        \begin{center}
  202.            \begin{tikzpicture}
  203.                \draw[color5, fill=color5] (-1.5, -1.5) rectangle (0.5, 0.5);
  204.                \draw[color6, fill=color6, shift={(0.5, 0.5)}] (-1,-1) rectangle (1,1);
  205.                \draw[color7, fill=color7, shift={(1.5, 1.5)}] (-1,-1) rectangle (1,1);
  206.                \draw[color8, fill=color8, shift={(2.5, 2.5)}] (-1,-1) rectangle (1,1);
  207.                \draw[color9, fill=color9, shift={(3.5, 3.5)}] (-1,-1) rectangle (1,1);
  208.                \draw[color0, fill=color0, shift={(4.5, 4.5)}] (-1,-1) rectangle (1,1);
  209.            \end{tikzpicture}
  210.        \end{center}
  211.    \end{frame}
  212.    
  213.    \begin{frame}{Filling shapes}
  214.        \begin{center}
  215.            \begin{tikzpicture}
  216.                \draw[magenta, fill=magenta] (0,0) -- (1,1) -- (3,-1) -- (5,1) -- (7,-1) -- cycle;
  217.                \draw[ultra thick, green, dotted] (-2,-2) rectangle (8,4);
  218.                \draw[line width = 3pt, double, cyan] (-2.5, -2.5) rectangle (8.5, 4.5);
  219.            \end{tikzpicture}
  220.        \end{center}
  221.    \end{frame}
  222.    
  223.    \begin{frame}{Transformations}
  224.        \begin{center}
  225.            \begin{tikzpicture}
  226.                \draw[blue] (0,0) -- (2,0) -- (2,2) -- cycle;
  227.                \draw (0.5, 0.5) node[draw, blue] {Original};
  228.                \draw[red, xscale=2, yscale=2] (0,0) -- (2,0) -- (2,2) -- cycle;
  229.                \draw (3,3) node[draw, red] {scaled=2};
  230.                \draw[yellow, shift={(-2, -2)}] (0,0) -- (2,0) -- (2,2) -- cycle;
  231.                \draw (-0.5, -0.5) node[draw, yellow] {Shift};
  232.                \draw[green, rotate=120] (0,0) -- (2,0) -- (2,2) -- cycle;
  233.                \draw (-1.2, 2.2) node[draw, green] {Rotate};
  234.            \end{tikzpicture}
  235.        \end{center}
  236.    \end{frame}
  237.    
  238.    \begin{frame}{Node border}
  239.        \begin{center}
  240.            \begin{columns}
  241.                    \column{0.48 \linewidth}
  242.                        \begin{tikzpicture}
  243.                            \draw (0,0) node {No Border};
  244.                            \draw (0, -1) node[draw] {Black Border};
  245.                        \end{tikzpicture}
  246.                    \column{0.48 \linewidth}
  247.                        \begin{tikzpicture}
  248.                            \draw (0,0) node[fill=red] {Red fill};
  249.                            \draw (0, -1) node[draw, fill=red] {Red fill, black border};
  250.                            \draw (0, -2) node[blue, fill=red] {Red fill, blue text};
  251.                            \draw (0, -3) node[draw, blue, fill=red] {Red fill, black border, blue text};
  252.                        \end{tikzpicture}
  253.            \end{columns}
  254.        \end{center}
  255.    \end{frame}
  256.    
  257.    \begin{frame}{Node placement}
  258.        \begin{center}
  259.            \begin{tikzpicture}
  260.                \draw[green, <->] (-1,-1)-- (9,-1);
  261.                \draw[green, <->] (-1,1) -- (9,1);
  262.                \draw[red] (0,0) -- (8,0)
  263.                 node[pos=0] {0}
  264.                 node[pos=0.25] {0.25}
  265.                 node[pos=0.5] {0.5}
  266.                 node[pos=0.75] {0.75}
  267.                 node[pos=1] {1};
  268.            \end{tikzpicture}
  269.        \end{center}
  270.    \end{frame}
  271.  
  272. \end{document}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement