Using PSTricks to draw the Olympics Rings

The other day I ran into a person who’s asking people to draw the five Olympics rings by writing latex source codes only. I said, well, I could do that, using pstricks, which was my favorite drawing tool in latex.

After inspecting the Olympics logo for a while, I had a rough idea how to draw it. The key was to draw the five rings in the order: blue, yellow, black, green, and red. For each ring, draw a circle at that color with a certain line width, and then surround the circle with two white slim circles. This gave the salient pattern of the five rings and at the intersection of two rings some whites. The rest of the job was to make the interleaving effect of the five rings instead of seeing the yellow ring placed above the blue ring and so on. The trick was, after drawing the blue and the yellow rings, draw a blue arc at the place where the blue should be on top of the yellow at one of the intersection of the two rings. For the rest of the rings, do the same trick. Drawing the arcs was almost the same as drawing the rings (a colored circle squeezed by two slim white circles), except that an arc was part of a circle from some degree to some degree.

Okay, enough explanation. Here are the pstricks codes.

% This file draws the Olympic rings using PSTricks.
% File name: rings.tex
% Compile:
%  $ latex rings
%  $ dvips rings -E -o rings.eps
%  $ eps2png -width 600 rings.eps

\documentclass{article}
\usepackage[dvipsnames]{pstricks}
\pagestyle{empty}

\definecolor{myblue}{rgb}{0,.52,.78}
\definecolor{myyellow}{rgb}{.96,.76,0}
\definecolor{mygreen}{rgb}{0,.62,.24}
\definecolor{myred}{rgb}{.87,0,.14}

\newcommand{\drawring}[1]{%
\pscircle[linewidth=.25,linecolor=#1](0,0){1.375}%
\pscircle[linewidth=.05,linecolor=white](0,0){1.425}%
\pscircle[linewidth=.05,linecolor=white](0,0){1.125}%
}

\newcommand{\drawarc}[3]{%
\psarc[linewidth=.25,linecolor=#1](0,0){1.25}{#2}{#3}%
\psarc[linewidth=.05,linecolor=white](0,0){1.4}{#2}{#3}%
\psarc[linewidth=.05,linecolor=white](0,0){1.1}{#2}{#3}%
}

\begin{document}

\color{white}
\fboxsep=0pt
\fbox{

\begin{pspicture}(-4.5,-3)(4.5,1.5)
%\psgrid
\rput(-3,0){\drawring{myblue}}
\rput(-1.5,-1.375){\drawring{myyellow}}
\rput(-3,0){\drawarc{myblue}{330}{30}}
\rput(0,0){\drawring{black}}
\rput(-1.5,-1.375){\drawarc{myyellow}{30}{90}}
\rput(1.5,-1.375){\drawring{mygreen}}
\rput(0,0){\drawarc{black}{330}{30}}
\rput(3,0){\drawring{myred}}
\rput(1.5,-1.375){\drawarc{mygreen}{30}{90}}

\end{pspicture}

}
\end{document}

And this is the result:

Oh, by the way, remember the day this post was initialized, Aug 8, 2008. It’s the day for which we Chinese have been dreaming for years.

Advertisements

4 Responses to “Using PSTricks to draw the Olympics Rings”


  1. 1 Kjell Magne Fauske August 15, 2008 at 7:03 am

    Hi,

    You have a really nice blog with many interesting and useful examples! I am currently collecting feeds for a TeX-related feed aggregator: http://www.texample.net/community/

    Can I add your feed to aggregator?

    Regards,
    Kjell Magne Fauske

  2. 2 Jie August 15, 2008 at 11:43 am

    Yes, that will be a great idea. I do not update the blog too often, and I did not expect many people reading the entries here, though I really think some posts are interesting and helpful. So go ahead. I enjoy a back-link for my blog 🙂

    Jie

  3. 3 Kjell Magne Fauske August 15, 2008 at 12:16 pm

    Thank you Jie. I have now added your feed. I hope that it will lead to more visits to your site. Keep on blogging!

    Note. Only post in the latex category will be added.

    Regards,
    Kjell Magne Fauske

  4. 4 sandrar September 10, 2009 at 6:07 pm

    Hi! I was surfing and found your blog post… nice! I love your blog. 🙂 Cheers! Sandra. R.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




Categories

Blog Stats

  • 247,883 hits

%d bloggers like this: