summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/gradient-text
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2022-12-25 03:01:07 +0000
committerNorbert Preining <norbert@preining.info>2022-12-25 03:01:07 +0000
commit90ef58ebc56f69220f860d466e1e21ed68ce9a55 (patch)
tree1b6ae8a0cb89728c9f71447236a171da28b786a1 /macros/latex/contrib/gradient-text
parentda0bd16b0ba9d42d044af47137003788f0b7f773 (diff)
CTAN sync 202212250301
Diffstat (limited to 'macros/latex/contrib/gradient-text')
-rw-r--r--macros/latex/contrib/gradient-text/README.md38
-rw-r--r--macros/latex/contrib/gradient-text/gradient-text.pdfbin0 -> 84781 bytes
-rw-r--r--macros/latex/contrib/gradient-text/gradient-text.sty31
-rw-r--r--macros/latex/contrib/gradient-text/gradient-text.tex50
4 files changed, 119 insertions, 0 deletions
diff --git a/macros/latex/contrib/gradient-text/README.md b/macros/latex/contrib/gradient-text/README.md
new file mode 100644
index 0000000000..730fe264f0
--- /dev/null
+++ b/macros/latex/contrib/gradient-text/README.md
@@ -0,0 +1,38 @@
+gradient-text
+=========
+
+The 'gradient-text' package enables writers to conveniently decorate text with linear
+gradient colors.
+
+Basic Usage
+-----------
+The package only provides a user command.
+
+ \gradientRGB {⟨text⟩}{⟨first RGB⟩}{⟨last RGB⟩}
+
+You can read the package manual for some explanations.
+
+Copyright and License
+---------------------
+
+ Copyright (C) 2022 by Sicheng Du <siddsc@foxmail.com>
+ -----------------------------------------------------------------
+
+ This work may be distributed and/or modified under the
+ conditions of the LaTeX Project Public License, either
+ version 1.3c of this license or (at your option) any later
+ version. This version of this license is in
+ http://www.latex-project.org/lppl/lppl-1-3c.txt
+ and the latest version of this license is in
+ http://www.latex-project.org/lppl.txt
+ and version 1.3 or later is part of all distributions of
+ LaTeX version 2005/12/01 or later.
+
+ This work has the LPPL maintenance status "maintained".
+
+ The Current Maintainer of this work is Sicheng Du.
+
+ This package consists of the files gradient-text.tex,
+ gradient-text.pdf,
+ gradient-text.sty and
+ README.md (this file). \ No newline at end of file
diff --git a/macros/latex/contrib/gradient-text/gradient-text.pdf b/macros/latex/contrib/gradient-text/gradient-text.pdf
new file mode 100644
index 0000000000..1956ba90ed
--- /dev/null
+++ b/macros/latex/contrib/gradient-text/gradient-text.pdf
Binary files differ
diff --git a/macros/latex/contrib/gradient-text/gradient-text.sty b/macros/latex/contrib/gradient-text/gradient-text.sty
new file mode 100644
index 0000000000..62494481f4
--- /dev/null
+++ b/macros/latex/contrib/gradient-text/gradient-text.sty
@@ -0,0 +1,31 @@
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{gradient-text}[2022/12/24]
+\ExplSyntaxOn
+\clist_new:N\l_FirstRGB_int \clist_new:N\l_LastRGB_int
+\int_new:N\l_MaxIndex\int_new:N\l_Ratio
+\newcommand{\@radientR@B}[7]{
+ \int_set:Nn\l_MaxIndex{\int_eval:n{\str_count:n{#1}}}
+ \int_step_inline:nnn{1}{\l_MaxIndex}{
+ \exp_args:Ne\str_if_eq:nnTF{\str_item:Nn{#1}{##1}}{~}{}{
+ \int_set:Nn\l_Ratio{\int_eval:n{\l_Ratio+1}}
+ }
+ \color_select:nn{RGB}{
+ \int_eval:n{(\int_use:N\l_Ratio*#5+(\l_MaxIndex-##1)*#2)/\l_MaxIndex},
+ \int_eval:n{(\int_use:N\l_Ratio*#6+(\l_MaxIndex-##1)*#3)/\l_MaxIndex},
+ \int_eval:n{(\int_use:N\l_Ratio*#7+(\l_MaxIndex-##1)*#4)/\l_MaxIndex}
+ }\str_item:Nn{#1}{##1}
+ }
+}
+
+\NewDocumentCommand\gradientRGB{mmm}{{
+ \clist_set:Nn\l_FirstRGB_int #2
+ \clist_set:Nn\l_LastRGB_int #3
+ \@radientR@B{#1}
+ {\clist_item:Nn\l_FirstRGB_int{1}}
+ {\clist_item:Nn\l_FirstRGB_int{2}}
+ {\clist_item:Nn\l_FirstRGB_int{3}}
+ {\clist_item:Nn\l_LastRGB_int{1}}
+ {\clist_item:Nn\l_LastRGB_int{2}}
+ {\clist_item:Nn\l_LastRGB_int{3}}
+}}
+\ExplSyntaxOff \ No newline at end of file
diff --git a/macros/latex/contrib/gradient-text/gradient-text.tex b/macros/latex/contrib/gradient-text/gradient-text.tex
new file mode 100644
index 0000000000..59924a0a90
--- /dev/null
+++ b/macros/latex/contrib/gradient-text/gradient-text.tex
@@ -0,0 +1,50 @@
+\documentclass{ltxdoc}
+\title{The \textsf{\gradientRGB{gradient-text}{{255,63,63}}{{6,60,255}}} package\footnote{This project is under the \LaTeX~Project Public License.}}
+\usepackage{fontspec}
+\usepackage{tcolorbox}
+\usepackage[misc,geometry]{ifsym}
+\author{Sicheng Du\thanks{\Letter~~\href{mailto:siddsc@foxmail.com}{\gradientRGB{siddsc@foxmail.com}{{0,224,238}}{{173,0,254}}}}}
+\date{2022/12/24~~~~v1.1}
+\setmainfont{Times New Roman}
+\usepackage[colorlinks,linkcolor=purple]{hyperref}
+\usepackage{gradient-text}
+\begin{document}
+\maketitle
+The \textsf{gradient-text} package enables writers to conveniently decorate text with linear gradient colors. It's effect can be seen from the title.
+
+%\DescribeMacro{\xxx}xxxx
+\begin{macro}{\gradientRGB}
+\marg{text}\marg{first RGB}\marg{last RGB}
+This is the syntax of the command for putting gradient color on text . It takes three mandatory arguments.
+\end{macro}
+\begin{description}
+\item[\marg{text}] is the text you desire to have gradient color. Be aware that this command most likely wouldn't output content as expected if this parameter is filled with tokens that cannot expand into pure text. Below are two examples.
+\begin{tcolorbox}[sidebyside,coltitle=black,colbacktitle=white,lower separated=false,title=A correct usage,oversize,boxrule=0.5pt]
+\begin{verbatim}
+\newcommand{\hello}{Hello!}
+\gradientRGB{\hello}{{0,255,0}}{{255,0,0}}
+\end{verbatim}
+\tcblower
+\hfill\gradientRGB{Hello!}{{0,255,0}}
+{{255,0,0}}
+\end{tcolorbox}
+\begin{tcolorbox}[sidebyside,coltitle=orange,colbacktitle=white,lower separated=false,title=\SmallCross~An incorrect usage,oversize,boxrule=0.5pt]
+\begin{verbatim}
+\newcommand{\hello}{\textit{Hello!}}
+\gradientRGB{\hello}{{0,255,0}}{{255,0,0}}
+\end{verbatim}
+\tcblower
+\hfill\gradientRGB{\textit{Hello!}}{{0,255,0}}{{255,0,0}}
+\end{tcolorbox}
+In addition, for any space characters in \marg{text}, they will not be take a unique color, although they will still show up in their original position.
+\begin{tcolorbox}[coltitle=black,colbacktitle=white,lower separated=false,title=Example of space characters,oversize,boxrule=0.5pt]
+\verb|\gradientRGB{Hello World}{{0,255,0}}{{255,0,0}}|\hfill\gradientRGB{Hello World}{{0,255,0}}{{255,0,0}}
+\tcblower
+\verb|\gradientRGB{HelloWorld}{{0,255,0}}{{255,0,0}}|\hfill\gradientRGB{HelloWorld}{{0,255,0}}{{255,0,0}}
+\end{tcolorbox}
+\item[\marg{first RGB}] specifies the RGB value given to the first character of the \marg{text}. It should be formatted as a three-item comma list in brackets \verb|{}|, of which each item is a natural number not exceeding 255.
+
+All of \verb|{{13,28,176}}|, \verb|{{0,59,2}}| and \verb|{{255,34,5}}| are correct examples.
+\item[\marg{last RGB}] is similar to \marg{first RGB} except that it controls the RGB color of the last character in the \marg{text}.
+\end{description}
+\end{document} \ No newline at end of file