30

In my attempt to create an eye icon to illustrate something in my notes, I came up with the following:

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[scale=0.25]
\filldraw[color=black] (0,0) circle (1.5cm);
\fill[color=white] (0,0) circle (1cm);
\draw[very thick](-3,0) .. controls (-2,2) and (2,2) .. (3,0) .. controls (2,-2) and (-2,-2) .. (-3,0)--cycle;
\end{tikzpicture}
\end{document}

This produces:

enter image description here

The problem I would have is to resize the diagram in that I do not like how the inner circles are independent of the eye design. May be using nodes would help a lot. Essentially I would like the inner circles shrink and expand with respect to the outer shape. I know that scale and transform shape can help but I am looking for something flexible like \tikzeye{<height>}{<width>} or \tikzeye{<scale>}. Any other designs or variants are welcome. I know the dingbat package has an \eye command defined but it is not too flexible.

EDIT:

I like the clipping idea. If a point P1 and P2 are on the circle and point Q1 and Q2 on the curve, how can make these points, P1 and Q1 and P2 and Q2 be the equal respectively given that P1 and Q1 are at the top and P2 and Q2 are at the bottom? See image below.

\begin{tikzpicture}[scale=0.25]
\filldraw[color=black] (0,0) circle (1.5cm);                                 % Circle with points P1 and P2
\fill[color=white] (0,0) circle (1cm);
\filldraw[color=blue] (0,1.5) circle (3pt) node[above] {{\footnotesize p1}}; % Point P1 on the circle.
\filldraw[color=blue] (0,-1.5) circle (3pt) node[below] {{\footnotesize p2}};% Point P2 on the circle.

\draw[very thick,yshift=6cm](-3,0) .. controls (-2,2) and (2,2) .. (3,0) .. controls (2,-2) and (-2,-2) .. (-3,0)--cycle;                                                                % Curve in question
\filldraw[color=blue] (0,7.5) circle (3pt) node[above] {{\footnotesize q1}};% Point Q1 on the curve.
\filldraw[color=blue] (0,4.5) circle (3pt) node[below] {{\footnotesize q2}};% Point Q2 on the curve.
\end{tikzpicture}

enter image description here

3
  • 1
    I don't understand... currently if you use scale=0.5 in your code, you get an eye of double size (even the inner circles). Anyway, you can also put your whole tikz picture inside a \scalebox (from graphics package) and thus even the line thickness will be scaled, or use \resizebox to specify the final height and width.
    – JLDiaz
    Commented Jan 16, 2013 at 15:50
  • 1
    I know it's funnier with TikZ. But in this answer Marco Daniel shows how to use \eye symbol from dingbat package and mdframed package to highlight some text.
    – Ignasi
    Commented Jan 16, 2013 at 17:36
  • Regarding your edition, I still don't get what do you want. Apparently you want the iris (circle) and the lids (curves) to be tangent, but I don't see how the clipping would do anything in this case. And anyway, your first drawing already has those objects tangent...
    – JLDiaz
    Commented Jan 16, 2013 at 23:19

1 Answer 1

75

This is my version of your eye, trying to give an aspect a bit more organic:

\def\eyepath{(-3,0) .. controls (-2,1.8) and (2,2.2) .. (2.7,0) .. controls (2,-1.2) and (-2,-1.4) .. (-3,0)--cycle;}


\begin{tikzpicture}[scale=0.25]
\clip\eyepath;
\filldraw[color=orange!50!black] (-.2,.2) circle (1.5);
\fill[color=black] (-.2,.2) circle (0.7);
\fill[color=white] (.3,.5) circle (0.2);
\draw[very thick]\eyepath;
\end{tikzpicture}

eye

In relation with your question, you can put this tikzpicture inside a \scalebox (from graphicx package) to get any desired size. Note also that my eye is slightly assymmetrical. You can use \reflectbox to get the other eye :-)

Update

I could not resist it, and I tried a more realistic eye (probably not in the spirit of the question, sorry!)

\documentclass{article}
\usepackage{tikz}
\usepackage{graphicx}
\usetikzlibrary{calc,decorations.pathmorphing}
\begin{document}

\def\eye#1{\scalebox{#1}{
\def\topedge{(-3,0) .. controls (-2,1.8) and (2,2) .. (2.3,.3)}
\def\bottomedge{(2.3,.3) .. controls (2,-2.2) and (-2,-1.2) .. (-3,0)}
\def\eyepath{\topedge -- \bottomedge --cycle;}

\begin{tikzpicture}[scale=0.25]
  \clip\eyepath;
  % Iris
    \filldraw[color=orange!30!black] (-.2,.2) circle (1.4);
  % Shadow on iris
    \filldraw[color=orange!40!black] (-.3,-.1) circle (1.1);
  % Iris lines
    \foreach \a in {0,5,...,360}{
      \pgfmathparse{25+28*rnd}
      \fill[orange!\pgfmathresult!black, decoration={random steps, segment length=1pt, amplitude=0.3pt}, decorate, line width=0.3pt  ] (-.2,.2) -- ++($(\a+2*rnd:.8+0.3*rnd)$) -- ++(\a+90:3pt) -- cycle;
    }
  % Pupil
    \fill[color=black] (-.2,.2) circle (0.5);
  % Sun reflection
    \fill[color=white] (90:.8) {[rotate=-30] circle (0.2 and 0.12)};
  % Shadow of the eyelid
    \draw[line width=2.5mm, draw opacity=0.1, line cap=round]\topedge;
  % Eyelids
    \draw[line width=1mm, red!40!white!80!black, line cap=round]\bottomedge;
    \draw[line width=1.2mm, red!40!white!60!black, line cap=round]\topedge;
  % Lacrimal
    \fill[red!40!white!80!black] (-2.8,0) circle (.25);
    \fill[white] (-2.7,.1) circle (.03);
\end{tikzpicture}
}}

\eye{1}
\end{document}

Eye

4
  • I like the clipping idea. If a point P1 and P2 are on the circle and point Q1 and Q2 on the curve, how can make these points, P1|Q1 and P2|Q2 be the same respectively given that P1 and Q1 are at the top and P2 and Q2 are at the bottom?
    – azetina
    Commented Jan 16, 2013 at 18:10
  • I'm lost... could you rephrase your question? What does P1|Q1 mean? What does "be the same respectively" mean?
    – JLDiaz
    Commented Jan 16, 2013 at 18:21
  • See my updated question.
    – azetina
    Commented Jan 16, 2013 at 18:46
  • 1
    I couldn't resist upvoting! +1
    – hpesoj626
    Commented Jan 17, 2013 at 7:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .