1

Desired Output

enter image description here

My MWE

Borrowed the code from here.

% Dartboard.
% Author: Roberto Bonvallet <[email protected]>
% Under Creative Commons attribution license.

\documentclass[tikz]{standalone}
\usepackage{mathpazo}

\tikzstyle{wired}=[draw=gray!30, line width=0.15mm]
\tikzstyle{number}=[anchor=center, color=white]
% Sectors are numbered 0-19 counterclockwise from the top.

% \strip{color}{sector}{outer_radius}{inner_radius}
\newcommand{\strip}[4]{
    \filldraw[#1, wired]
      ({18 *  #2}      :                   #3) arc
      ({18 *  #2}      : {18 * (#2 + 1)} : #3) --
      ({18 * (#2 + 1)} :                   #4) arc
      ({18 * (#2 + 1)} : {18 *  #2}      : #4) -- cycle;
}

% \sector{color}{sector}{radius}
\newcommand{\sector}[3]{
    \filldraw[#1, wired]
      (0, 0) --
      ({18 * #2} :                   #3) arc
      ({18 * #2} : {18 * (#2 + 1)} : #3) -- cycle;
}

\begin{document}

% 81 degrees = 4.5 sectors.
% The rotation leaves 20 at the top.
\begin{tikzpicture}[rotate=81, scale=.14]

  % These are the official dartboard dimensions as per BDO's regulations.

  % The whole board's background.
  \fill[black] (0, 0) circle (225.5mm);

  % Even sections.
  \foreach\i in {0,2,...,18} {
    \sector{black}{\i}{162mm}
    \strip{red}{\i}{170mm}{162mm} % Double strip.
    \strip{red}{\i}{107mm}{ 99mm} % Treble strip.
  }

  % Odd sections.
  \foreach\i in {1,3,...,19} {
    \sector{white}{\i}{162mm}
    \strip{green}{\i}{170mm}{162mm} % Double strip.
    \strip{green}{\i}{107mm}{ 99mm} % Treble strip.
  }

  % Bull's ring and eye.
  \filldraw[green, wired] (0, 0) circle (15.9mm);
  \filldraw[red,   wired] (0, 0) circle (6.35mm);

  % Labels.
  \foreach \sector/\label in {%
      0/20,  1/ 1,  2/18,  3/ 4,  4/13,
      5/ 6,  6/10,  7/15,  8/ 2,  9/17,
     10/ 3, 11/19, 12/ 7, 13/16, 14/ 8,
     15/11, 16/14, 17/ 9, 18/12, 19/ 5}%
  {
    \node[number] at ({18 * (-\sector + .5)} : 197.75mm) {\label};
  }
\end{tikzpicture}

\end{document}

Output

enter image description here

Questions

  1. My MWE produces there wrongly pages. How to correct this?
  2. How to put arrows?

Thanks in advance for your help.

5
  • 2
    Nice one, but personally I would not use tikz for it. Instead I would use Adobe Illustrator / Inkscape / ... (any vector graphics editor), export to PDF and include it. Seems to be less work and faster. Commented May 10, 2014 at 17:59
  • 1
    For starters, comment out lines 3-5, starting with \usepackage{pdftex,.. and ending with \usepackage{mathpazo}. None of that stuff is necessary for it to compile correctly (and then you will also get a single page). Commented May 10, 2014 at 18:03
  • @jlv (+1). Thanks for useful comment. Much appreciated.
    – MYaseen208
    Commented May 10, 2014 at 18:07
  • 2
    If you can draw a dart board with TikZ, surely you can also draw the darts?
    – Jake
    Commented May 10, 2014 at 18:11
  • 2
    @Jake The dartboard is just copied from the linked example in the question. The OP hasn't made any attempt beyond finding the image and copying the code. (Though I would actually have some idea how to create the board - at least in metapost but maybe tikz - but no idea how to do the darts or turn the board.)
    – cfr
    Commented May 10, 2014 at 22:19

2 Answers 2

19
+50

About the darts:

\documentclass{article}
\usepackage{tikz}
\begin{document}
\colorlet{gold}{orange!50!yellow}
\def\dart#1#2#3{ % 1 = tip position, 2 = rotation angle, 3 = dart color
  \begin{scope}[rotate=#2]
  \colorlet{dart color}{#3}
  % tip
  \fill[top color=black!30, bottom color=black!60, middle color=white] 
     (#1) ++(0,0) -- ++(1,0.04) -- ++(0,-0.04) -- cycle;
  % golden mass
  \fill[top color=gold, bottom color=gold!60!black, middle color=gold!20!white]
    (#1) ++(0.99,0) to[out=90, in=180] ++(0.2, 0.2) -- ++(0.5, 0) -- ++(0, -0.4) -- ++(-0.5,0) to[out=180, in=-90] ++(-0.2,0.2) -- cycle;
  % wings
  \fill[top color=dart color!20!white, bottom color=dart color!10!black, middle color=dart color!70!white] 
    (#1) ++(4.5,0) to[out=60, in=150] ++(3.1,1) -- ++(-0.3,-1) -- cycle;
  \fill[top color=dart color!20!black, bottom color=dart color] 
    (#1) ++(4.5,0) to[out=-60, in=-150] ++(3.1,-1) -- ++(-0.3,1) -- cycle;
  % body
  \fill[top color=dart color!20!white, bottom color=dart color!10!black, middle color=dart color] 
    (#1) ++(1.7,0.2) .. controls +(1,.2) and +(-4,.4) .. ++(6,-0.2) .. controls +(-4, -.4) and +(1,-.2) .. ++(-6, -0.2) -- cycle;
\end{scope}
}

\begin{tikzpicture} % Demo
\dart{0,0}{30}{yellow}
\dart{0,0}{-10}{red}
\dart{0,0}{10}{green!70!cyan}
\dart{0,0}{-25}{blue!50!cyan}
\dart{0,0}{30}{yellow}
\end{tikzpicture}
\end{document}

Result:

Darts

Integration with the bullseye:

\documentclass{article}
\usepackage{tikz}
\begin{document}
\colorlet{gold}{orange!50!yellow}
\def\dart#1#2#3{ % 1 = tip position, 2 = rotation angle, 3 = dart color
  \begin{scope}[rotate=#2, scale=0.3]
  \colorlet{dart color}{#3}
  % tip
  \fill[top color=black!30, bottom color=black!60, middle color=white] 
     (#1) ++(0,0) -- ++(1,0.04) -- ++(0,-0.04) -- cycle;
  % golden mass
  \fill[top color=gold, bottom color=gold!60!black, middle color=gold!20!white]
    (#1) ++(0.99,0) to[out=90, in=180] ++(0.2, 0.2) -- ++(0.5, 0) -- ++(0, -0.4) -- ++(-0.5,0) to[out=180, in=-90] ++(-0.2,0.2) -- cycle;
  % wings
  \fill[top color=dart color!20!white, bottom color=dart color!10!black, middle color=dart color!70!white] 
    (#1) ++(4.5,0) to[out=60, in=150] ++(3.1,1) -- ++(-0.3,-1) -- cycle;
  \fill[top color=dart color!20!black, bottom color=dart color] 
    (#1) ++(4.5,0) to[out=-60, in=-150] ++(3.1,-1) -- ++(-0.3,1) -- cycle;
  % body
  \fill[top color=dart color!20!white, bottom color=dart color!10!black, middle color=dart color] 
    (#1) ++(1.7,0.2) .. controls +(1,.2) and +(-4,.4) .. ++(6,-0.2) .. controls +(-4, -.4) and +(1,-.2) .. ++(-6, -0.2) -- cycle;
\end{scope}
}

% The code from next line to line marked with % <<<END is from:
% Dartboard.
% Author: Roberto Bonvallet <[email protected]>
% Under Creative Commons attribution license.    
\tikzstyle{wired}=[draw=gray!30, line width=0.15mm]
\tikzstyle{number}=[anchor=center, color=white]
% Sectors are numbered 0-19 counterclockwise from the top.

% \strip{color}{sector}{outer_radius}{inner_radius}
\newcommand{\strip}[4]{
    \filldraw[#1, wired]
      ({18 *  #2}      :                   #3) arc
      ({18 *  #2}      : {18 * (#2 + 1)} : #3) --
      ({18 * (#2 + 1)} :                   #4) arc
      ({18 * (#2 + 1)} : {18 *  #2}      : #4) -- cycle;
}

% \sector{color}{sector}{radius}
\newcommand{\sector}[3]{
    \filldraw[#1, wired]
      (0, 0) --
      ({18 * #2} :                   #3) arc
      ({18 * #2} : {18 * (#2 + 1)} : #3) -- cycle;
}


% 81 degrees = 4.5 sectors.
% The rotation leaves 20 at the top.
\begin{tikzpicture}
% Next scope and its options are not from the original code,
% but added here to better integrate with my darts
\begin{scope}[rotate=81,scale=0.14,  yscale=0.7]
  % These are the official dartboard dimensions as per BDO's regulations.

  % The whole board's background.
  \fill[black] (0, 0) circle (225.5mm);

  % Even sections.
  \foreach\i in {0,2,...,18} {
    \sector{black}{\i}{162mm}
    \strip{red}{\i}{170mm}{162mm} % Double strip.
    \strip{red}{\i}{107mm}{ 99mm} % Treble strip.
  }

  % Odd sections.
  \foreach\i in {1,3,...,19} {
    \sector{white}{\i}{162mm}
    \strip{green}{\i}{170mm}{162mm} % Double strip.
    \strip{green}{\i}{107mm}{ 99mm} % Treble strip.
  }

  % Bull's ring and eye.
  \filldraw[green, wired] (0, 0) circle (15.9mm);
  \filldraw[red,   wired] (0, 0) circle (6.35mm);

  % Labels.
  \foreach \sector/\label in {%
      0/20,  1/ 1,  2/18,  3/ 4,  4/13,
      5/ 6,  6/10,  7/15,  8/ 2,  9/17,
     10/ 3, 11/19, 12/ 7, 13/16, 14/ 8,
     15/11, 16/14, 17/ 9, 18/12, 19/ 5}%
  {
    \node[number] at ({18 * (-\sector + .5)} : 197.75mm) {\label};
  }
\end{scope}
% <<<END of the code by Roberto Bonvallet

\dart{0,0}{30}{yellow}
\dart{0,0}{-10}{red}
\dart{0,0}{10}{green!70!cyan}
\dart{0,0}{-25}{blue!50!cyan}
\dart{0,0}{30}{yellow}
\end{tikzpicture}
\end{document}

Result:

Final

Update:

Improved the "perspective", by using canvas transformations. Also added a brown circle to fake some depth in the dartboard:

New

The only changes in the code are at the beginning of the tikzpicture:

\begin{tikzpicture}
% Next scope and its options are not from the original code,
% but added here to better integrate with my darts
\begin{scope}[rotate=81,scale=0.14,  transform canvas={xscale=0.6,xslant=-0.3}]
  % These are the official dartboard dimensions as per BDO's regulations.

  % The whole board's background.
  \fill[brown!80!black] (-1,2) circle (225.5mm);  % <-- Fake "depth"
  \fill[black] (0, 0) circle (225.5mm);

 % The remaining is unchanged...

Update 2

(Last one, promised ;-))

I think the result is improved by changing the font used for the numbers:

\node[number] at ({18 * (-\sector + .5)} : 197.75mm) {\sffamily\bfseries\large\label};

Last one

9
  • It's really nice, but it looks a little odd that the numbers move but don't tilt when the board is tilted - can they be scaled narrower perhaps?
    – Chris H
    Commented May 15, 2014 at 10:48
  • 1
    @ChrisH You are right. See my update
    – JLDiaz
    Commented May 15, 2014 at 11:12
  • Very nice indeed!
    – Chris H
    Commented May 15, 2014 at 11:14
  • 2
    Where is the copyright notice ? :P
    – percusse
    Commented May 15, 2014 at 11:19
  • @percusse It is indeed. A bit buried, but it is. Just when the borrowed code starts :-)
    – JLDiaz
    Commented May 15, 2014 at 11:21
4

This was just a trial. I tried to make the board slanting and added numbers to it. I have used the asymptote package. Here is the code:

\documentclass{standalone}
\usepackage{asymptote}
\begin{document}
\begin{asy}
size(3cm);
path p1 = ellipse((1,0), 9, 10);
path p2 = ellipse((1,0), 8.8, 9.8);
path p3 = ellipse((1,0), 7, 8);
draw(rotate(30)*p1);
fill(rotate(30)*p1, gray);
draw(rotate(30)*p2);
fill(rotate(30)*p2, white);
draw(rotate(30)*p3);
fill(rotate(30)*p2);
fill(rotate(30)*p3, white);
label("20", (1,9),white);
label("8", (9,1),white);
label("11", (1,-8.2),white);
label("2", (-7.5,0.8),white);
\end{asy}
\end{document}

The output generated is:

enter image description here

Now, this seems a very tedious task with traditional TikZ. However, with the asymptote package 75% is possible (experts can go upto 100% but need a good amount of patience). I have shown the methodology to draw slanted ellipses and fill the intersected regions. Follow the same procedure for all the ellipses and the corresponding labels. To get the 3d effect of the arrow, you can go something like this (if you are satisfied):
enter image description here
The corresponding MWE for this is:

settings.render=16;
import three;
size(4cm,0);
draw(O--2X ^^ O--2Y ^^ O--2Z);
triple circleCenter = (Y+Z)/sqrt(2) +
X;
path3 mycircle =
circle(c=circleCenter, r=1,
normal=Y+Z);
draw(plane(O=sqrt(2)*Z, 2X, 2*unit(Y-Z)), gray + 0.1cyan);
draw(mycircle, blue);
draw(shift(circleCenter) * (O -- Y+Z), green, arrow=Arrow3());

(the above is the asy code which you need to add in the \begin{asy} and \end{asy}).

You must log in to answer this question.

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