Code Monkey home page Code Monkey logo

Comments (2)

LogCreative avatar LogCreative commented on May 27, 2024 1

这个命令是为了实现 SJTU VI A5-03-01,主要代码是:

% \begin{macro}{\sjtubeamer@compatible}
% For \TeX Live 2018 and even older,
% it is \emph{not} compatible to use the
% patterns.meta library for making
% user-defined patterns.
% And fading is not available for caching.
% Please consider
% \verb"\def\sjtubeamer@compatible{false}"
% to match the following condition
% checking.
%
% Remember to use \verb"\makeatletter"
% and \verb"\makeatother" in \LaTeX{}.
% \begin{macrocode}
\def\sjtubeamer@compatible@false{false}
% \end{macrocode}
% We didn't make it as an option since it will break the hierarchical structure of
% option definition. This is the bottom level of all style files, no advanced
% methods are provided in this layer.
% \end{macro}
%
% \begin{macro}{stamp}
% Make a stamp array.
%
% Use option
% \verb"[pattern={stamp[size=8pt,xshift=4pt,yshift=4pt]}]"
% on TikZ fill element.
% \begin{macrocode}
\ifx\sjtubeamer@compatible\sjtubeamer@compatible@false
\else
\usetikzlibrary{patterns.meta}
\tikzdeclarepattern{
name=stamp,
parameters={
\pgfkeysvalueof{/pgf/pattern keys/size},
\pgfkeysvalueof{/pgf/pattern keys/xshift},
\pgfkeysvalueof{/pgf/pattern keys/yshift},
},
defaults={
size/.initial = 5pt,
xshift/.initial = 0pt,
yshift/.initial = 0pt,
},
bottom left={(
-0.5*\pgfkeysvalueof{/pgf/pattern keys/size}
+\pgfkeysvalueof{/pgf/pattern keys/xshift},
-0.4*\pgfkeysvalueof{/pgf/pattern keys/size}
+\pgfkeysvalueof{/pgf/pattern keys/yshift}
)},
top right={(
0.5*\pgfkeysvalueof{/pgf/pattern keys/size}
+\pgfkeysvalueof{/pgf/pattern keys/xshift},
0.4*\pgfkeysvalueof{/pgf/pattern keys/size}
+\pgfkeysvalueof{/pgf/pattern keys/yshift}
)},
tile size={(
\pgfkeysvalueof{/pgf/pattern keys/size},
0.8*\pgfkeysvalueof{/pgf/pattern keys/size}
)},
code={
\def\sjtubeamer@s{\pgfkeysvalueof{/pgf/pattern keys/size}}%
\tikzset{x=0.5*\sjtubeamer@s,y=0.2*\sjtubeamer@s}
\fill[xshift=\pgfkeysvalueof{/pgf/pattern keys/xshift},
yshift=\pgfkeysvalueof{/pgf/pattern keys/yshift}]
(-0.25*\sjtubeamer@s,0)
-- (-0.17*\sjtubeamer@s,0.06*\sjtubeamer@s)
-- (-0.17*\sjtubeamer@s,0.1*\sjtubeamer@s)
-- (0.17*\sjtubeamer@s,0.1*\sjtubeamer@s)
-- (0.17*\sjtubeamer@s,0.06*\sjtubeamer@s)
-- (0.25*\sjtubeamer@s,0)
-- (0.17*\sjtubeamer@s,-0.06*\sjtubeamer@s)
-- (0.17*\sjtubeamer@s,-0.1*\sjtubeamer@s)
-- (-0.17*\sjtubeamer@s,-0.1*\sjtubeamer@s)
-- (-0.17*\sjtubeamer@s,-0.06*\sjtubeamer@s) -- cycle;
}
}
\fi
% \end{macrocode}
% Avoid calling macros in code section for performance reasons.
%
% The newest version of TikZ provides the interface to user-define a pattern.
% Obeying compatibility philosophy, use \verb"\pgfkeyvalueof" interface to get
% parameters in a standard way. The unit is first tested in a standalone file
% and previewed by TikZEdt.
% \end{macro}
%
% \begin{macro}{\stamparray}
% Create the stamp array in the TikZ
% environment.
%
% The first parameter is the pattern size.
%
% The second parameter is the starting
% point. Formatted in \verb"(0,0)".
%
% The third parameter is the ending point.
% Formatted in \verb"(0,0)".
% \begin{macrocode}
\ifx\sjtubeamer@compatible\sjtubeamer@compatible@false
\providecommand{\stamparray}[3]{}
\else
\providecommand{\stamparray}[3]{
% #1: pattern size
% #2: starting point
% #3: ending point
\usebeamercolor{palette primary}
\fill [pattern={stamp[size=#1]},
pattern color=bg!50!fg] #2 rectangle #3;
\def\sjtubeamer@s{#1}%
\pgfmathparse{0.5*\sjtubeamer@s}\let\xs=\pgfmathresult%
\pgfmathparse{-0.4*\sjtubeamer@s}\let\ys=\pgfmathresult%
\fill [pattern={stamp[size=#1,xshift=\xs, yshift=\ys]},
pattern color=bg!50!fg] #2 rectangle #3;
}
\fi
% \end{macrocode}
% NOTICE: \TeX{} is not good at handling parameters. Always remember to store it
% into a temporary variable. Register \verb"\pgfmathresult" will store the result
% of \verb"\pgfmathparse".
% \end{macro}

主要使用了 \tikzdeclarepattern 命令(详见PGF/TikZ 手册 62.3)来定义图案。

from sjtubeamer.

syx-413 avatar syx-413 commented on May 27, 2024

我想移植一下这个命令但是,看了源代码,发现关联的东西很多,可以指明一下这个如何做的吗。:}
image

from sjtubeamer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.