summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/ocgx/tikzlibraryocgx.code.tex
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/latex/contrib/ocgx/tikzlibraryocgx.code.tex
Initial commit
Diffstat (limited to 'macros/latex/contrib/ocgx/tikzlibraryocgx.code.tex')
-rw-r--r--macros/latex/contrib/ocgx/tikzlibraryocgx.code.tex121
1 files changed, 121 insertions, 0 deletions
diff --git a/macros/latex/contrib/ocgx/tikzlibraryocgx.code.tex b/macros/latex/contrib/ocgx/tikzlibraryocgx.code.tex
new file mode 100644
index 0000000000..d69b56d0d2
--- /dev/null
+++ b/macros/latex/contrib/ocgx/tikzlibraryocgx.code.tex
@@ -0,0 +1,121 @@
+% Copyright (C) 2012 by Paul Gaborit
+%
+% This file may be distributed and/or modified
+%
+% 1. under the LaTeX Project Public License and/or
+% 2. under the GNU Public License.
+
+\RequirePackage{ocgx}
+\usetikzlibrary{calc}
+
+\makeatletter
+\tikzset{
+ ocg/.style={ocg/.cd,#1,/tikz/.cd},
+ ocg={
+ % parameters
+ name/.store in=\ocgx@name,
+ visibity/.store in=\ocgx@visibility,
+ status/.is choice,
+ status/visible/.style={visibity=1},
+ status/invisible/.style={visibity=0},
+ % default values
+ name=,
+ status=visible,
+ % ref
+ ref/.style={
+ /tikz/execute at begin scope={\ocg{\ocgx@name}{#1}{\ocgx@visibility}},
+ /tikz/execute at end scope={\endocg},
+ },
+ },
+ switch ocg/.style={
+ postaction={
+ path picture={
+ \path let
+ \p1 = (path picture bounding box.south west),
+ \p2 = (path picture bounding box.north east),
+ \p3 = (\x2-\x1,\y2-\y1)
+ in
+ (path picture bounding box.center)
+ node[inner sep=0pt,anchor=center,outer sep=0pt]
+ {\switchocg{#1}{\phantom{\rule{\x3}{\y3}}}};
+ }
+ },
+ },
+ switch ocg with mark on/.style 2 args={
+ postaction={
+ path picture={
+ \begin{ocg}{#1}{#1}{1}
+ \draw
+ (path picture bounding box.south west)
+ --
+ (path picture bounding box.north east)
+ (path picture bounding box.south east)
+ --
+ (path picture bounding box.north west)
+ ;
+ \end{ocg}
+ },
+ switch ocg={#1 #2},
+ }
+ },
+ switch ocg with mark off/.style 2 args={
+ postaction={
+ path picture={
+ \begin{ocg}{#1}{#1}{0}
+ \draw
+ (path picture bounding box.south west)
+ --
+ (path picture bounding box.north east)
+ (path picture bounding box.south east)
+ --
+ (path picture bounding box.north west)
+ ;
+ \end{ocg}
+ },
+ switch ocg={#1 #2},
+ }
+ },
+ show ocg/.style={
+ postaction={
+ path picture={
+ \path let
+ \p1 = (path picture bounding box.south west),
+ \p2 = (path picture bounding box.north east),
+ \p3 = (\x2-\x1,\y2-\y1)
+ in
+ (path picture bounding box.center)
+ node[inner sep=0pt,anchor=center]
+ {\showocg{#1}{\phantom{\rule{\x3}{\y3}}}};
+ },
+ },
+ },
+ hide ocg/.style={
+ postaction={
+ path picture={
+ \path let
+ \p1 = (path picture bounding box.south west),
+ \p2 = (path picture bounding box.north east),
+ \p3 = (\x2-\x1,\y2-\y1)
+ in
+ (path picture bounding box.center)
+ node[inner sep=0pt,anchor=center]
+ {\hideocg{#1}{\phantom{\rule{\x3}{\y3}}}};
+ },
+ },
+ },
+ actions ocg/.style n args={3}{
+ postaction={
+ path picture={
+ \path let
+ \p1 = (path picture bounding box.south west),
+ \p2 = (path picture bounding box.north east),
+ \p3 = (\x2-\x1,\y2-\y1)
+ in
+ (path picture bounding box.center)
+ node[inner sep=0pt,anchor=center]
+ {\actionsocg{#1}{#2}{#3}{\phantom{\rule{\x3}{\y3}}}};
+ },
+ },
+ },
+}
+\makeatother