texlive[63187] Master/texmf-dist: hvextern (30apr22)

commits+karl at tug.org commits+karl at tug.org
Sat Apr 30 22:02:02 CEST 2022


Revision: 63187
          http://tug.org/svn/texlive?view=revision&revision=63187
Author:   karl
Date:     2022-04-30 22:02:01 +0200 (Sat, 30 Apr 2022)
Log Message:
-----------
hvextern (30apr22)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/hvextern/Changes
    trunk/Master/texmf-dist/doc/latex/hvextern/hvextern.pdf
    trunk/Master/texmf-dist/doc/latex/hvextern/hvextern.tex
    trunk/Master/texmf-dist/tex/latex/hvextern/hvextern.sty

Modified: trunk/Master/texmf-dist/doc/latex/hvextern/Changes
===================================================================
--- trunk/Master/texmf-dist/doc/latex/hvextern/Changes	2022-04-30 20:01:47 UTC (rev 63186)
+++ trunk/Master/texmf-dist/doc/latex/hvextern/Changes	2022-04-30 20:02:01 UTC (rev 63187)
@@ -1,5 +1,6 @@
 hvextern.sty ----------------
 
+v 0.21 2022-04-30  - added java support
 v 0.20 2022-04-27  - use L3 for the comma separated lists
                      cleanup and runsequence
                    - move the config files into the main file

Modified: trunk/Master/texmf-dist/doc/latex/hvextern/hvextern.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/hvextern/hvextern.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/hvextern/hvextern.tex	2022-04-30 20:01:47 UTC (rev 63186)
+++ trunk/Master/texmf-dist/doc/latex/hvextern/hvextern.tex	2022-04-30 20:02:01 UTC (rev 63187)
@@ -30,7 +30,7 @@
 \end{verbatim}
 
 \begin{sloppypar}
-This package allows to write external \MP, \TeX, \ConTeXt, \LaTeX, \LuaTeX, \LuaLaTeX, \XeTeX, \XeLaTeX, Lua, Perl and/or Python
+This package allows to write external \MP, \TeX, \ConTeXt, \LaTeX, \LuaTeX, \LuaLaTeX, \XeTeX, \XeLaTeX, Lua, Perl, Java and/or Python
 source code, which will then be run via \texttt{shell escape} to create a PDF oder text output to include
 it into the main \LaTeX\ document. 
 \end{sloppypar}
@@ -82,7 +82,7 @@
 \begin{minipage}{.59\linewidth}
 \begin{lstlisting}
 \begin{externalDocument}[
-  compiler=pdflatex,force,cleanup]{Roemer1}
+  compiler=pdflatex,force,cleanup]{voss}
 \documentclass{standalone}
 %StartVisiblePreamble
 \usepackage{fontenc}
@@ -106,7 +106,7 @@
 \end{minipage}
 \begin{minipage}{.39\linewidth}
 \begin{externalDocument}[
-  compiler=pdflatex,force,cleanup={log,aux},verbose]{Roemer1}
+  compiler=pdflatex,force,cleanup={log,aux},verbose]{voss}
 \documentclass{standalone}
 %StartVisiblePreamble
 \usepackage{fontenc}
@@ -261,11 +261,9 @@
 
 
 
-
-
 \begin{externalDocument}[grfOptions={width=0.95\linewidth},
   compiler=xelatex,code,mpwidth=0.6\linewidth,
-  crop,cleanup,force,usefancyvrb=false,ext=tex]{Senger3}
+  crop,cleanup,force,usefancyvrb=false,ext=tex]{voss}
 \documentclass{article}
 %StartVisiblePreamble
 \usepackage{tikz}
@@ -400,9 +398,83 @@
 \end{externalDocument}
 
 
+The following Java-program creates the Mandelbrot set as png image. The valid setting for 
+the environment \texttt{externalDocument} is:
 
+\begin{verbatim}
+  compiler=java,ext=java,docType=java,
+\end{verbatim}
 
+\begin{externalDocument}[
+  verbose,
+  compiler=java,ext=java,code,
+  force,docType=java,includegraphic,
+  usefancyvrb,grfOptions={width=0.9\linewidth}]{java}
+import java.awt.Color;
+import java.awt.Graphics;
+import java.awt.image.BufferedImage;
+import java.awt.image.RenderedImage;
+import java.io.File;
+import javax.imageio.ImageIO;
 
