texlive[72119] Master/texmf-dist: domaincoloring (27aug24)

commits+karl at tug.org commits+karl at tug.org
Tue Aug 27 21:31:50 CEST 2024


Revision: 72119
          https://tug.org/svn/texlive?view=revision&revision=72119
Author:   karl
Date:     2024-08-27 21:31:50 +0200 (Tue, 27 Aug 2024)
Log Message:
-----------
domaincoloring (27aug24)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/lualatex/domaincoloring/Changes
    trunk/Master/texmf-dist/doc/lualatex/domaincoloring/domaincoloring-doc.bib
    trunk/Master/texmf-dist/doc/lualatex/domaincoloring/domaincoloring-doc.pdf
    trunk/Master/texmf-dist/doc/lualatex/domaincoloring/domaincoloring-doc.tex
    trunk/Master/texmf-dist/doc/lualatex/domaincoloring/titleImg.pdf
    trunk/Master/texmf-dist/tex/lualatex/domaincoloring/domaincoloring-functions.lua
    trunk/Master/texmf-dist/tex/lualatex/domaincoloring/domaincoloring.lua
    trunk/Master/texmf-dist/tex/lualatex/domaincoloring/domaincoloring.sty

Modified: trunk/Master/texmf-dist/doc/lualatex/domaincoloring/Changes
===================================================================
--- trunk/Master/texmf-dist/doc/lualatex/domaincoloring/Changes	2024-08-27 19:31:40 UTC (rev 72118)
+++ trunk/Master/texmf-dist/doc/lualatex/domaincoloring/Changes	2024-08-27 19:31:50 UTC (rev 72119)
@@ -1,3 +1,7 @@
+0.03  2024-08-26  - use \jobname for temporary file
+                  - added option force for not creating already existing pdf's
+                  - allow different x|y resolutions
+                  - updated documentation
 0.02  2024-08-22  - edit option bgcolor
                   - reduced header for the intermediate eps
                   - renamed complex-numbers.lua

Modified: trunk/Master/texmf-dist/doc/lualatex/domaincoloring/domaincoloring-doc.bib
===================================================================
--- trunk/Master/texmf-dist/doc/lualatex/domaincoloring/domaincoloring-doc.bib	2024-08-27 19:31:40 UTC (rev 72118)
+++ trunk/Master/texmf-dist/doc/lualatex/domaincoloring/domaincoloring-doc.bib	2024-08-27 19:31:50 UTC (rev 72119)
@@ -25,3 +25,14 @@
   date = {2024-08-18},
 }
   
+ at online{dm,
+  author = {Juan Carlos Ponce Campuzano},
+  title = {Dynamic Mathematics},
+  subtitle = {Domain Coloring -- Visualizing Complex Functions}, 
+  date = {2018-07-15},
+  urldate = {2024-08-23},
+  url ={https://www.dynamicmath.xyz/domain-coloring/},
+}
+
+  
+  
\ No newline at end of file

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

Modified: trunk/Master/texmf-dist/doc/lualatex/domaincoloring/domaincoloring-doc.tex
===================================================================
--- trunk/Master/texmf-dist/doc/lualatex/domaincoloring/domaincoloring-doc.tex	2024-08-27 19:31:40 UTC (rev 72118)
+++ trunk/Master/texmf-dist/doc/lualatex/domaincoloring/domaincoloring-doc.tex	2024-08-27 19:31:50 UTC (rev 72119)
@@ -1,7 +1,9 @@
-%% $Id: domaincoloring-doc.tex 952 2024-08-22 15:40:35Z herbert $
+%% $Id: domaincoloring-doc.tex 966 2024-08-26 19:55:11Z herbert $
 % 
 \listfiles
 
+\def\header{Complex Functions}
+
 \DocumentMetadata{}
 \documentclass[fontsize=11pt,english,BCOR=10mm,DIV=12,bibliography=totoc,parskip=false,headings=small,
     headinclude=false,footinclude=false,oneside]{pst-doc}
@@ -15,8 +17,12 @@
 \usepackage{enumitem}
 \setlist{noitemsep,nosep}
 
+\usepackage{makeidx}
+\makeindex
+
 \usepackage{domaincoloring}
 \let\DColFV\fileversion
+\setDColkeys{force=false}% only for this documentation relevant
 
 \usepackage{hvlogos} 
 
@@ -23,7 +29,7 @@
 \usepackage{listings}
 \lstset{columns=fixed,basicstyle=\ttfamily\small}
 
-\def\bgImage{\includegraphics[width=7cm]{titleImg}}
+\def\bgImage{\hspace{-2cm}*\includegraphics[width=14cm]{titleImg.png}}
 
 \title{Domain Coloring of complex functions\\version \DColFV}
 \author{Herbert Voß}
@@ -34,7 +40,9 @@
 
 \section{Introduction}
 
-This package works only with \texttt{lualatex}!
+This package works only with \texttt{lualatex} and the option \Loption{shell-escape}! 
+It creates an intermediate external EPS-file, which is automatically converted with
+\LFile{epstopdf}. The pdf is in the end imported by the macro \Lcs{includegraphics}.
 
 \subsection{Loading the package}
 The package \texttt{domaincoloring} creates acolored interpretation of the
@@ -76,16 +84,17 @@
 \noindent
 \begin{xltabular}{\linewidth}{@{} >{\ttfamily}l l X @{}}\\\toprule
 \emph{name} & \emph{value} &\emph{meaning}\\\midrule
-domain & {-2,2,-2,2} & the (re,im)-coordinates for the complex system\\
-resolution & 500 & the number of steps for the re,im interval. At the moment only
-for both coordinates the same. Will be in future
-versions different for the both axes. \\
-filename & \Lcs{jobname-tmp} & name of the created external file, must be unique\\ 
-grfOptions &scale=0.5 & optional arguments for \Lcs{includegraphics}\\
-hsvrgb & {phi,1,r} & for the conversion into rgb\\
-funcName & & corresponding to external file\\
-bgcolor & 0 & change color to white as background for all values $r+g+b\le\text{bgcolor}$\\
-invers & false & inverted colors with $color=|color-255|$\\
+\Lkeyword{domain} & {-2,2,-2,2} & the (re,im)-coordinates for the complex system\\
+\Lkeyword{resolution} & 500 & the number of steps for the re,im interval. One value will be for
+both axes. Two values like \verb|{500,600}| for real axis and imaginary axis,\\
+\Lkeyword{filename} & \Lcs{jobname-tmp} & name of the created external file, must be unique\\ 
+\Lkeyword{funcName} & \texttt{\{\}} & corresponding to external file\\
+\Lkeyword{grfOptions} &scale=0.5 & optional arguments for \Lcs{includegraphics}\\
+\Lkeyword{hsvrgb} & {phi+pi,1,r} & for the conversion into rgb\\
+\Lkeyword{bgcolor} & -1 & change color to white as background for all values $-1\le r+g+b\le\text{bgcolor}$\\
+\Lkeyword{invers} & false & inverted colors with $color=|color-255|$\\
+\Lkeyword{force} & true & With \texttt{force=false} an existing pdf file will be used
+without calculating a new one.\\
 \bottomrule
 \end{xltabular}
 
@@ -96,7 +105,7 @@
 
 \subsection{The default with function $f(z)=z$}
 \begin{lstlisting}
-\DomainColoring{z}\qquad  % default filename \jobname-tmp.png
+\DomainColoring{z}  % default filename \jobname-tmp.png
 \end{lstlisting}
 
 \noindent
@@ -111,7 +120,9 @@
  f(z) &= \cos(z)/\sin(z^4-1)
 \end{align}
 
-in Lua-notation: \verb|cmath.cos(z)/cmath.sin(z^4-1)|.
+in Lua-notation: \verb|cmath.cos(z)/cmath.sin(z^4-1)|. All complex functions
+must be preceeded by \texttt{cmath.}. For real functions the prefix \texttt{math.}
+can be omitted.
 
 \begin{lstlisting}
 \DomainColoring[domain={-2.5,2.5,-2.5,2.5},resolution=500,
@@ -138,7 +149,7 @@
     filename=\jobname-tmp1c]{cmath.cos(z)/cmath.sin(z^4-1)}}
 
 
-With \Lcs{bgcolor}\texttt{=<int>} all RGB-combinations with a sum $R+G+B <= \text{int}$ are set to
+With \Lkeyword{bgcolor}\texttt{=<int>} all RGB-combinations with a sum $R+G+B <= \text{int}$ are set to
 the color white. 
 
 \subsection{Option for \Lcs{includegraphics}}
@@ -159,9 +170,9 @@
 \subsection{Higher resolution}
 
 The resolution is more or less the number of pixels for the given domain.
-In later versions of this package it may be possible to have different values
-for the two coordinates. By now the one value for \Lkeyword{resolution} is for
-both axes.
+It is possible to have different values
+for the two coordinates. Is only one value for \Lkeyword{resolution} given, then it is
+for both axes.
 
 
 \begin{lstlisting}
@@ -182,7 +193,7 @@
 
 \subsection{hsv to rgb conversion}
 
-The color model (Wikipedia)
+The color model (Wikipedia):
 
 \begin{center}
 \includegraphics[width=0.5\linewidth]{hsv}
@@ -222,27 +233,28 @@
 \subsection{External function definition}
 The already existing file \LFile{domaincoloring-functions.lua} collects sone
 definitions of complex functions $f(z)$, which can be used from inside \LaTeX\ 
-with the optional argument \Lkeyword{funcName}. In this case the mandatory argument
+with the optional argument \Lkeyword{funcName}\texttt{<Lua function name>}. 
+In this case the mandatory argument
 of \Lcs{DomainColoring} has no meaning and can be empty.
 
 \begin{lstlisting}
 \DomainColoring[filename=\jobname-tmp6a,resolution=1000,
    domain={-1.5,1.5,-1.5,1.5}, grfOptions={width=0.49\linewidth},
-   hsvrgb={phi+2*pi,1,1/r}, funcName=f12]{}%  using predefined function
+   hsvrgb={phi+pi,1,2/r}, funcName=f12]{}%  using predefined function
 \hfill
 \DomainColoring[filename=\jobname-tmp6b,resolution=2000,
    domain={-2.3,0.7,-1.5,1.5}, grfOptions={width=0.49\linewidth},
-   hsvrgb={phi+2*pi,1,1/r},funcName=f13]{}
+   hsvrgb={phi+pi,1,2/r},funcName=f13]{}
 \end{lstlisting}
 
 \noindent
 \DomainColoring[filename=\jobname-tmp6a,resolution=1000,
    domain={-1.5,1.5,-1.5,1.5}, grfOptions={width=0.49\linewidth},
-   hsvrgb={phi+2*pi,1,1/r}, funcName=f12]{}%  using predefined function
+   hsvrgb={phi+pi,1,2/r}, funcName=f12]{}%  using predefined function
 \hfill
 \DomainColoring[filename=\jobname-tmp6b,resolution=2000,
    domain={-2.3,0.7,-1.5,1.5}, grfOptions={width=0.49\linewidth},
-   hsvrgb={phi+2*pi,1,1/r},funcName=f13]{}
+   hsvrgb={phi+pi,1,2/r},funcName=f13]{}
 
 
 The contents of the function file of the current version of \LPack{domaincoloring} is::
@@ -254,4 +266,5 @@
 \nocite{*}
 \printbibliography
 
+\printindex
 \end{document}

Modified: trunk/Master/texmf-dist/doc/lualatex/domaincoloring/titleImg.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/tex/lualatex/domaincoloring/domaincoloring-functions.lua
===================================================================
--- trunk/Master/texmf-dist/tex/lualatex/domaincoloring/domaincoloring-functions.lua	2024-08-27 19:31:40 UTC (rev 72118)
+++ trunk/Master/texmf-dist/tex/lualatex/domaincoloring/domaincoloring-functions.lua	2024-08-27 19:31:50 UTC (rev 72119)
@@ -1,4 +1,4 @@
--- $Id: domaincoloring-functions.lua 946 2024-08-21 19:32:10Z herbert $
+-- $Id: domaincoloring-functions.lua 965 2024-08-26 17:50:33Z herbert $
 
 kpse.set_program_name("luatex")
 
@@ -72,3 +72,13 @@
   return z
 end
 
+function f14(z)   
+  local iterateNo = 5
+--  local c = z
+--  z = complex(0,0)
+  for n=1,iterateNo do
+    z = cmath.sin(z)*cmath.sin(0.8*z) -- + c
+  end
+  return z
+end
+

Modified: trunk/Master/texmf-dist/tex/lualatex/domaincoloring/domaincoloring.lua
===================================================================
--- trunk/Master/texmf-dist/tex/lualatex/domaincoloring/domaincoloring.lua	2024-08-27 19:31:40 UTC (rev 72118)
+++ trunk/Master/texmf-dist/tex/lualatex/domaincoloring/domaincoloring.lua	2024-08-27 19:31:50 UTC (rev 72119)
@@ -1,4 +1,4 @@
--- $Id: domaincoloring.lua 952 2024-08-22 15:40:35Z herbert $
+-- $Id: domaincoloring.lua 965 2024-08-26 17:50:33Z herbert $
 
 -----------------------------------------------------------------------
 --         FILE:  domaincoloring.lua
@@ -9,7 +9,7 @@
 --
 -----------------------------------------------------------------------
 
-local version = 0.02
+local version = 0.03
 
 kpse.set_program_name("luatex")
 
@@ -65,7 +65,7 @@
 The pixels in the image are square and contiguous.
 ]]  
 
-function write_eps_data(name,data,res)
+function write_eps_data(name,data,domain,res,grid)
   print("Lua: writing data file "..name.." ...")
 --  print(data)
   outFile = io.open(name,"w+") -- Dateiname
@@ -159,17 +159,72 @@
     end
   end
   outFile:write("\n")        -- neue Zeile 
-  outFile:write([[end % of userdict
+  if grid == "true" then
+    outFile:write("gsave \n /xMin "..domain[1].." def\n")
+    outFile:write("/xMax "..domain[2].." def\n")
+    outFile:write("/yMin "..domain[3].." def\n")
+    outFile:write("/yMax "..domain[4].." def\n")
+    outFile:write(res[1].." xMax xMin sub div dup /xScale exch def \n")
+    outFile:write(res[2].." yMax yMin sub div dup /yScale exch def \n")
+    outFile:write("scale\n")
+    outFile:write([[
+xMin neg yMin neg translate % the new origin\n"
+gsave
+xMin floor 0.5 yScale div sub
+  0.5 xMax 0.5 add round { % loop variable on stack\n"
+  dup yMin moveto yMax lineto
+} for
+2 ]])
+    outFile:write(res[2]) 
+    outFile:write([[  div  setlinewidth 0.4 setgray [5 5 ] { ]])
+    outFile:write(res[2]..[[ div } forall 2 array astore 0 setdash
+stroke
+grestore
+gsave
+yMin floor 0.5 yScale div add          % startValue 
+  % with shift 0.5 to be in the middle of the pixel
+  0.5   % step
+  yMax 0.5 add round { % loop variable on stack
+  dup xMin exch moveto xMax exch lineto
+} for
+2 ]])
+    outFile:write(res[1]) 
+    outFile:write([[  div  setlinewidth 0.4 setgray [5 5 ] { ]])
+    outFile:write(res[1]..[[ div } forall 2 array astore 0 setdash
+stroke
+grestore 
+gsave
+xMin floor 0.5 yScale div sub
+  1 xMax 0.5 add round { % loop variable on stack\n"
+  dup yMin moveto yMax lineto
+} for
+2 ]])
+    outFile:write(res[2]) 
+    outFile:write([[ div  setlinewidth 0.3 setgray stroke
+grestore
+gsave
+yMin floor 0.5 yScale div add
+  1 yMax 0.5 add round { % loop variable on stack
+  dup xMin exch moveto xMax exch lineto
+} for 
+2 ]])
+    outFile:write(res[1]) 
+    outFile:write([[ div  setlinewidth 0.3 setgray stroke
+grestore
+]])
+  end
+  outFile:write([[
+end % of userdict
 %%PageTrailer
 %%Trailer
 %%EOF
-]])
+    ]])
   outFile:close() -- Datei schließen 
   --os.execute("pnmtopng apfel.ppm >"..fileName..".png") -- ppm -> png Format 
 end
 
-function write_data(name,data,res)  -- only valid for writing ppm files
-  print("\nLua: writing data file "..name.." ...")
+function write_data(name,data,domain,res)  -- only valid for writing ppm files
+  print("Lua: writing data to file "..name.." ...")
 --  print(data)
   outFile = io.open(name,"w+") -- Dateiname
   outFile:write("P3 ")                -- Grafictype R G B
@@ -192,6 +247,7 @@
 end
 
 function plot(fString, domain, res, funcName, hsvrgb, bgColor, invers)
+  print("\nLua: calculating data with "..tostring(fString).." ... ")
   local left = domain[1]
   local right = domain[2]
   local bottom = domain[3]
@@ -222,7 +278,7 @@
           color[c] = math.abs(color[c]-255)
         end
       end
-      if bgColor > 0 then
+      if bgColor > -1 then
         if color[1] + color[2] + color[3] <= bgColor then
           color = { 255, 255, 255 }
         end
@@ -241,13 +297,13 @@
   Resolution: (points per Interval) xRes,yRes
   funcName: true/false (see f)    
 ]]
-function createData(f,Domain,Resolution,funcName,hsvrgb,bgColor,invers)
-  if funcName == "" then
-    img = plot(f,Domain,Resolution,false,hsvrgb,bgColor,invers)
-  else
-    img = plot(load("return "..funcName)(),Domain,Resolution,true,hsvrgb,bgColor,invers)
-  end
+function createData(jobname,f,funcName,Domain,Resolution,hsvrgb,bgColor,invers,grid)
+    if funcName == "" then
+      img = plot(f,Domain,Resolution,false,hsvrgb,bgColor,invers)
+    else
+      img = plot(load("return "..funcName)(),Domain,Resolution,true,hsvrgb,bgColor,invers)
+    end
 --  write_data("domain.ppm",img,Resolution)
-  write_eps_data("domain.eps",img,Resolution)
+    write_eps_data(jobname.."-domain.eps",img,Domain,Resolution,grid)
 end
 

Modified: trunk/Master/texmf-dist/tex/lualatex/domaincoloring/domaincoloring.sty
===================================================================
--- trunk/Master/texmf-dist/tex/lualatex/domaincoloring/domaincoloring.sty	2024-08-27 19:31:40 UTC (rev 72118)
+++ trunk/Master/texmf-dist/tex/lualatex/domaincoloring/domaincoloring.sty	2024-08-27 19:31:50 UTC (rev 72119)
@@ -1,4 +1,4 @@
-%% $Id: domaincoloring.sty 952 2024-08-22 15:40:35Z herbert $
+%% $Id: domaincoloring.sty 966 2024-08-26 19:55:11Z herbert $
 %% This is file `domaincoloring.sty',
 %%
 %% Copyright (C) 2024-   Herbert Voss
@@ -14,13 +14,13 @@
 \RequirePackage{graphicx}
 \RequirePackage{shellesc}
 
-\def\fileversion{0.02}
-\def\filedate{2024/08/22}
+\def\fileversion{0.03}
+\def\filedate{2024/08/26}
 \message{`DCol' v\fileversion, \filedate}
 \ProvidesPackage{domaincoloring}
-  [\filedate\ \fileversion\ 0.02 package for domain coloring of complex functions]
+  [\filedate\ \fileversion\  package for domain coloring of complex functions]
 
-\ifnum\ShellEscapeStatus  < 1
+\ifnum\ShellEscapeStatus < 1
     \PackageError{shellesc}{ShellEscape not enabled! Use --shell-escape}%
 \fi
 
