In [1]:
%load_ext autoreload
%autoreload 2
from __future__ import division, print_function
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
np.set_printoptions(precision=4)#, suppress=True)
%cd -q ../scripts/
I use the tikmagic described in http://blog.invibe.net/posts/2015-01-20-using-tikzmagic.html
In [2]:
import tikzmagic
In [3]:
%%tikz
\newcommand{\tstar}[5]{% inner radius, outer radius, tips, rot angle, options
\pgfmathsetmacro{\starangle}{360/#3}
\draw[#5] (#4:#1)
\foreach \x in {1,...,#3}
{ -- (#4+\x*\starangle-\starangle/2:#2) -- (#4+\x*\starangle:#1)
}
-- cycle;
}
\newcommand{\ngram}[4]{% outer radius, tips, rot angle, options
\pgfmathsetmacro{\starangle}{360/#2}
\pgfmathsetmacro{\innerradius}{#1*sin(90-\starangle)/sin(90+\starangle/2)}
\tstar{\innerradius}{#1}{#2}{#3}{#4}
}
\begin{scope}[xshift=0, yshift=0cm,scale=5]
\draw[anchor=north west] (-.15, 1) node {$\mathsf{(A)}$};
\draw[gray,very thick] (0, 0) rectangle (1., 1) ;
\draw[black!30,very thick, anchor=south] (0.12, .49) rectangle (0.14, .51) ;
\draw[red, ->] (0.17, .5) -- (0.83, .5) ;
\draw[black,very thick] (0.49, .49) rectangle (0.51, .51) ;
\tstar{0.01}{0.04}{5}{21}{orange,thick,fill=orange,xshift=.5cm, yshift=.43cm}
\draw[black,very thick] (0.49, .42) rectangle (0.51, .44) ;
\end{scope}
\begin{scope}[xshift=6.5cm, yshift=-0cm,scale =5]
\draw[anchor=north west] (-.15, 1) node {$\mathsf{(B)}$};
\draw[gray,very thick, dashed] (0, 0) rectangle (1., 1) ;
\draw[red, ->] (0.17, .5) -- (0.83, .5) ;
\draw[black!30,very thick] (0.12, .49) rectangle (0.14, .51) ;
\draw[black!30,very thick] (0.49, .49) rectangle (0.51, .51) ;
\draw[black,very thick] (0.56, .49) rectangle (0.58, .51) ;
\tstar{0.01}{0.04}{5}{21}{orange,thick,fill=orange,xshift=.5cm, yshift=.43cm}
\draw[black,very thick] (0.49, .42) rectangle (0.51, .44) ;
\end{scope}
% perhaps add limit cycles ...
Out[3]:
In [4]:
%%tikz
\newcommand{\tstar}[5]{% inner radius, outer radius, tips, rot angle, options
\pgfmathsetmacro{\starangle}{360/#3}
\draw[#5] (#4:#1)
\foreach \x in {1,...,#3}
{ -- (#4+\x*\starangle-\starangle/2:#2) -- (#4+\x*\starangle:#1)
}
-- cycle;
}
\newcommand{\ngram}[4]{% outer radius, tips, rot angle, options
\pgfmathsetmacro{\starangle}{360/#2}
\pgfmathsetmacro{\innerradius}{#1*sin(90-\starangle)/sin(90+\starangle/2)}
\tstar{\innerradius}{#1}{#2}{#3}{#4}
}
\begin{scope}[xshift=-6.5cm, yshift=-0cm, scale=5]
\draw[anchor=north west] (-.15, 1) node {$\mathsf{(A)}$};
\draw[gray,very thick] (0, 0) rectangle (1., 1) ;
\draw[black,very thick] (0.12, .49) rectangle (0.14, .51) ;
\draw[red, ->] (0.17, .5) -- (0.83, .5) ;
\end{scope}
\begin{scope}[xshift=0, yshift=0cm,scale=5]
\draw[anchor=north west] (-.15, 1) node {$\mathsf{(B)}$};
\draw[gray,very thick] (0, 0) rectangle (1., 1) ;
\draw[black!30,very thick] (0.12, .49) rectangle (0.14, .51) ;
\draw[red, ->] (0.17, .5) -- (0.83, .5) ;
\draw[black,very thick] (0.49, .49) rectangle (0.51, .51) ;
\tstar{0.01}{0.04}{5}{21}{orange,thick,fill=orange,xshift=.5cm, yshift=.43cm}
\draw[black,very thick] (0.49, .42) rectangle (0.51, .44) ;
\end{scope}
\begin{scope}[xshift=6.5cm, yshift=-0cm,scale =5]
\draw[anchor=north west] (-.15, 1) node {$\mathsf{(C)}$};
\draw[gray,very thick] (0, 0) rectangle (1., 1) ;
\draw[red, ->] (0.17, .5) -- (0.83, .5) ;
\draw[black!30,very thick] (0.12, .49) rectangle (0.14, .51) ;
\draw[black!30,very thick] (0.49, .49) rectangle (0.51, .51) ;
\draw[black,very thick] (0.56, .49) rectangle (0.58, .51) ;
\tstar{0.01}{0.04}{5}{21}{orange,thick,fill=orange,xshift=.5cm, yshift=.43cm}
\draw[black,very thick] (0.49, .42) rectangle (0.51, .44) ;
\end{scope}
\begin{scope}[xshift=-6.5cm, yshift=-6.cm,scale =5]
\draw[anchor=north west] (-.15, 1) node {$\mathsf{(D)}$};
\draw[gray,very thick] (0, 0) rectangle (1., 1) ;
\draw[black,very thick] (0.12, .49) rectangle (0.14, .51) ;
\draw[red, ->] (0.17, .5) -- (0.83, .5) ;
\draw[black,very thick] (0.12, .49) rectangle (0.14, .51) ;
\draw[black!30,very thick] (0.49, .49) rectangle (0.51, .51) ;
\draw[black!30,very thick] (0.86, .49) rectangle (0.88, .51) ;
\tstar{0.01}{0.04}{5}{21}{orange,thick,fill=orange,xshift=.13cm, yshift=.43cm}
\draw[black,very thick] (.12, .42) rectangle (0.14, .44) ;
\end{scope}
\begin{scope}[xshift=0, yshift=-6cm,scale =5]
\draw[anchor=north west] (-.15, 1) node {$\mathsf{(E)}$};
\draw[gray,very thick] (0, 0) rectangle (1., 1) ;
\draw[black,very thick] (0.49, .49) rectangle (0.51, .51) ;
\draw[red, ->] (0.17, .5) -- (0.83, .5) ;
\draw[black!30,very thick] (0.12, .49) rectangle (0.14, .51) ;
\draw[black,very thick] (0.49, .49) rectangle (0.51, .51) ;
\draw[black!30,very thick] (0.86, .49) rectangle (0.88, .51) ;
\tstar{0.01}{0.04}{5}{21}{orange,thick,fill=orange,xshift=.5cm, yshift=.43cm}
\draw[black,very thick] (0.49, .42) rectangle (0.51, .44) ;
\end{scope}
\begin{scope}[xshift=6.5cm, yshift=-6cm,scale =5]
\draw[anchor=north west] (-.150, 1) node {$\mathsf{(F)}$};
\draw[gray,very thick] (0, 0) rectangle (1., 1) ;
\draw[black,very thick] (0.12, .49) rectangle (0.14, .51) ;
\draw[red, ->] (0.17, .5) -- (0.83, .5) ;
\draw[black!30,very thick] (0.12, .49) rectangle (0.14, .51) ;
\draw[black!30,very thick] (0.49, .49) rectangle (0.51, .51) ;
\draw[black,very thick] (0.86, .49) rectangle (0.88, .51) ;
\tstar{0.01}{0.04}{5}{21}{orange,thick,fill=orange,xshift=.87cm, yshift=.43cm}
\draw[black,very thick] (.86, .42) rectangle (.88, .44) ;
\end{scope}
Out[4]:
In [5]:
%%tikz --debug -l fadings,arrows.meta,decorations.pathmorphing -e ../figures/FLE_cartoon.pdf
\newcommand{\tstar}[5]{% inner radius, outer radius, tips, rot angle, options
\pgfmathsetmacro{\starangle}{360/#3}
\draw[#5] (#4:#1)
\foreach \x in {1,...,#3}
{ -- (#4+\x*\starangle-\starangle/2:#2) -- (#4+\x*\starangle:#1)
}
-- cycle;
}
\begin{scope}[scale =2]
\begin{scope}[xshift=6.5cm, yshift=-0cm, scale =5]
\draw[white, fill=white] (0.13, 0.3) rectangle (.84, .65) ;
\draw[green!50!black, densely dash dot dot] (0.5, .35) -- (0.5, .65) ;
%\draw[green!50!black, densely dash dot dot] (0.5, .05) -- (0.5, .65) ;
\node[anchor=south] (player1) at (0.17, .5) {\includegraphics[width=.06\textwidth]{../figures/cartoon/player_running.png}} ;
\node[anchor=south] (player2) at (0.50, .5) {\includegraphics[width=.06\textwidth]{../figures/cartoon/player_running.png}} ;
\node[anchor=south] (player3) at (0.58, .5) {\includegraphics[width=.06\textwidth]{../figures/cartoon/player_running_red.png}} ;
\draw[left color=green!60!black, right color=green, fill=green, arrows = {-Stealth[white, fill=green,length=12pt]}] (0.17, .5) -- (0.83, .5) ;
\path[left color=green!60!black, right color=green] (0.17, .502) rectangle (0.82, .498); % "line with gradient"
\draw[green!60!black,very thick] (0.16, .49) rectangle (0.18, .51) ;
\draw[green!80,very thick] (0.49, .49) rectangle (0.51, .51) ;
\draw[red!80,very thick] (0.56, .49) rectangle (0.58, .51) ;
\node[anchor=south] (ball) at (0.5, .3) {\includegraphics[width=.03\textwidth]{../figures/cartoon/football.png}} ;
\node[anchor=south] (shooter) at (0.4, .3) {\includegraphics[width=.1\textwidth]{../figures/cartoon/player.jpg}} ;
\tstar{0.01}{0.03}{5}{0}{red, thick, fill=orange, xshift=.5cm, yshift=.42cm}
\tstar{0.009}{0.03}{5}{0}{red, thick, xshift=.5cm, yshift=.42cm}
\draw[black,very thick] (0.49, .41) rectangle (0.51, .43) ;
%\node[anchor=south] (referee) at (0.5, .01) {\includegraphics[width=.1\textwidth]{../figures/cartoon/referee.png}} ;
\end{scope}
\end{scope}
Out[5]:
In [6]:
!convert -density 300 -units pixelsperinch ../figures/FLE_cartoon.pdf ../figures/FLE_cartoon.jpg
!convert -density 600 -flatten -compress lzw -units pixelsperinch -depth 8 ../figures/FLE_cartoon.pdf ../figures/FLE_cartoon.tiff
!echo "width=" ; convert ../figures/FLE_cartoon.tiff -format "%[fx:w]" info:
!echo ", \nheight=" ; convert ../figures/FLE_cartoon.tiff -format "%[fx:h]" info:
!echo ", \nunit=" ; convert ../figures/FLE_cartoon.tiff -format "%U" info:
from IPython.display import Image
Image('../figures/FLE_cartoon.jpg')
Out[6]:
In [7]:
from default_param import fig_width, inches_per_pt, inches_per_cm
width = 19.05 #(cm)
width_in = width * inches_per_cm
width_in, 1273 / 450
Out[7]:
In [10]:
#!git rm ../figures/FLE-cartoon.svg
#!git add figure_1_FLE_cartoon.ipynb
!git status
In [9]:
!git commit -m' figure FLE_cartoon : updating tiff' ../figures/cartoon/referee.jpg ../khoei17fle.tex ../notebooks/figure_1_FLE* ../figures/cartoon/football.png ../figures/cartoon/player_running.png ../figures/FLE_cartoon* ../figures/cartoon/player_running_red.png ../figures/cartoon/referee.png
#! git push