2

I'm looking for a way to color a text rendered on the surface with a gradient. Below is an example showing the surface with the gradient and the text in black. How can the text color be changed?

\documentclass{standalone}
\usepackage{asypictureB}
\begin{document}
\begin{asypicture}{name=text}
import graph3;
import contour;
import palette;

size(8cm,IgnoreAspect);

currentprojection=orthographic(-10,-10,8);
limits((0,0,0),(5,10,12));

real f(pair z) {return (z.x+z.y)/(2+cos(z.x)*sin(z.y));}

surface s=surface(f,(0,0),(5,10),50,Spline);

draw(s,mean(palette(s.map(zpart),Rainbow())),black);

string text="lorum ipsum";
real uoffset=1; 
real voffset=1; 
real h=0.1;
draw(surface(xscale(0.9)*yscale(0.9)*text,s,uoffset,voffset,h));

\end{asypicture}
\end{document}
  • Please post an MWE or at least indicate all the asymptote libraries you are loading for this. – user121799 May 5 '18 at 12:18
4

OK, here you go then. I do not think that your choice of the surface is particularly nice, but this is just a matter of taste. The question is about drawing a text on a surface and giving it rainbow colors, which is actually not too difficult.

\documentclass{standalone}
\usepackage{asypictureB}
\begin{document}
\begin{asypicture}{name=text}
import graph3;
import contour;
import palette;

size(8cm,IgnoreAspect);

currentprojection=orthographic(-10,-10,8);
limits((0,0,0),(5,10,12));

real f(pair z) {return (z.x+z.y)/(2+cos(z.x)*sin(z.y));}

surface s=surface(f,(0,0),(5,10),50,Spline);

draw(s,red+opacity(0.4));//mean(palette(s.map(zpart),Rainbow())),black

string text="\textbf{lorum ipsum}";
real uoffset=1; 
real voffset=1; 
real h=0.1;
draw(surface(xscale(0.4)*yscale(0.4)*text,s,uoffset,voffset,h),mean(palette(s.map(zpart),Rainbow())),black);
//draw(surface(xscale(0.9)*yscale(0.9)*text,s,uoffset,voffset,h));

\end{asypicture}
\end{document}

enter image description here

ORIGINAL ANSWER:

enter image description here

\documentclass{standalone}
\usepackage{asypictureB}
\begin{document}
\begin{asypicture}{name=text}
size(5cm);
pen[][] p={{white,grey,black},
           {red,green,blue},
           {cyan,magenta,yellow}};
latticeshade(texpath("text"),p);
\end{asypicture}
\end{document}
  • Thanks for your answer but I'm looking specifically for a way to render this command: draw(surface(xscale(1)*yscale(1)*text,s,uoffset,voffset,h)); with a gradient ie. to have a text rendered both on the surface and in colour. Is there a way to use a pen inside the draw command? – zbigniew Jun 10 '18 at 7:32
  • @zbigniew Well, your question does not have an MWE. If you provide one, i.e. specify a suitable f and really bake an MWE, I may have a look at it. – user121799 Jun 10 '18 at 13:56
  • Sorry for the vague original question. I just added an example. Would be grateful if you could take a look. – zbigniew Jun 14 '18 at 18:24
  • @zbigniew I added something, please have a look. It actually really only combines ingredients you were already using. – user121799 Jun 14 '18 at 19:45
  • Just testing it further and the text doesn't render with gradient (like in your attached picture). Instead it is broken in segments and each is coloured with a random colour and the rainbow affect isn't really there. Is there a way to change it? – zbigniew Jun 17 '18 at 9:05

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.