+public class Main {
+
+//StartVisiblePreamble
+  public static int iterZahl(final double cx, final double cy, int maxIt, 
+                final double radius) {
+  // bestimmt Anzahl der Iterationen
+    int zaehler = 0;
+    double zx = 0.0, zy = 0.0, tmp;
+    do {
+      tmp = zx*zx - zy*zy + cx;
+      zy = 2*zx*zy + cy; zx = tmp;
+      zaehler++;
+    } while (zx*zx + zy*zy <= radius && zaehler < maxIt);
+    return zaehler;
+  }
+//StopVisiblePreamble
+  public static void main(String[] argv) throws Exception {  
+    String f_name = new File ((Main.class.getProtectionDomain().getCodeSource().getLocation().toURI()).getPath()).getName();
+    String basename = f_name.replaceAll("\\.[^.]*$", "");
+    int imageBreite = 540, imageHoehe = 405;
+    BufferedImage bufferedImage = new BufferedImage(imageBreite, imageHoehe, BufferedImage.TYPE_INT_RGB);
+    Graphics g = bufferedImage.createGraphics();
+//StartVisibleMain
+    double xa = -2.5, xe = 0.7, ya = -1.2, ye = 1.2; // Ratio 20:15 
+    double dx = (xe-xa)/(imageBreite-1), dy = (ye-ya)/(imageHoehe-1);
+    double cx, cy; int R, G, B;
+    double radius = 10.0;  int maxIt = 1024;
+    cx = xa;
+    for (int sp = 0; sp < imageBreite; sp++) {
+      cy = ye; // von oben nach unten
+      for (int ze = 0; ze < imageHoehe; ze++) {
+        int zIter = iterZahl(cx, cy, maxIt, radius);
+        if (zIter == maxIt) {
+          g.setColor(Color.WHITE);
+          g.drawLine(sp, ze, sp, ze);
+        } else { 
+          R = zIter % 4 * 6 ; G = zIter % 8 * 32; B = zIter % 16 * 16;
+          g.setColor(new Color(R,G,B));
+          g.drawLine(sp, ze, sp, ze);
+        }
+        cy = cy - dy;
+      } // for ze
+      cx = cx + dx;
+    } // for sp
+//StopVisibleMain
+    g.dispose();
+    RenderedImage rendImage = bufferedImage;
+
+    File file = new File(basename+".png");
+    ImageIO.write(rendImage, "png", file);
+  }
+}
+\end{externalDocument}
+
+
+
+
+
 \subsection{Grafik options}
 \begin{verbatim}
 \define at key{hv}{grfOptions}[]{\def\hv at extern@grfOptions{#1}}
@@ -413,7 +485,7 @@
 
 \begin{externalDocument}[grfOptions={angle=90,width=\linewidth},
   compiler=xelatex,code,mpwidth=0.6\linewidth,
-  crop,cleanup,force]{Senger3}
+  crop,cleanup,force]{voss}
 \documentclass{article}
 %StartVisiblePreamble
 \usepackage{tikz}
@@ -1305,6 +1377,7 @@
   showFilename,
 %  crop,
   force,
+  cleanup,
   code,
   docType=mp,
   ext=mp,]{voss}
