#Defining a New command

1 messages · Page 1 of 1 (latest)

past steppe
#

\newcommand{\grad}[5]{%
\usetikzlibrary{fadings}
\definecolor{myred}{HTML}{#1}
\definecolor{myplum}{HTML}{#2}
\begin{tikzfadingfrompicture}[name=picfading]
\node [text=transparent!0,align=center] {%
#3%
};
\end{tikzfadingfrompicture}
\begin{document}
\begin{tikzpicture}
\shade [path fading=picfading,right color=myred, left color=myplum,fit fading=false] (-#4,-#5) rectangle (#4,#5);
\end{tikzpicture}
\end{document}
%}
\grad{40E0D0}{FF0080}{\sqrt{2}}{2}{2}
Here is my code.

real gyroBOT
#

Restarter
Compile Error! Click the errors reaction for more information.
(You may edit your message to recompile.)

past steppe
#

#1, #2 = color in HTML
#3 = text or math expressions
#4, #5 = width and height of the canvas.

snow cipher
#

You're defining it wrong.

#

You should consider omitting the document environments

#

And load the TikZ library outside \newcommand

#

\usetikzlibrary{fadings}
\newcommand{\grad}[5]{%
\definecolor{myred}{HTML}{#1}
\definecolor{myplum}{HTML}{#2}
\begin{tikzfadingfrompicture}[name=picfading]
\node [text=transparent!0,align=center] {%
#3%
};
\end{tikzfadingfrompicture}
\begin{tikzpicture}
\shade [path fading=picfading,right color=myred, left color=myplum,fit fading=false] (-#4,-#5) rectangle (#4,#5);
\end{tikzpicture}
}
\grad{40E0D0}{FF0080}{$\sqrt{2}$}{2}{2}

real gyroBOT
past steppe
#

Oh wow...

So that's where my mistakes lies...

Thanks!

#

\usetikzlibrary{fadings}
\newcommand{\fancy}[5]{%
\definecolor{myred}{HTML}{#1}
\definecolor{myplum}{HTML}{#2}
\begin{tikzfadingfrompicture}[name=picfading]
\node [text=transparent!0,align=center] {%
#3%
};
\end{tikzfadingfrompicture}
\begin{tikzpicture}
\shade [path fading=picfading,right color=myred, left color=myplum,fit fading=false] (-#4,-#5) rectangle (#4,#5);
\end{tikzpicture}
}
\fancy{40E0D0}{FF0080}{$\sqrt{2}$}{2}{2}

#

Now what the heck...

real gyroBOT
#

Restarter

past steppe
#

Ah okay.