summaryrefslogtreecommitdiff
path: root/macros/luatex/optex/pdfextra/examples/pdfextra-example.tex
diff options
context:
space:
mode:
Diffstat (limited to 'macros/luatex/optex/pdfextra/examples/pdfextra-example.tex')
-rw-r--r--macros/luatex/optex/pdfextra/examples/pdfextra-example.tex76
1 files changed, 40 insertions, 36 deletions
diff --git a/macros/luatex/optex/pdfextra/examples/pdfextra-example.tex b/macros/luatex/optex/pdfextra/examples/pdfextra-example.tex
index 6093bf7def..6704ac4b98 100644
--- a/macros/luatex/optex/pdfextra/examples/pdfextra-example.tex
+++ b/macros/luatex/optex/pdfextra/examples/pdfextra-example.tex
@@ -7,17 +7,14 @@
% env TEXMFDOTDIR=.:~/src/texlive/texmf-dist/source/latex/media9/files/ optex pdfextra-example.tex
% \endtt
-% basic \OpTeX/ settings
+% Basic \OpTeX/ settings:
\enlang\enquotes
\fontfam[lm]
-%\pdfobjcompresslevel=0
-%\pdfcompresslevel=0
-
-% load the package from standard search path
+% Load the package from standard search path:
\load[pdfextra]
-% Before using \hlink we must activate hyperlinks
+% Before using \hlink we must activate hyperlinks:
\hyperlinks\Blue\Green
% Maybe we want to greet the user and jump to page 2 right at the start?
@@ -41,7 +38,8 @@
-% For external references we need to `\filedef` "external" and "url" files beforehand:
+% For external references we need to `\filedef` "external" and "url" files
+% beforehand:
\filedef/u[doc-internet]{http://petr.olsak.net/ftp/olsak/optex/optex-doc.pdf}
\filedef/x[doc-local]{optex-doc.pdf}
@@ -53,20 +51,24 @@
% Insert a video twice with different settings:
\filedef/e[video]{example-movie.mp4}
-% insert video into page using Renditions mechanism with controls and autoplay
+% Insert video into page using Renditions mechanism with controls and autoplay.
\render[video][
controls=true,
aactions=\renditionautoplay,
]{\picwidth=\hsize \inspic{example-image.pdf}}
-% Maybe add action buttons?
+% We set red text color, blue border (RGB triplet) for "rendition" links.
+\let\_renditionlinkcolor\Red
+\def\_renditionborder{0 1 0}
+% Then we add some buttons.
\hlink[rendition::play]{play} \hlink[rendition::pause]{pause}
\hlink[rendition::stop]{stop} \hlink[rendition::resume]{resume}
% Render the same file again, but with different dimensions, no controls
% and explicit activation.
\render[video]{\inspic{example-image.pdf}}
-% This one can't have buttons, because it doesn't have its own name ("video") is used by the previous one.
+% This one can't have buttons, because it doesn't have its own name -- "video"
+% is used by the previous one.
@@ -87,13 +89,13 @@
-% deliver fresh random number to everyone who sees this page using "page open"
-% trigger event of page's actions
+% Deliver fresh random number to everyone who sees this page using "page open"
+% ("O") trigger event of page's actions.
\pageactions[
{O} {js:{app.alert("Random number for you is " + getRandomNumber());}}
]
-% "previous page" link with "Split" transition
+% Link to OpTeX's page reference ("pg:1") with "Split" transition:
\hlink[pg:1, transition:Split]{Go to previous page (with transition).}
@@ -102,7 +104,8 @@
% A 3D Rich Media annotation with a custom view and script follows:
-% First we define the 3D file, so we can use same name for the view and have it auto included.
+% First we define the 3D file, so we can use same name for the view and have it
+% auto included.
\filedef/e[example]{pdfextra-example-part.prc}
% Then a simplistic "front" view.
@@ -112,7 +115,9 @@
]
% A 3D JavaScript script that will define function to use with action button.
-% (we write the script only now, so we don't have to carry around an extra file in the package)
+% (we write the script only now, so we don't have to carry around an extra file
+% in the package, you would normally have the contents in the file -- "turn.js"
+% in this case).
\newwrite\js
\immediate\openout\js=turn.js
% rotate every node by angle degrees along $x$ axis
@@ -131,7 +136,7 @@ function turn(angle) {
\RM[example][
activation=auto,
scripts=turn.js,
-]{{\White\vrule width\hsize height\hsize}}
+]{\White\vrule width\hsize height\hsize}
\hlink[js:\DDDcontext{example}.turn(10);]{Turn by 10 degrees along $x$ axis.}\par
\hlink[js:\DDDcontext{example}.turn(30);]{Turn by 30 degrees along $x$ axis.}\par
@@ -142,10 +147,11 @@ function turn(angle) {
\vfil\break
-% Here is the "epix" 3D model example from media9 documentation ported to pdfextra
+% Here is the "epix" 3D model example from media9 documentation ported to
+% pdfextra.
%
% First we define a view with the same name as the future Rich Media
-% annotation. This view will then automatically be used if no `views` is
+% annotation. This view will then automatically be used if no `views` key is
% specified. No need to be excessive with decimal numbers.
\DDDview[epix][
FOV=30,
@@ -159,11 +165,13 @@ function turn(angle) {
% We want to use the nice "epix" name for the view and annotation.
\filedef/e[epix]{epix.prc}
-% Just to spice things up, we diverge a bit from media9 and define custom background color.
+% Just to spice things up, we diverge a bit from media9 and define custom
+% background color.
\colordef\GreyBG{0.1\Black}
% Define the 3D Rich Media annotation. One view is automatically detected from
-% name ("epix"). Scripts will run in turn at initialization time.
+% name ("epix"). Scripts will run in specified order at initialization time
+% (when the annotation is activated).
\RM[epix][
scripts={
asylabels.js,
@@ -180,7 +188,8 @@ function turn(angle) {
% Second media9 example is "dice" it has a lot of views, but they are simple.
-% This time we can't use the deduction with same name.
+% This time we can't use the view name deduction from `\RM` name -- there is
+% more than one view.
\DDDview[Front][roo=27]
\DDDview[Back][roo=27, c2c=0 1 0]
\DDDview[Left][roo=27, c2c=-1 0 0]
@@ -190,38 +199,32 @@ function turn(angle) {
\DDDview[Fish Eye at Centre][fov=120]
% We want to use all the defined views, as well as autoactivate the annotation.
-% This means that the previews mostly sets dimensions, because it will not be
-% shown much. (Except in viewers that don't support 3D Rich Media -- all except
-% Acrobat).
+% This means that the preview mostly sets dimensions, because it will not be
+% shown much. (Only in viewers that don't support 3D Rich Media -- that is, all
+% except Acrobat).
\RM[dice.u3d][
views={Front, Back, Left, Right, Top, Bottom, Fish Eye at Centre},
activation=auto,
scripts=3dmenu,
-]{{\Red \vrule height.5\hsize width.5\hsize}}
+]{\Red \vrule height.5\hsize width.5\hsize}
% A few buttons for switching views.
\hlink[goto3dview::/N]{\frame{Next view}}
\hlink[goto3dview::(Back)]{\frame{View \"Back"}}
\hlink[goto3dview::5]{\frame{6th view in the list}}
-% And define the action buttons using this new custom action.
-\hlink[diceview:/N]{Next view}
-\hlink[diceview:(Back)]{View \"Back"}
-\hlink[diceview:5]{6th view in the list}
-
-
\vfil\break
% Last media9 example ported. It has its own JavaScript file for animation,
% which can be customized at runtime using JavaScript actions that access 3D
-% conotext.
+% context of the annotation.
\filedef/e[malte]{malte.u3d}
\DDDview[malte][c2c=1 1 1, roo=0.25]
\RM[malte][
activation=auto,
scripts={3dmenu, malte.js},
-]{{\Blue \vrule height.5\hsize width0.5\hsize}}
+]{\Blue \vrule height.5\hsize width0.5\hsize}
{\picheight=1.44em
% Normal JavaScript actions, but we access functions defined globaly in the 3D
@@ -240,7 +243,7 @@ function turn(angle) {
% Lastly a showcase of transitions / page durations in \OpTeX/ slideshow.
% Because transitions are displayed only in fullscreen mode, we could request
-% it by using "\fullscreen". But we have more pages before this, so we didn't.
+% it by using `\fullscreen`. But we have more pages before this, so we didn't.
% We just turn the rest of the document into slideshow.
\slides
@@ -253,7 +256,8 @@ function turn(angle) {
% "Wipe" and be 1 second long.
\transitions[Wipe:1]
-% The slides will by default be shown for 3 seconds before advancing to the next one.
+% The slides will by default be shown for 3 seconds before advancing to the
+% next one.
\defaultpageduration[3]
% But the first slide has override to only be shown for 1 second.
\pageduration[1]
@@ -268,7 +272,7 @@ function turn(angle) {
% to that page. That means that we probably didn't see the "Wipe:1" animation
% of the first slide, because we already were there. However, this second slide
% with "Fade" is now shown correctly. (The first one also will, when we go
-% back.)
+% back to it.)
\transition[Fade]
\sec First slide