Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- \documentclass{beamer}
- \usepackage[utf8]{inputenc}
- \usepackage{amsmath}
- \usepackage{amssymb}
- \usepackage{tikz}
- \usepackage{xcolor}
- \title{Document 5 - Basics in TikZ}
- \author{Thomas Boufikos}
- \date{October 2021}
- \usetheme{Boadilla}
- \usecolortheme{whale}
- \begin{document}
- \begin{frame}{Basics TikZ commands}
- There is a red dot
- \begin{tikzpicture}
- \draw[fill=red] (0,0) circle [radius = 0.2];
- \end{tikzpicture}
- in the center of this sentence. \\ \\
- The red dot is now centered. \\
- \begin{center}
- \begin{tikzpicture}
- \draw[fill=red] (0,0) circle [radius = 0.2];
- \end{tikzpicture}
- \end{center}
- \end{frame}
- \begin{frame}{Drawing lines}
- \begin{center}
- \begin{tikzpicture}
- \draw (0,0) -- (3,2);
- \draw[red] (3,0) -- (0,2);
- \draw[yellow] (0,0) rectangle (3,2);
- \draw[blue] (-0.2, -0.2) -- (3.2, -0.2) -- (3.2, 2.2) -- (-0.2, 2.2) -- cycle;
- \draw[green, fill=green] (1.2, 0.8) rectangle (1.8, 1.2);
- \end{tikzpicture}
- \end{center}
- \end{frame}
- \begin{frame}{Shapes}
- This shape is a rectangle: \\
- \begin{tikzpicture}
- \draw[blue, fill=blue] (0,0) rectangle (2,3);
- \end{tikzpicture} \\ \\
- This one is a circle:
- \begin{tikzpicture}
- \draw[red, fill=green] (4,4) circle [radius = 0.5];
- \end{tikzpicture}
- \end{frame}
- \begin{frame}{Polar coordinates}
- I Will create an octagon with 8 angles (0, 45, ...., 315, 360). \\ \\
- \begin{center}
- \begin{tikzpicture}
- \draw[red, fill=red] (0:3) -- (45:3) -- (90:3) -- (135:3) -- (180:3) -- (225:3) -- (270:3) -- (315:3) -- cycle;
- \end{tikzpicture}
- \end{center}
- \end{frame}
- \begin{frame}{Relative Coordinates}
- \begin{center}
- \begin{tikzpicture}
- \draw[red, fill=red] (0,0) -- ++(2,0) -- ++(0,4);
- \draw[blue, fill=blue] (3,0) -- ++(2,0) -- ++(0,4);
- \draw[yellow, fill=yellow] (0,3) -- ++(2,0) -- ++(0,4);
- \draw[green, fill=green] (3,3) -- ++(2,0) -- ++(0,4);
- \end{tikzpicture}
- \end{center}
- \end{frame}
- \begin{frame}{Circle, ellipsis}
- Now, I am gonna draw 1 circle and 1 ellipsis.
- \begin{center}
- \begin{tikzpicture}
- \draw[blue, fill=blue] (0,0) circle [radius = 2];
- \draw[red] (0,0) circle [x radius = 2, y radius = 3];
- \draw[red, rotate = 45] (0,0) circle [x radius = 2, y radius = 3];
- \draw[yellow] (0,0) circle [y radius = 2, x radius = 3];
- \draw[yellow, rotate = -45] (0,0) circle [x radius = 2, y radius = 3];
- \end{tikzpicture}
- \end{center}
- \end{frame}
- \begin{frame}{Random Shape}
- \begin{center}
- \begin{tikzpicture}
- \draw[red, fill=red] (0,0) -- (2.2, 2.6) -- ++ (1.5, 1.5) -- ++(270, 1.2) -- cycle;
- \draw[green, fill=green] (1,1) rectangle (2,2);
- \draw[cyan, fill=cyan] (4,4) -| (5,5) -- cycle;
- \end{tikzpicture}
- \end{center}
- \end{frame}
- \begin{frame}{Nodes 1}
- \begin{center}
- \begin{tikzpicture}
- \draw (0,0) node[draw] {A};
- \draw (0,2) node[draw] {B};
- \draw (3,2) node[draw] {C};
- \end{tikzpicture}
- \end{center}
- \end{frame}
- \begin{frame}{Nodes 2}
- \begin{center}
- \begin{tikzpicture}
- \draw (0,0) node[draw] {A} -- (0,2) node[draw] {B} -- (3,2) node[draw] {C};
- \end{tikzpicture}
- \end{center}
- \end{frame}
- \begin{frame}{Nodes 3}
- \begin{center}
- \begin{tikzpicture}
- \draw (0,0) node[draw, fill=white] {A} -- (0,2) node[draw, fill=white] {B} -- (3,2) node[draw, fill=white] {C};
- \end{tikzpicture}
- \end{center}
- \end{frame}
- \begin{frame}{Code Order Matters 1}
- \begin{center}
- \begin{tikzpicture}
- \draw (0,0) node[fill=white] {Node A};
- \draw (-1,-1) -- (1,1);
- \draw (-1,1) -- (1,-1);
- \end{tikzpicture}
- \end{center}
- \end{frame}
- \begin{frame}{Code Order Matters 2}
- \begin{center}
- \begin{tikzpicture}
- \draw (-1,-1) -- (1,1);
- \draw (0,0) node[fill=white] {Node A};
- \draw (-1,1) -- (1,-1);
- \end{tikzpicture}
- \end{center}
- \end{frame}
- \begin{frame}{Code Order Matters 3}
- \begin{center}
- \begin{tikzpicture}
- \draw (-1,-1) -- (1,1);
- \draw (-1,1) -- (1,-1);
- \draw (0,0) node[fill=white] {Node A};
- \end{tikzpicture}
- \end{center}
- \end{frame}
- \definecolor{color1}{RGB}{128, 128, 128}
- \definecolor{color2}{RGB}{100, 228, 178}
- \definecolor{color3}{RGB}{188, 28, 218}
- \definecolor{color4}{RGB}{228, 18, 18}
- \begin{frame}{Random RGB colors and shift}
- \begin{center}
- \begin{tikzpicture}
- \draw[color1, fill=color1] (-1.5, -1.5) rectangle (0.5, 0.5);
- \draw[color2, fill=color2, shift={(0.5, 0.5)}] (-1,-1) rectangle (1,1);
- \draw[color3, fill=color3, shift={(1.5, 1.5)}] (-1,-1) rectangle (1,1);
- \draw[color4, fill=color4, shift={(2.5, 2.5)}] (-1,-1) rectangle (1,1);
- \end{tikzpicture}
- \end{center}
- \end{frame}
- \colorlet{color5}{red!0!blue}
- \colorlet{color6}{red!25!blue}
- \colorlet{color7}{red!50!blue}
- \colorlet{color8}{red!75!blue}
- \colorlet{color9}{red!100!blue}
- \begin{frame}{Colorlet package 1}
- Now, I will mix 2 colors: red and blue. This will happen 5 times. \\
- Each time in different proportion: 0 \% blue, 25 \%, 50\% and 75\% 100\%. \\ \\
- \begin{center}
- \begin{tikzpicture}
- \draw[color5, fill=color5] (-1.5, -1.5) rectangle (0.5, 0.5);
- \draw[color6, fill=color6, shift={(0.5, 0.5)}] (-1,-1) rectangle (1,1);
- \draw[color7, fill=color7, shift={(1.5, 1.5)}] (-1,-1) rectangle (1,1);
- \draw[color8, fill=color8, shift={(2.5, 2.5)}] (-1,-1) rectangle (1,1);
- \draw[color9, fill=color9, shift={(3.5, 3.5)}] (-1,-1) rectangle (1,1);
- \end{tikzpicture}
- \end{center}
- \end{frame}
- \colorlet{color5}{white!0!blue}
- \colorlet{color6}{white!20!blue}
- \colorlet{color7}{white!40!blue}
- \colorlet{color8}{white!60!blue}
- \colorlet{color9}{white!80!blue}
- \colorlet{color0}{white!100!blue}
- \begin{frame}{Colorlet package 2}
- Now, I will mix 2 colors: white and blue. This will happen 6 times. \\
- Each time in different proportion: 0 \% blue, 20 \%, 40\%, 60\%, 80\% and 100\%. \\ \\
- \begin{center}
- \begin{tikzpicture}
- \draw[color5, fill=color5] (-1.5, -1.5) rectangle (0.5, 0.5);
- \draw[color6, fill=color6, shift={(0.5, 0.5)}] (-1,-1) rectangle (1,1);
- \draw[color7, fill=color7, shift={(1.5, 1.5)}] (-1,-1) rectangle (1,1);
- \draw[color8, fill=color8, shift={(2.5, 2.5)}] (-1,-1) rectangle (1,1);
- \draw[color9, fill=color9, shift={(3.5, 3.5)}] (-1,-1) rectangle (1,1);
- \draw[color0, fill=color0, shift={(4.5, 4.5)}] (-1,-1) rectangle (1,1);
- \end{tikzpicture}
- \end{center}
- \end{frame}
- \begin{frame}{Filling shapes}
- \begin{center}
- \begin{tikzpicture}
- \draw[magenta, fill=magenta] (0,0) -- (1,1) -- (3,-1) -- (5,1) -- (7,-1) -- cycle;
- \draw[ultra thick, green, dotted] (-2,-2) rectangle (8,4);
- \draw[line width = 3pt, double, cyan] (-2.5, -2.5) rectangle (8.5, 4.5);
- \end{tikzpicture}
- \end{center}
- \end{frame}
- \begin{frame}{Transformations}
- \begin{center}
- \begin{tikzpicture}
- \draw[blue] (0,0) -- (2,0) -- (2,2) -- cycle;
- \draw (0.5, 0.5) node[draw, blue] {Original};
- \draw[red, xscale=2, yscale=2] (0,0) -- (2,0) -- (2,2) -- cycle;
- \draw (3,3) node[draw, red] {scaled=2};
- \draw[yellow, shift={(-2, -2)}] (0,0) -- (2,0) -- (2,2) -- cycle;
- \draw (-0.5, -0.5) node[draw, yellow] {Shift};
- \draw[green, rotate=120] (0,0) -- (2,0) -- (2,2) -- cycle;
- \draw (-1.2, 2.2) node[draw, green] {Rotate};
- \end{tikzpicture}
- \end{center}
- \end{frame}
- \begin{frame}{Node border}
- \begin{center}
- \begin{columns}
- \column{0.48 \linewidth}
- \begin{tikzpicture}
- \draw (0,0) node {No Border};
- \draw (0, -1) node[draw] {Black Border};
- \end{tikzpicture}
- \column{0.48 \linewidth}
- \begin{tikzpicture}
- \draw (0,0) node[fill=red] {Red fill};
- \draw (0, -1) node[draw, fill=red] {Red fill, black border};
- \draw (0, -2) node[blue, fill=red] {Red fill, blue text};
- \draw (0, -3) node[draw, blue, fill=red] {Red fill, black border, blue text};
- \end{tikzpicture}
- \end{columns}
- \end{center}
- \end{frame}
- \begin{frame}{Node placement}
- \begin{center}
- \begin{tikzpicture}
- \draw[green, <->] (-1,-1)-- (9,-1);
- \draw[green, <->] (-1,1) -- (9,1);
- \draw[red] (0,0) -- (8,0)
- node[pos=0] {0}
- node[pos=0.25] {0.25}
- node[pos=0.5] {0.5}
- node[pos=0.75] {0.75}
- node[pos=1] {1};
- \end{tikzpicture}
- \end{center}
- \end{frame}
- \end{document}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement