Do you have a question regarding this example, TikZ or LaTeX in general? Just ask in the
LaTeX Forum.
Oder frag auf Deutsch auf TeXwelt.de.
En français: TeXnique.fr.
% Poppy flower
% Author: Elena Botoeva
\documentclass{article}
\usepackage[margin=0.3cm, paperwidth=9.5cm, paperheight=9.5cm]{geometry}
\usepackage{tikz}
\usetikzlibrary{fadings}
\definecolor{darkgreen}{rgb}{0.2,0.6,0.2}
\definecolor{poppyred}{rgb}{0.89,0.08,0.3}
\definecolor{poppyredd}{rgb}{0.78,0.0,0.09}
\definecolor{poppyreddd}{rgb}{0.63,0.0,0.0}
\def\petala{
[rounded corners=3] (0,0) %
.. controls (-0.25,-0.5) and (-1.25,0.3) .. (-1.6,0) %
.. controls (-1.6,0.75) and (-1.25,0.65) .. (-1.1,1) %
.. controls (-1.05,0.65) and (-0.05,0.7) .. (0,0)}
\def\petalb{
[rounded corners=3] (0,0)%
.. controls (-0.55,-0.2) and (-1.25,0.7) .. (-1.5,0.6)%
.. controls (-1.4,1.1) and (-1.15,0.9) .. (-0.75,1.4)%
.. controls (-0.5,1.5) and (-0.05,1.45) .. (0.05,1.3)%
.. controls (-0.15,1.1) and (0.25,0.05) .. (0,0)}
\def\petalc{[rotate=-30] \petalb}
\def\petald{[rotate=-90] \petala}
\def\petiolea{
[rounded corners=2] (0.25,-7) %
.. controls (0.7,-5.5) and (0.3,-3) .. (0.25,-2) %
.. controls (0.2,-1.5) and (0.33,-0.4) .. (0,0) %
.. controls (0.34,-0.4) and (0.21,-1.5) .. (0.27,-2) %
.. controls (0.4,-3) and (0.82,-5.5) .. (0.42,-7)
}
\def\petioleb{
[rounded corners=2] (0.1,-7) %
.. controls (0.3,-3) and (-0.85,-1.05) .. (-2.3,-1) %
arc (270:230:0.2)%
.. controls (-2.7,-1) and (-3.05,-1.05) .. (-3.35,-1.3) %
.. controls (-3.35,-1.5) and (-3.45,-1.75) .. (-3.65,-1.75) %
.. controls (-3.7,-1.25) and (-3.4,-1.35) .. (-3.4,-1.25) %
.. controls (-3.05,-0.95) and (-2.7,-0.9) .. (-2.4,-0.85) %
.. controls (-1.1,-0.75) and (0.4,-2.45) .. (0.2,-7)
}
\def\petiolec{
[rounded corners=2] (-0.3,-7) %
.. controls (-0.9,-3.5) and (-1.5,-2.7) .. (-2,-2.5) %
.. controls (-2.5,-2.3) and (-3.2,-2.35) .. (-3.47,-3.5) %
.. controls (-3.68,-3.85) and (-3.75,-4.2) .. (-3.9,-4.15) %
.. controls (-4.0,-3.9) and (-3.8,-3.8) .. (-3.7,-3.8) %
.. controls (-3.65,-3.75) and (-3.6,-3.7) .. (-3.5,-3.47) %
.. controls (-3.2,-2.3) and (-2.5,-2.25) .. (-2,-2.45) %
.. controls (-1.48,-2.65) and (-0.86,-3.5) .. (-0.26,-7)
}
\tikzfading[name=fade inside,
inner color=transparent!100,
outer color=transparent!30]
\tikzfading[name=fade out,
inner color=transparent!0,
outer color=transparent!100]
%%%------beautiful flower------%%%
\def\flower{
% draw each petal independently
\foreach \a in {\petala,\petalb,\petalc,\petald}
{
\filldraw[draw=none,color=poppyred,opacity=0.8]
[postaction={path fading=south,fading angle=30,fill=poppyreddd,opacity=.2}]
\a;
}
% draw all petals together
\draw[draw=none,rounded corners=3]
[postaction={path fading=north,fading angle=30,fill=poppyreddd,opacity=.7}]
\petala \petalb \petalc [rotate=30] \petald;
% emphasise overlapping areas between two petals
\begin{scope}
\foreach \a/\b in {\petala/\petalb,\petalb/\petalc,\petalc/\petald}
{
\begin{scope}
\clip \a;
\draw [draw=none]
[postaction={path fading=fade inside,fill=poppyredd,opacity=.7}]
\b;
\end{scope}
}
\end{scope}
% emphasise overlapping areas between three petals
\begin{scope}
\foreach \a/\b/\c in {\petala/\petalb/\petalc,\petalb/\petalc/\petald}
{
\begin{scope}
\clip \a;
\clip \b;
\draw [draw=none]
[postaction={path fading=fade out,fill=poppyreddd,opacity=.4}]
\c;
\end{scope}
}
\end{scope}
}
\def\petioles[#1]{
\foreach \a in {\petiolea,\petioleb,\petiolec}
{
\draw[fill,color=#1] \a;
}
}
%%% -----------POPPIES---------------- %%%
% beautiful poppy
\def\poppy[#1,#2]{
\begin{scope}[shift={#1},scale=#2]
% draw the flower
\flower;
% draw petioles
\petioles[darkgreen]
\end{scope}
}
% poppy with uniform color
\def\poppyu[#1,#2]{
\begin{scope}[shift={#1},scale=#2]
% draw the flower
\foreach \a in {\petala,\petalb,\petalc,\petald}
{
\filldraw[draw=none,color=poppyred,opacity=0.8]
\a;
}
% draw petioles
\petioles[darkgreen]
\end{scope}
}
% black and white poppy
\def\poppybw[#1,#2]{
\begin{scope}[shift={#1},scale=#2]
% draw the flower
\foreach \a in {\petala,\petalb,\petalc,\petald}
{
\filldraw[draw=none,color=gray!80,opacity=1]
\a;
}
% draw petioles
\petioles[gray!80]
\end{scope}
}
\begin{document}
\thispagestyle{empty}
\begin{center}
\tikz\poppy[{(0cm,0cm)},1];
\tikz\poppyu[{(4cm,0cm)},1];
\tikz\poppybw[{(7cm,0cm)},0.8];
\end{center}
\end{document}
Comments
Wow. Did you type this up manually? I am very impressed!
Thanks, I am glad you like it. Yes, I typed it manually :-) but the most interesting part for me was fading the flower, so that it does not look plain
This is really nice, good work!
I was curious if you ever thought of changing the structure of your blog?
Its very well written; I love what youve got to say.
But maybe you could a little more in the way of content so people could connect with it better. Youve got an awful lot of text for only having 1 or two pictures. Maybe you could space it out better?
Adding comments is currently not enabled.