7

Consider the following:

\documentclass{article}

\usepackage{pstricks-add}

\begin{document}

\begin{figure}
 \centering
  \begin{pspicture}(2.4,0.6)
   \rput(1.2,0.25){Springboldene}
%   \psset{linestyle=none}
   \multido{\r=0.3+0.45}{5}{\pscircle(\r,0.3){0.3}}
  \end{pspicture}
\end{figure}

\end{document}

How do I fill the five circles with a gradient color that stretches over all five of them, starting with orange at the left and going to green at the right?

I would like to remove the circles themselves (therefore linestyle=none) but fill the inner of them, as explained.

  • Do you want to fill each individual circle with a gradient, or should the gradient stretch over the total width of the five circles? – Jake Mar 21 '13 at 16:26
  • The gradient should strech over all five circles. (I'll specify it in my question.) – Svend Tveskæg Mar 21 '13 at 16:28
  • If you can construct the outline of the Audi logo then you can use a clip a gradient rectangle with that. – percusse Mar 21 '13 at 16:32
  • What does the Audi logo has to do with it? :( I would just like to have a gradient fill of the five circles. – Svend Tveskæg Mar 21 '13 at 16:35
  • @SvendMortensen Think of the five circles combined as in Jake's answer. The outline of five circles I mean. Well Audi logo + one more circle. :) – percusse Mar 21 '13 at 16:40
7
\documentclass{article}   
\usepackage{pst-grad,multido}   
\begin{document}

  \begin{pspicture}(-12ex,-3.5ex)(12ex,3.5ex)
  \pscustom[linestyle=none,fillstyle=gradient,gradangle=-90,
    gradbegin=orange!90!red,gradend=green!80!orange,
    gradmidpoint=0]{%
     \multido{\rA=-8+4}{5}{\pscircle(\rA ex,0){3ex}}}
  \rput(0,0){\large\textbf{Springboldene}}
  \end{pspicture}

\end{document}

enter image description here

and the same for a gradmidpoint=0.5

enter image description here

enter image description here

  • @SvendMortensen: There is also pst-slpe that provides fillstyle=slope (and friends). – Werner Mar 21 '13 at 17:34
  • @Werner Nice. I'll probably use this. – Svend Tveskæg Mar 21 '13 at 18:04
3

Here's how you can do it using TikZ: The filling will stretch over all circles as long as they're specified using a single \path (or \shade) command

\documentclass{article}

\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
\shade [left color=orange!90!red, right color=green!80!orange]
    \foreach \i in {-2,...,2}{
     (\i*3.5ex,0) circle [radius=2.5ex]
};
\node [font=\bfseries] (A) {Springboldene};
\end{tikzpicture}

\end{document}
  • Nice. I would like to use PSTricks, though. – Svend Tveskæg Mar 21 '13 at 16:38
  • 3
    @SvendMortensen: Yes, sorry, your question is quite clear about that. It has just become customary that TikZ questions also get a PSTricks answer, and vice versa. I'm sure Herbert or KarlsStudents will come up with a PSTricks approach soon. – Jake Mar 21 '13 at 16:40
  • Have you pinged any of them? :) – Svend Tveskæg Mar 21 '13 at 16:43
  • @SvendMortensen: There's no global ping, unfortunately, but I think they monitor the {pstricks} tag quite closely. – Jake Mar 21 '13 at 16:44
  • Okay. If no PSTricks solution appears, I'll accept your answer (but you can always get an upvote, which you will). – Svend Tveskæg Mar 21 '13 at 16:46
2

My code seems to be verbose but the extra code is actually to get the precise dimension and placement. It also make you more convenient to adjust the parameters.

enter image description here

\documentclass[pstricks,border=0pt]{standalone}
\usepackage{multido}
\usepackage{pst-grad}
\usepackage[nomessages]{fp}


\newpsstyle{A}
{
    fillstyle=gradient,
    gradbegin=red,
    gradend=yellow,
    gradangle=30,
    gradmidpoint=0.5,
}

\psset{linestyle=none}


\def\greeting{Springboldene}
\def\hoffset{5pt}
\def\voffset{5pt}



\newsavebox\IBox
\savebox\IBox{\raisebox{\depth}{\greeting}}

\newlength\Left
\newlength\Right
\newlength\Top
\newlength\Bottom


\Left=\dimexpr-0.5\wd\IBox-\hoffset
\Right=\dimexpr0.5\wd\IBox+\hoffset
\Top=\dimexpr0.5\ht\IBox+\voffset
\Bottom=\dimexpr-0.5\ht\IBox-\voffset

% for circles
\FPset\a{-27.00}
\FPset\b{27.00}
\FPset\N{7}
\FPeval\step{round((b-a)/N:2)}
\FPeval\NplusOne{N+1}

\begin{document}
\begin{pspicture}(\Left,\Bottom)(\Right,\Top)
  \psclip{\pscustom{\multido{\nx=\a+\step}{\NplusOne}{\pscircle(\nx pt,0){8pt}}}}
      \psframe[style=A](\Left,\Bottom)(\Right,\Top) 
    \endpsclip
    \rput(0,0){\usebox\IBox}
  \end{pspicture}
\end{document}
  • There are too many circles – Jake Mar 21 '13 at 17:42
  • @Jake: I will adjust the parameters in the next update. – kiss my armpit Mar 21 '13 at 18:00
  • I cannot really follow what you are doing, but it looks fancy. :) Can you explain the code a bit, please? – Svend Tveskæg Mar 22 '13 at 12:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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