@@ -1394,7 +1467,7 @@
 \begin{externalDocument}[
   grfOptions={width=0.5\linewidth},
 %  pages={1,3},
-  frame,
+%  frame,
   verbose=false,
   compiler=lualatex,
   showFilename,
@@ -1414,7 +1487,7 @@
 \begin{pspicture}(-9,-15)(9,2)
 \psaxes(0,0)(-9,-15)(9,2)
 \psplot[algebraic,plotstyle=curve,curvature=1 1 0, 
-  linewidth=1pt,linecolor=red]{-8}{8}{
+  linewidth=2pt,linecolor=red]{-8}{8}{
   1 - 3876218985722260225*x^2/10892114744073986176 
     + 14975974793271450625*x^4/174273835905183778816 
     - 317095420958296875*x^6/26811359370028273664 

Modified: trunk/Master/texmf-dist/tex/latex/hvextern/hvextern.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/hvextern/hvextern.sty	2022-04-30 20:01:47 UTC (rev 63186)
+++ trunk/Master/texmf-dist/tex/latex/hvextern/hvextern.sty	2022-04-30 20:02:01 UTC (rev 63187)
@@ -11,8 +11,8 @@
 %% and version 1.3c or later is part of all distributions of LaTeX
 %% version 2005/12/01 or later.
 
-\def\hvexternFileversion{0.20}
-\ProvidesFile{hvextern}[2022/04/27 v\hvexternFileversion: package for running external documents (HV)]
+\def\hvexternFileversion{0.21}
+\ProvidesFile{hvextern}[2022/04/30 v\hvexternFileversion: package for running external documents (HV)]
 
 \RequirePackage{shellesc,xkeyval,graphicx,marginnote,fancyvrb,tikz,listings,ifplatform}
 \RequirePackage{tcolorbox,xparse}
@@ -78,13 +78,14 @@
 \def\hv at typeout#1{\ifhv at extern@verbose\typeout{#1}\fi}
 
 %\define at key{hv}{compiler}[pdflatex]{\def\hv at extern@compiler{#1}}
-\define at choicekey*+{hv}{compiler}[\val\nr]{mpost,tex,latex,luatex,python3,perl,lua,xetex,pdflatex,lualatex,xelatex,context}[pdflatex]{% 
-%  \hv at typeout{>>>> Compiler type \nr}%
+\define at choicekey*+{hv}{compiler}[\val\nr]{mpost,tex,latex,luatex,python3,perl,lua,java,%
+     xetex,pdflatex,lualatex,xelatex,context}[pdflatex]{% 
+  \hv at typeout{>>>> Compiler type \nr}%
   \def\hv at extern@compiler{\val}%
   \edef\hv at extern@compilerNo{\nr}%
 }{\PackageWarning{hvextern}{erroneous input (#1) for compiler ignored. Using pdflatex.}%
   \def\hv at extern@compiler{pdflatex}%
-  \def\hv at extern@compilerNo{6}%
+  \def\hv at extern@compilerNo{9}%
  }
 
 \def\ResetKeys{%
@@ -140,6 +141,9 @@
 \NewDocumentCommand\run at hv@extern at cleanup{ m }
  {
   \clist_map_inline:nn {#1}{\ShellEscape{\hv at rm \hv at extern@ExamplesDir\hvExternDateiname.##1}} 
+  \ifnum\hv at extern@compilerNo=0\relax   % we have metapost
+    \hv at rm epsf.*
+  \fi
  }
 \NewDocumentCommand\run at hv@extern at sequenceList{ m }
  {
@@ -157,9 +161,9 @@
 
 \newcommand\BodyVerbatim[2][]{\begin{tcolorbox}\VerbatimInput[#1]{#2}\end{tcolorbox}}
 
-\newcommand\PreambleListing[2][]{\begin{tcolorbox}\expandafter\lstinputlisting\expandafter[#1]{#2}\end{tcolorbox}}
+\newcommand\PreambleListing[2][]{\begin{tcolorbox}[top=-2pt]\expandafter\lstinputlisting\expandafter[#1]{#2}\end{tcolorbox}}
 
-\newcommand\BodyListing[2][]{\begin{tcolorbox}\expandafter\lstinputlisting\expandafter[#1]{#2}\end{tcolorbox}}
+\newcommand\BodyListing[2][]{\begin{tcolorbox}[top=-2pt]\expandafter\lstinputlisting\expandafter[#1]{#2}\end{tcolorbox}}
 
 \newcounter{hv at example@counter}
 
@@ -168,7 +172,7 @@
   \@namedef{#1 at initPreambleFancy}{\edef\FancyVerbStartString{#4}\edef\FancyVerbStopString{#5}}% code
   \@namedef{#1 at initText}{linerange={#2}-{#3},includerangemarker=false}% text
   \@namedef{#1 at initPreamble}{linerange={#4}-{#5},includerangemarker=false}% code
-}%                                      ^^to prevent problems with lua comments
+}%                                   {} ^^to prevent problems with lua comments
 
 %%------------------   the config part --------------------
 %\input{hvextern-mp.cfg}
@@ -260,6 +264,14 @@
   {--StopVisiblePreamble}
 
 
+%----  Java
+\hv at extern@ExampleType{java}
+  {//StartVisibleMain}
+  {//StopVisibleMain}
+  {//StartVisiblePreamble}
+  {//StopVisiblePreamble}
+
+
 %%%---------------------------------  end config part ------------------
 
 %%
@@ -368,11 +380,13 @@
    \fi
    \ifhv at extern@code\else
       \ifhv at extern@showFilename
+        \hv at typeout{>>>> Set filename in the margin!}%
         \marginnote{\rotatebox{90}{\hvExternDateiname}}%
       \fi
    \fi
    \ifhv at extern@moveToExampleDir
 %     \ShellEscape{mkdir\space\hv at extern@ExamplesDir/}%
+     \hv at typeout{>>>> Move file into example dir}% 
      \ShellEscape{\hv at move \hvExternDateiname.*\space \hv at extern@ExamplesDir}%
    \fi
    \ifhv at extern@includegraphic
@@ -380,8 +394,10 @@
        \expandafter\includegraphics\expandafter[\hv at extern@grfOptions]{\hv at extern@ExamplesDir\hvExternDateiname}%
      \else
        \ifhv at extern@float
+         \hv at typeout{>>>> Floating environment}% 
          \begin{figure}[!htb]
        \else
+         \hv at typeout{>>>> No floating environment}% 
          \ifdim\hv at extern@mpwidth>\z@ 
            \hfill\minipage[t]{\dimexpr\linewidth-\hv at extern@mpwidth-1em\relax}\vspace{0pt}%
          \else
@@ -389,6 +405,7 @@
          \fi
        \fi
        \hv at extern@align
+       \hv at typeout{>>>> Input image \hv at extern@ExamplesDir\hvExternDateiname}% 
        \ifhv at extern@frame
          \expandafter\@for\expandafter\next\expandafter:\expandafter=\hv at extern@pages\do{%
            \fbox{\expandafter\includegraphics\expandafter[\hv at extern@grfOptions,page=\next]{\hv at extern@ExamplesDir\hvExternDateiname}}%



More information about the tex-live-commits mailing list.