⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ctextemp_texpower.sty

📁 幻灯片模板
💻 STY
📖 第 1 页 / 共 5 页
字号:
  \def\convert@RGB@rgb@TP#1,#2,#3;%                   Convert RGB color to rgb.
  {%
    \convert@RGBvalue@rgbvalue@TP{#1}%
    \edef\newcolordef@TP{\result@TP,}%                Store first value.
    \convert@RGBvalue@rgbvalue@TP{#2}%
    \edef\newcolordef@TP{\newcolordef@TP\result@TP,}% Store second value.
    \convert@RGBvalue@rgbvalue@TP{#3}%
    \edef\newcolordef@TP{\newcolordef@TP\result@TP}%  Store third value.
    }


  % \colorbetween[<factor>]{<target>}{<source1>}{<source2>} calculates a `weighted average' between two
  % colors. <source1> and <source2> are the names of the two colors. <factor> (default: 0.5) is a fixed-point number
  % between 0 and 1 giving the `weight' for the interpolation between <source1> and <source2>. <target> is the name to
  % be given to the resulting mixed color.
  % If <factor> is 1, then <target> will be identical to <source1> (up to color model conversions, see below), if
  % <factor> is 0, then <target> will be identical to <source2>, if <factor> is 0.5, then <target> will be exactly in
  % the middle between <source1> and <source2>.
  % \colorbetween supports the following color models: rgb, RGB, gray, cmyk, hsb. If both colors are of the same model,
  % the resulting color is also of the respective model. If <source1> and <source2> are from _different_ models, then
  % <target> will _always_ be an rgb color. The only exception is the hsb color model: As I don't know how to convert
  % hsb to rgb, mixing hsb with another color model will always raise an error.
  \newcommand{\colorbetween}[4][.5]% 
  {%
    \begingroup%                               Make the definition of \processcolor... local.
      \newcommand{\processcolor@TP@rgb}[3]%    What if the first color is an rgb color?
      {%
        \ifx##2\processcolor@TP@rgb%           Are both colors rgb colors?
          \interpolate@three@TP##1;##3;{#1}%   Calculate interpolated values.
         \else
          \ifx##2\processcolor@TP@gray%        Is the second color from the gray model?
            \interpolate@three@TP##1;##3,##3,##3;{#1}%    Calculate interpolated values.
           \else
            \ifx##2\processcolor@TP@cmyk%      Is the second color from the cmyk model?
              \convert@cmyk@rgb@TP##3;%        Convert to rgb.
              \edef\newcolordef@TP{\noexpand\interpolate@three@TP##1;\newcolordef@TP;{#1}}%
              \newcolordef@TP
             \else
              \ifx##2\processcolor@TP@RGB%     Is the second color from the RGB model?
                \convert@RGB@rgb@TP##3;%       Convert to rgb.
                \edef\newcolordef@TP{\noexpand\interpolate@three@TP##1;\newcolordef@TP;{#1}}%
                \newcolordef@TP
               \else
                \ifx##2\processcolor@TP@hsb%   Is the second color from the hsb model?
                  \PackageError{texpower}{Don't know how to convert an hsb color!}
                \fi
              \fi
            \fi
          \fi
        \fi
        \edef\newcolordef@TP{{rgb}{\newcolordef@TP}}% Store the result
        }%
      \newcommand{\processcolor@TP@gray}[3]%          What if the first color is a gray color?
      {%
        \ifx##2\processcolor@TP@gray%                 Are both colors gray colors?
          \interpolate@TP{#1}{##1}{##3}%              Calculate interpolated value.
          \edef\newcolordef@TP{{gray}{\result@TP}}%   Store the result
         \else
          \processcolor@TP@rgb{##1,##1,##1}{##2}{##3}% Otherwise, convert first color to rgb and continue.
        \fi
        }%
      \newcommand{\processcolor@TP@cmyk}[3]%          What if the first color is a cmyk color?
      {%
        \ifx##2\processcolor@TP@cmyk%                 Are both colors cmyk colors?
          \interpolate@four@TP##1;##3;{#1}%           Calculate interpolated values.
          \edef\newcolordef@TP{{cmyk}{\newcolordef@TP}}% Store the result
         \else
          \convert@cmyk@rgb@TP##1;%                   Otherwise, convert first color to rgb ...
          \expandafter\processcolor@TP@rgb\expandafter{\newcolordef@TP}{##2}{##3}% ... and continue.
        \fi
        }%
      \newcommand{\processcolor@TP@RGB}[3]%           What if the first color is an RGB color?
      {%
        \convert@RGB@rgb@TP##1;%                      Convert to rgb ...
        \expandafter\processcolor@TP@rgb\expandafter{\newcolordef@TP}{##2}{##3}% ... and continue.
        }%
      \newcommand{\processcolor@TP@hsb}[3]%           What if the first color is an hsb color?
      {%
        \ifx##2\processcolor@TP@hsb%                  Are both colors hsb colors?
          \interpolate@three@TP##1;##3;{#1}%          Calculate interpolated values.
          \edef\newcolordef@TP{{hsb}{\newcolordef@TP}}% Store the result
         \else
          \PackageError{texpower}{Don't know how to convert an hsb color!}
        \fi
        }%
      \expandafter\let\expandafter
      \firstcol@TP\csname colordef@TP@#3\endcsname    % Retrieve definition of color <source1>...
      \expandafter\expandafter\expandafter\firstcol@TP% and apply (remember \processcolor... is part of the definition)
      \csname colordef@TP@#4\endcsname%                 to definition of color <source2>.
      \edef\end@TP%                                     Define color <target> (outside the enclosing group).
      {\endgroup\noexpand\definecolor{#2}\newcolordef@TP}%
    \end@TP
    }% matches \newcommand{\colorbetween}


  \newcommand{\complement@TP}[1]%                   Calculate the complement of a fixed point value.
  {%
    \setlength{\tempdima@TP}{1pt-#1pt}%
    \edef\result@TP{\strip@pt\tempdima@TP}%
    }

  \def\complement@three@TP#1,#2,#3;%                Complement a three-piece color value.
  {%
    \complement@TP{#1}%
    \edef\newcolordef@TP{\result@TP,}%                Store first value.
    \complement@TP{#2}%
    \edef\newcolordef@TP{\newcolordef@TP\result@TP,}% Store second value.
    \complement@TP{#3}% 
    \edef\newcolordef@TP{\newcolordef@TP\result@TP}%  Store third value.
    }

  \def\grabfourth@TP#1,#2,#3,#4;%            Separate the fourth element of a four-piece color value from the rest.
  {%
    \def\mem@TP{#4}%                         Store fourth element.
    \def\result@TP{#1,#2,#3;}%               Store first three elements.
    }

  % \complementcolor{<target>}{<source>} calculates the numerical complement of a color. <source> is the name of the
  % color to be complemented. <target> is the name to be given to the resulting color.
  % \complementcolor supports the following color models: rgb, RGB, gray, cmyk, hsb. 
  \newcommand{\complementcolor}[2]%        
  {%
    \begingroup%                               Make the definition of \processcolor... local.
      \newcommand{\processcolor@TP@rgb}[1]%    What if the color is an rgb color?
      {%
        \complement@three@TP##1;%              Calculate complemented values.
        \edef\newcolordef@TP{{rgb}{\newcolordef@TP}}% Store the result
        }%
      \newcommand{\processcolor@TP@gray}[1]%   What if the color is a gray color?
      {%
        \complement@TP{##1}%                   Calculate complemented value.
        \edef\newcolordef@TP{{gray}{\result@TP}}% Store the result
        }%
      \newcommand{\processcolor@TP@cmyk}[1]%   What if the color is a cmyk color?
      {%
        \grabfourth@TP##1;%                    Remember fourth element.
        \expandafter\complement@three@TP\result@TP%  Calculate complemented values of first three elements.
        \edef\newcolordef@TP{{cmyk}{\newcolordef@TP,\mem@TP}}% Store the result, putting back the fourth element.
        }%
      \newcommand{\processcolor@TP@RGB}[1]%    What if the color is an RGB color?
      {%
        \convert@RGB@rgb@TP##1;%               Convert to rgb ...
        \expandafter\processcolor@TP@rgb\expandafter{\newcolordef@TP}% ... and continue.
        }%
      \newcommand{\processcolor@TP@hsb}[1]%    What if the color is an hsb color?
      {%
        \complement@three@TP##1;%              Calculate complemented values.
        \edef\newcolordef@TP{{hsb}{\newcolordef@TP}}% Store the result
        }%
      \csname colordef@TP@#2\endcsname%        Execute definition of color <source> (which contains \processcolor...)
      \edef\end@TP%                            Define color <target> (outside the enclosing group).
      {\endgroup\noexpand\definecolor{#1}\newcolordef@TP}%
    \end@TP
    }% matches \newcommand{\complementcolor}
  }% matches \ifthenelse{\boolean{TPcolor}}{% Yes.
{% No. Do nothing.
  }

%-----------------------------------------------------------------------------------------------------------------------
% Color name and color set management. 

% \replacecolor[<tset>]{<tcol>}[<sset>]{<scol>} will make <tcol> have the same definition as <scol> (if <scol> is
% defined at all), where <tcol> and <scol> are color names as given in the first argument of \definecolor.  If (one
% of) <tset> and <sset> are given, the colors will be taken from the respective color sets.
\newcommand{\replacecolor}
{%
  \let\replacecolor@hook@TP=\@gobble% This hook can be used for variant checking (see below).
  \replacecolor@TP%                   Pick up arguments.
  }

\newcommand{\replacecolor@TP}[2][]% Pick up the first two arguments of \replacecolor.
{%
  \ifthenelse{\equal{#1}{}}{\edef\tcolname@TP{#2}}{\edef\tcolname@TP{#2@#1}}% Construct `real' target color name.
  \@replacecolor@TP%                                                        Read second argument.
  }%


\ifthenelse{\boolean{TPcolor}}% Only if TeXPower's color management is active.
{% Yes.
  \newcommand{\undefinecolor@TP}[1]%                                Make a color undefined.
  {\expandafter\let\csname\string\color @#1\endcsname=\@undefined}% 


  \newcommand{\ifcolorexists@TP}[3]%                                Conditional for testing whether a color is defined.
  {\@ifundefined{\string\color @#1}{#3}{#2}}%                       Test whether a given color is defined.


  \newcommand{\@replacecolor@TP}[2][]%                              Second part of \replacecolor.
  {%
    \ifthenelse{\equal{#1}{}}{\edef\scolname@TP{#2}}{\edef\scolname@TP{#2@#1}}% Construct `real' source color name.
    \ifcolorexists@TP{\scolname@TP}%                                            Does the source color exist at all?
    {% Yes.
      \replacecolor@hook@TP{\tcolname@TP}%                                      Execute hook.
      \expandafter\let\csname\string\color @\tcolname@TP\expandafter\endcsname% Make value of target color
      \csname\string\color @\scolname@TP\endcsname%                             identical with source color.
      \expandafter\let\csname colordef@TP@\tcolname@TP\expandafter\endcsname%   Make definition of target color
      \csname colordef@TP@\scolname@TP\endcsname%                               identical with source color.
      }%
    {% No. Do nothing.
      }%
    }%


  % The set of TeXPower's `standard colors' and some commands to manipulate them.

  \newcommand{\colors@TP}%             The list of all standard colors defined by texpower.
  {% Initially empty.
    }


  \newcommand{\removecolor@TP}[1]%     Remove a color name from the list.
  {%
    \def\processme@TP##1%              This macro does the real work.
    {%
      \ifthenelse{\equal{#1}{##1}}%    Is this the color to be removed?
      {% Yes. Do nothing, so it vanishes.
        }
      {% No. Re-insert.
        \expandafter\def\expandafter\colors@TP\expandafter{\colors@TP\processme@TP{##1}}%
        }%
      }%
    \expandafter\let\expandafter\colors@TP\expandafter\empty% Initialize \colors@TP.
    \colors@TP%                                               Execute \processme@TP for every color on the list.
    }


  % \addTPcolor{<color>} adds the color named <color> to TeXPower's list of standard colors.
  \newcommand{\addTPcolor}[1]%
  {%
    \removecolor@TP{#1}%               Remove this color from the list (to avoid duplicates).
    \expandafter\def\expandafter\colors@TP\expandafter{\colors@TP\processme@TP{#1}}% ... and insert.
    }


  % \defineTPcolor[<set>]{<name>}{<model>}{<def>} acts like \definecolor{<name>}{<model>}{<def>}, but
  % a. color <name> is automatically added to the list of standard colors and
  % b. if the optional parameter is given, the color is defined in the color set <set> instead of the current color
  %    set. 
  \newcommand{\defineTPcolor}[4][]%    Color definition which also adds the color to the color list.
  {%
    \addTPcolor{#2}%                   Add color to the list.
    \ifthenelse{\equal{#1}{}}%         Color from the current color set?
    {\definecolor{#2}{#3}{#4}}%        Yep. Just define the color.
    {\definecolor{#2@#1}{#3}{#4}}%     No. Add color set identifyer.
    }


  % Some commands for manipluating whole color sets.

  \newcommand{\replacecolors@TP}%                Low level command for replacing a complete color set.          
  {%
    \@ifstar%                                    The starred version will put the color set into normal variant.
    {\let\replacecolor@hook@TP=\register@normalvariant@TP\@replacecolors@TP}
    {\let\replacecolor@hook@TP=\@gobble\@replacecolors@TP}%
    }

  \newcommand{\@replacecolors@TP}[4]%            This part does the real work.
  {%
    \def\processme@TP##1{\replacecolor@TP[#1]{#2##1}[#3]{#4##1}}%
    \colors@TP
    }

  % \usecolorset{<set>} switches to color set <set>.
  \newcommand{\usecolorset}[1]%       
  {%
    \replacecolors@TP*{}{}{#1}{}%   Replace normal variant (registering variants).
    \replacecolors@TP{}{d}{#1}{d}%  Replace dimmed variant.
    \replacecolors@TP{}{e}{#1}{e}%  Replace enhanced variant.
    \color{textcolor}%              Activate textcolor.
    \pagecolor{pagecolor}%          Activate pagecolor.
    }%

  % \dumpcolorset{<set>} saves all standard colors from the current color set to the color set <set>.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -