# Highlighting chunks of text spiral

I use the code provided in this question to draw a text spiral and now I want to highlight each chunk separated with a comma in a different color. Is there a way to achieve that?

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.text}

\makeatletter

\let\pgf@lib@dec@text@dobox@original=\pgf@lib@dec@text@dobox%

\def\pgf@lib@dec@text@dobox{%
\pgf@lib@dec@text@dobox@original%
\ifpgfdecorationtextalongpathscaletext%
\pgfmathparse{\pgf@lib@dec@text@endscale+(\pgf@lib@dec@text@startscale-\pgf@lib@dec@text@endscale)*\pgfdecoratedremainingdistance/\pgfdecoratedpathlength}%
\setbox\pgf@lib@dec@text@box=\hbox{\scalebox{\pgfmathresult}{\box\pgf@lib@dec@text@box}}%
\fi%
}
\newif\ifpgfdecorationtextalongpathscaletext
\def\pgf@lib@dec@text@startscale{1}
\def\pgf@lib@dec@text@endscale{1}

\pgfkeys{/pgf/decoration/.cd,
text path start scale/.code={%
\pgfdecorationtextalongpathscaletexttrue%
\def\pgf@lib@dec@text@startscale{#1}%
},
text path end scale/.code={%
\pgfdecorationtextalongpathscaletexttrue%
\def\pgf@lib@dec@text@endscale{#1}%
}
}
\begin{document}
\begin{tikzpicture}[
decoration={
reverse path,
text along path,
text path start scale=1.5,
text path end scale=0,
text={Lorem ipsum dolor sit amet, consectetur adipisicing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua,
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
pariatur, Excepteur sint occaecat cupidatat non proident, sunt
inculpa qui officia deserunt mollit anim id est laborum}}
]
\draw [decorate]
(0,0)
\foreach \i [evaluate={\r=(\i/2000)^2;}] in {0,5,...,2880}{ -- (\i:\r)};
\useasboundingbox (-2.75,-2.75) rectangle (2.75,2.75);
\end{tikzpicture}
\end{document}


I could not find an image that I have in mind but something similar to the below diagram, but there should be also text in the color blocks. I do not care about the arrow like decoration.

-

I'm not sure I understood the question but this does something with commas and colours

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.text}

\makeatletter

\def\zr{red}
\def\zy{yellow}
\def\zcomma{,}
\let\z\zr
\let\pgf@lib@dec@text@dobox@original=\pgf@lib@dec@text@dobox%

\def\pgf@lib@dec@text@dobox{%
\ifx\zcomma\pgf@lib@dec@text@char
\ifx\z\zr\let\z\zy\else\let\z\zr\fi
\fi
\pgf@lib@dec@text@dobox@original%
\ifpgfdecorationtextalongpathscaletext%
\pgfmathparse{\pgf@lib@dec@text@endscale+(\pgf@lib@dec@text@startscale-\pgf@lib@dec@text@endscale)*\pgfdecoratedremainingdistance/\pgfdecoratedpathlength}%
\setbox\pgf@lib@dec@text@box=\hbox{\scalebox{\pgfmathresult}{\fboxsep\z@\colorbox{\z}{\box\pgf@lib@dec@text@box}}}%
\fi%
}
\newif\ifpgfdecorationtextalongpathscaletext
\def\pgf@lib@dec@text@startscale{1}
\def\pgf@lib@dec@text@endscale{1}

\pgfkeys{/pgf/decoration/.cd,
text path start scale/.code={%
\pgfdecorationtextalongpathscaletexttrue%
\def\pgf@lib@dec@text@startscale{#1}%
},
text path end scale/.code={%
\pgfdecorationtextalongpathscaletexttrue%
\def\pgf@lib@dec@text@endscale{#1}%
}
}
\begin{document}
\begin{tikzpicture}[
decoration={
reverse path,
text along path,
text path start scale=1.5,
text path end scale=0,
text={Lorem ipsum dolor sit amet, consectetur adipisicing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua,
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
pariatur, Excepteur sint occaecat cupidatat non proident, sunt
inculpa qui officia deserunt mollit anim id est laborum}}
]
\draw [decorate]
(0,0)
\foreach \i [evaluate={\r=(\i/2000)^2;}] in {0,5,...,2880}{ -- (\i:\r)};
\useasboundingbox (-2.75,-2.75) rectangle (2.75,2.75);
\end{tikzpicture}
\end{document}


You can smooth it off a bit with a strut and some kerns:

    \setbox\pgf@lib@dec@text@box=\hbox{\scalebox{\pgfmathresult}{\fboxsep\z@
\kern-.7pt\colorbox{\z}{\kern.7pt\strut\box\pgf@lib@dec@text@box\kern.7pt}\kern-.7pt}}%


-
This is very close but not exactly what i wanted. I mean to highlight in continuous blocks, that do not only follow the text but also provide smooth edges, if that makes sense, including the whitespaces. – Basak Jan 27 at 13:02
I had another idea, but lack the skills to implement it. The idea is to draw the text without colored background and, when detecting the comma, store the value of \i in a list. Once the text has ben typeset, a double spiral is drawn in the background filled with a color which changes at the values of \i stored in the list. – JLDiaz Jan 27 at 14:58
Yay! another tikz answer! – hpesoj626 Jan 28 at 1:30