@@ -28,7 +28,13 @@
 \catcode`\^=11\relax  % for power symbol in Lua
 
 \define at key{DCol}{domain}{\def\@domaincoloring at domain{#1}}
-\define at key{DCol}{resolution}{\def\@domaincoloring at res{#1,#1}}
+\define at key{DCol}{resolution}{\@domaincoloring at res@i#1,\@nil}
+\def\@domaincoloring at res@i#1,#2\@nil{%
+  \ifx\relax#2\relax  % only one value
+    \def\@domaincoloring at res{#1,#1}%
+  \else
+    \def\@domaincoloring at res{#1,#2}%
+  \fi}
 \define at key{DCol}{bgcolor}{\def\@domaincoloring at bgcolor{#1}}
 \define at key{DCol}{filename}{\def\@domaincoloring at filename{#1}}
 \define at key{DCol}{hsvrgb}{\def\@domaincoloring at hsvrgb{#1}}
@@ -35,18 +41,22 @@
 \define at key{DCol}{funcName}{\def\@domaincoloring at funcName{#1}}
 \define at key{DCol}{invers}{\def\@domaincoloring at invers{#1}}
 \define at key{DCol}{grfOptions}{\def\@domaincoloring at grf{#1}}
+\define at boolkey{DCol}[DCol@]{force}[true]{}
+\define at boolkey{DCol}[DCol@]{grid}[true]{}
 
 \def\setDColkeys#1{\edef\x{\noexpand\setkeys{DCol}{#1}}\x}
 
 \setDColkeys{
   funcName={},               % corresponding to external file
-  hsvrgb={phi+3.14,1,r},     % given (r,phi) of the complex value
+  hsvrgb={phi+pi,1,r},       % given (r,phi) of the complex value
   filename=\jobname-tmp,     % the external image filename
   resolution=500,            % pixel per (x|y) interval
   domain={-2,2,-2,2},        % x|y domain
-  bgcolor=0,                 % R+G+B value, changes only 0,0,0 -> 255,255,255
+  bgcolor=-1,                % R+G+B value, changes only 0,0,0 -> 255,255,255
   invers=false,              % 0 or 1 vor inverted colors
   grfOptions={scale=0.5},    % LaTeX options for the included image
+  force=true,                % only valid for the documentation
+  grid=false,                % draw a grid into the image
 }% 
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -55,14 +65,22 @@
 \def\DomainColoring at i[#1]#2{%
   \begingroup
   \setDColkeys{#1}%
-  \directlua{
-    require("domaincoloring-complex-numbers")
-    require ("domaincoloring")
-    createData("#2",{\@domaincoloring at domain},{\@domaincoloring at res},
-               "\@domaincoloring at funcName","\@domaincoloring at hsvrgb",
-               \@domaincoloring at bgcolor,"\@domaincoloring at invers")}%
-  \typeout{Convert domain.eps file to \@domaincoloring at filename.pdf}%
-  \ShellEscape{epstopdf domain.eps \@domaincoloring at filename.pdf}%
+  \ifDCol at force\else
+    \IfFileExists{\@domaincoloring at filename.pdf}{}{\DCol at forcetrue}%
+  \fi
+  \ifDCol at force  
+    \directlua{%
+      require("domaincoloring-complex-numbers")
+      require ("domaincoloring")
+      createData("\jobname",
+               "#2","\@domaincoloring at funcName", % user defined, function no from -functions.lua 
+               {\@domaincoloring at domain},{\@domaincoloring at res},
+               "\@domaincoloring at hsvrgb",
+               \@domaincoloring at bgcolor,"\@domaincoloring at invers",
+               \ifDCol at grid "true" \else "false" \fi)}%
+    \typeout{Convert \jobname-domain.eps file to \@domaincoloring at filename.pdf}%
+    \ShellEscape{epstopdf \jobname-domain.eps \@domaincoloring at filename.pdf}%
+  \fi
   %
   \expandafter\includegraphics\expandafter[\@domaincoloring at grf]{\@domaincoloring at filename.pdf}%
   \endgroup



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