summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2024-08-27 19:31:50 +0000
committerKarl Berry <karl@freefriends.org>2024-08-27 19:31:50 +0000
commita0ffed9804111ae312b1710fe706e819495c0648 (patch)
tree24e1d59fa99b1eb5e3d321ef42c80a9260ac9994
parentadcc42259991461c70441605834e890e99b5c9fb (diff)
domaincoloring (27aug24)
git-svn-id: svn://tug.org/texlive/trunk@72119 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r--Master/texmf-dist/doc/lualatex/domaincoloring/Changes4
-rw-r--r--Master/texmf-dist/doc/lualatex/domaincoloring/domaincoloring-doc.bib11
-rw-r--r--Master/texmf-dist/doc/lualatex/domaincoloring/domaincoloring-doc.pdfbin6845040 -> 12831690 bytes
-rw-r--r--Master/texmf-dist/doc/lualatex/domaincoloring/domaincoloring-doc.tex63
-rw-r--r--Master/texmf-dist/doc/lualatex/domaincoloring/titleImg.pdfbin335225 -> 334858 bytes
-rw-r--r--Master/texmf-dist/tex/lualatex/domaincoloring/domaincoloring-functions.lua12
-rw-r--r--Master/texmf-dist/tex/lualatex/domaincoloring/domaincoloring.lua86
-rw-r--r--Master/texmf-dist/tex/lualatex/domaincoloring/domaincoloring.sty50
8 files changed, 169 insertions, 57 deletions
diff --git a/Master/texmf-dist/doc/lualatex/domaincoloring/Changes b/Master/texmf-dist/doc/lualatex/domaincoloring/Changes
index e49a69aac3c..725f4399fba 100644
--- a/Master/texmf-dist/doc/lualatex/domaincoloring/Changes
+++ b/Master/texmf-dist/doc/lualatex/domaincoloring/Changes
@@ -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
diff --git a/Master/texmf-dist/doc/lualatex/domaincoloring/domaincoloring-doc.bib b/Master/texmf-dist/doc/lualatex/domaincoloring/domaincoloring-doc.bib
index d109070c927..5529a63a489 100644
--- a/Master/texmf-dist/doc/lualatex/domaincoloring/domaincoloring-doc.bib
+++ b/Master/texmf-dist/doc/lualatex/domaincoloring/domaincoloring-doc.bib
@@ -25,3 +25,14 @@
date = {2024-08-18},
}
+@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
diff --git a/Master/texmf-dist/doc/lualatex/domaincoloring/domaincoloring-doc.pdf b/Master/texmf-dist/doc/lualatex/domaincoloring/domaincoloring-doc.pdf
index 8a8b79e4d98..bf0e31988ee 100644
--- a/Master/texmf-dist/doc/lualatex/domaincoloring/domaincoloring-doc.pdf
+++ b/Master/texmf-dist/doc/lualatex/domaincoloring/domaincoloring-doc.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/lualatex/domaincoloring/domaincoloring-doc.tex b/Master/texmf-dist/doc/lualatex/domaincoloring/domaincoloring-doc.tex
index 63c33ec368f..cedf037ab1c 100644
--- a/Master/texmf-dist/doc/lualatex/domaincoloring/domaincoloring-doc.tex
+++ b/Master/texmf-dist/doc/lualatex/domaincoloring/domaincoloring-doc.tex
@@ -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,15 +17,19 @@
\usepackage{enumitem}
\setlist{noitemsep,nosep}
+\usepackage{makeidx}
+\makeindex
+
\usepackage{domaincoloring}
\let\DColFV\fileversion
+\setDColkeys{force=false}% only for this documentation relevant
\usepackage{hvlogos}
\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 @@ Every math function has to be preceeded by \texttt{cmath} if it has a complex ar
\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 @@ invers & false & inverted colors with $color=|color-255|$\\
\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 @@ invers & false & inverted colors with $color=|color-255|$\\
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 @@ in Lua-notation: \verb|cmath.cos(z)/cmath.sin(z^4-1)|.
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 @@ With \Lkeyword{grfOptions} one can define optional arguments for \Lcs{includegra
\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 @@ both axes.
\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 @@ e.g. \texttt{hsvrgb=\{phi+2,0.5,2/r\}}
\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 @@ The contents of the function file of the current version of \LPack{domaincolorin
\nocite{*}
\printbibliography
+\printindex
\end{document}
diff --git a/Master/texmf-dist/doc/lualatex/domaincoloring/titleImg.pdf b/Master/texmf-dist/doc/lualatex/domaincoloring/titleImg.pdf
index e68120b481d..decae34f421 100644
--- a/Master/texmf-dist/doc/lualatex/domaincoloring/titleImg.pdf
+++ b/Master/texmf-dist/doc/lualatex/domaincoloring/titleImg.pdf
Binary files differ
diff --git a/Master/texmf-dist/tex/lualatex/domaincoloring/domaincoloring-functions.lua b/Master/texmf-dist/tex/lualatex/domaincoloring/domaincoloring-functions.lua
index 84cfd65d7c6..bd71f282ce7 100644
--- a/Master/texmf-dist/tex/lualatex/domaincoloring/domaincoloring-functions.lua
+++ b/Master/texmf-dist/tex/lualatex/domaincoloring/domaincoloring-functions.lua
@@ -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 @@ function f13(z) -- mandelbrot
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
+
diff --git a/Master/texmf-dist/tex/lualatex/domaincoloring/domaincoloring.lua b/Master/texmf-dist/tex/lualatex/domaincoloring/domaincoloring.lua
index 2b2ae177ead..872acc762f0 100644
--- a/Master/texmf-dist/tex/lualatex/domaincoloring/domaincoloring.lua
+++ b/Master/texmf-dist/tex/lualatex/domaincoloring/domaincoloring.lua
@@ -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 @@ A row of an image is horizontal. A column is vertical.
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 @@ DisplayImage
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 @@ function write_data(name,data,res) -- only valid for writing ppm files
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 @@ function plot(fString, domain, res, funcName, hsvrgb, bgColor, invers)
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 @@ end
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
diff --git a/Master/texmf-dist/tex/lualatex/domaincoloring/domaincoloring.sty b/Master/texmf-dist/tex/lualatex/domaincoloring/domaincoloring.sty
index d668d057f03..170e1897f03 100644
--- a/Master/texmf-dist/tex/lualatex/domaincoloring/domaincoloring.sty
+++ b/Master/texmf-dist/tex/lualatex/domaincoloring/domaincoloring.sty
@@ -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,25 +28,35 @@
\catcode`\^=11\relax % for power symbol in Lua
\define@key{DCol}{domain}{\def\@domaincoloring@domain{#1}}
-\define@key{DCol}{resolution}{\def\@domaincoloring@res{#1,#1}}
+\define@key{DCol}{resolution}{\@domaincoloring@res@i#1,\@nil}
+\def\@domaincoloring@res@i#1,#2\@nil{%
+ \ifx\relax#2\relax % only one value
+ \def\@domaincoloring@res{#1,#1}%
+ \else
+ \def\@domaincoloring@res{#1,#2}%
+ \fi}
\define@key{DCol}{bgcolor}{\def\@domaincoloring@bgcolor{#1}}
\define@key{DCol}{filename}{\def\@domaincoloring@filename{#1}}
\define@key{DCol}{hsvrgb}{\def\@domaincoloring@hsvrgb{#1}}
\define@key{DCol}{funcName}{\def\@domaincoloring@funcName{#1}}
\define@key{DCol}{invers}{\def\@domaincoloring@invers{#1}}
\define@key{DCol}{grfOptions}{\def\@domaincoloring@grf{#1}}
+\define@boolkey{DCol}[DCol@]{force}[true]{}
+\define@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@i[#1]#2{%
\begingroup
\setDColkeys{#1}%
- \directlua{
- require("domaincoloring-complex-numbers")
- require ("domaincoloring")
- createData("#2",{\@domaincoloring@domain},{\@domaincoloring@res},
- "\@domaincoloring@funcName","\@domaincoloring@hsvrgb",
- \@domaincoloring@bgcolor,"\@domaincoloring@invers")}%
- \typeout{Convert domain.eps file to \@domaincoloring@filename.pdf}%
- \ShellEscape{epstopdf domain.eps \@domaincoloring@filename.pdf}%
+ \ifDCol@force\else
+ \IfFileExists{\@domaincoloring@filename.pdf}{}{\DCol@forcetrue}%
+ \fi
+ \ifDCol@force
+ \directlua{%
+ require("domaincoloring-complex-numbers")
+ require ("domaincoloring")
+ createData("\jobname",
+ "#2","\@domaincoloring@funcName", % user defined, function no from -functions.lua
+ {\@domaincoloring@domain},{\@domaincoloring@res},
+ "\@domaincoloring@hsvrgb",
+ \@domaincoloring@bgcolor,"\@domaincoloring@invers",
+ \ifDCol@grid "true" \else "false" \fi)}%
+ \typeout{Convert \jobname-domain.eps file to \@domaincoloring@filename.pdf}%
+ \ShellEscape{epstopdf \jobname-domain.eps \@domaincoloring@filename.pdf}%
+ \fi
%
\expandafter\includegraphics\expandafter[\@domaincoloring@grf]{\@domaincoloring@filename.pdf}%
\endgroup