Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I wish to draw the picture like below, however, I don't know how to add multiple lines in side the circle.

enter image description here

This is my code:

\documentclass[tikz]{standalone}
\usetikzlibrary{
    shapes.geometric,
    positioning,
    fit,
    calc
}
\usepackage{tikz}
\begin{document}
\tikzset{
 block/.style = {circle, draw,
    text width=1em,align=center,inner sep=0pt},
  line/.style = {draw,thick,->},
}
\begin{tikzpicture}
\node [block,fill=yellow] (s1) {3};
\end{tikzpicture}
\end{document} 
share|improve this question
    
Are you just concerned about the lines, or do you also want to reproduce the colour gradient? –  Jake Feb 21 '13 at 8:41
    
Search for clipping a path in the TikZ manual –  Lionel MANSUY Feb 21 '13 at 8:43
    
@Jake Actually both. Thanks –  sweetyBaby Feb 21 '13 at 8:46
    
Since you have some responses below that seem to answer your question, please consider marking one of them as ‘Accepted’ by clicking on the tickmark below their vote count (see How do you accept an answer?). This shows which answer helped you most, and it assigns reputation points to the author of the answer (and to you!). It's part of this site's idea to identify good questions and answers through upvotes and acceptance of answers. –  Jubobs May 4 '13 at 13:44
add comment

3 Answers 3

You can use a hatched picture as a mask and put your desired fading to be seen through that hatching. Simple example

\documentclass[tikz,border=5mm]{standalone}
\usetikzlibrary{fadings,patterns}%

\begin{tikzfadingfrompicture}[name=hatch fade]%
\foreach\x in{-10,...,10}{
\draw[ultra thick,transparent!20] ([xshift=2*\x mm]-1cm,-1cm) -- ([xshift=2*\x mm]1cm,1cm);
}
\end{tikzfadingfrompicture}


\begin{document}

\begin{tikzpicture}
\node[path fading=hatch fade,fit fading,
font=\sffamily,
circle,
top color=yellow,bottom color=black,
]
{\small 3};
\end{tikzpicture}

\end{document}

enter image description here

share|improve this answer
    
Try also fit fading=false –  percusse Feb 21 '13 at 11:39
    
That's really nice.. I always forget how much powerful is tikzfadingfrompicture. :) –  Claudio Fiandrino Feb 21 '13 at 11:49
add comment

This is one possible solution: the only library needed is patterns.

When one defines:

\node [
  pattern=north east lines,
  left color=orange,
  right color=yellow,
  ] (<name>) at (<some where>) {<text>}; 

or

\node [
  left color=orange,
  right color=yellow,
  pattern=north east lines] (<name>) at (<some where>) {<text>}; 

the problem is that the pattern is overridden by the shading. Thus, one possibility is to define a style exploiting the path picture which allows to mix the shading and the pattern; for example:

 my pattern/.style args={#1 colored by #2}{%
   path picture={
     \node[pattern=#1,pattern color=#2] at (path picture bounding box.center) {};
   }
 },

In such a way, the definition of:

\node [
  my pattern=<some pattern> colored by <some color>,
  left color=orange,
  right color=yellow,      
  ] (<name>) at (<some where>) {<text>}; 

or

\node [
  left color=orange,
  right color=yellow,
  my pattern=<some pattern> colored by <some color>
  ] (<name>) at (<some where>) {<text>};

both work. Moreover, the solution allows to easily select the gradient style to fill the node; the keys:

\pgfkeys{/tikz/.cd,
  gradient style init/.initial=left color,
  gradient style init/.get=\grsi,
  gradient style init/.store in=\grsi,
  gradient style end/.initial=right color,
  gradient style end/.get=\grse,
  gradient style end/.store in=\grse,
}

are devoted to the type choice and the style

  my gradient/.style args={#1 and #2}{%
   \grsi=#1,
   \grse=#2,
 },

to the color choice.

The code:

\documentclass[tikz,border=2pt,png]{standalone}

\usepackage{tikz}
\usetikzlibrary{patterns}

\pgfkeys{/tikz/.cd,
  gradient style init/.initial=left color,
  gradient style init/.get=\grsi,
  gradient style init/.store in=\grsi,
  gradient style end/.initial=right color,
  gradient style end/.get=\grse,
  gradient style end/.store in=\grse,
}

\tikzset{
 block/.style = {circle, draw,
    text width=1em,align=center,inner sep=0pt}, 
 my pattern/.style args={#1 colored by #2}{%
   path picture={
     \node[pattern=#1,pattern color=#2] at (path picture bounding box.center) {};
   }
 },
 my gradient/.style args={#1 and #2}{%
   \grsi=#1,
   \grse=#2,
 },
}

\begin{document}

\begin{tikzpicture}
\node [minimum size=1.75cm,
  block,
  my pattern=north east lines colored by blue!50,
  my gradient=orange!60 and yellow!40] (s1) {1};

% Changing gradient style
\tikzset{gradient style init=top color,
         gradient style end=bottom color}         
\node [minimum size=1.5cm,
  right of=s1,
  block,
  my pattern=north west lines colored by blue!60,
  my gradient=white and green!50] (s2) at (s1.east) {2};

% Changing gradient style
\tikzset{gradient style init=inner color,
         gradient style end=outer color}
\node [minimum size=1.25cm,
  right of=s2,
  block,
  my pattern=crosshatch dots colored by magenta!60,
  my gradient=violet!50!magenta!25 and violet!50!magenta!5] (s3) at (s2.east) {3};

\end{tikzpicture}

\end{document}

The result:

enter image description here

share|improve this answer
    
thanks, however, when I tried your method, there only two lines in the circle. –  sweetyBaby Feb 21 '13 at 11:41
    
@sweetyBaby: which pattern you applied and which circle's dimension? –  Claudio Fiandrino Feb 21 '13 at 11:48
    
\tikzset{gradient style init=top color, gradient style end=bottom color} this pattern –  sweetyBaby Feb 21 '13 at 11:58
    
@sweetyBaby: I meant my pattern=... and minimum size –  Claudio Fiandrino Feb 21 '13 at 12:08
    
I didn't use minimum size, my pattern=north east lines colored by blue!50. –  sweetyBaby Feb 21 '13 at 14:38
show 1 more comment

Another solution (except for the shading)

\begin{tikzpicture}

\coordinate (O) at (0,0);

\begin{scope}[rotate=30]
\coordinate (sw) at (-2ex,-2ex); 
\coordinate (ne) at (2ex,2ex);
\clip (0,0) circle (2ex); % clip the surface
\path (ne) -- (sw) % calculate points
    coordinate[pos=.167] (a)
    coordinate[pos=.333] (b)
    coordinate[pos=.500] (c)
    coordinate[pos=.667] (d)
    coordinate[pos=.833] (e);
% draw lines
\draw[blue,very thich] (sw |- a) -- (ne |- a);
\draw[blue,very thich] (sw |- b) -- (ne |- b);
\draw[blue,very thich] (sw |- c) -- (ne |- c);
\draw[blue,very thich] (sw |- d) -- (ne |- d);
\draw[blue,very thich] (sw |- e) -- (ne |- e);
\end{scope}

\draw[thick] (O) circle (2ex);
\node[fill=white,inner sep=.2pt] at (O) {3};
\end{tikzpicture}

enter image description here

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.