diff options
author | Norbert Preining <norbert@preining.info> | 2024-08-23 03:03:10 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2024-08-23 03:03:10 +0000 |
commit | 82f5764bd001d191b822d064f56dac669d1325a0 (patch) | |
tree | bb43d59f497a02adebc54ea61274fd63eccc7f13 /macros/luatex | |
parent | b705e74a380bef7cb2ca827bff29f28062cbdbe2 (diff) |
CTAN sync 202408230303
Diffstat (limited to 'macros/luatex')
-rw-r--r-- | macros/luatex/latex/domaincoloring/Changes | 5 | ||||
-rw-r--r-- | macros/luatex/latex/domaincoloring/README.md | 8 | ||||
-rw-r--r-- | macros/luatex/latex/domaincoloring/doc/domaincoloring-doc.pdf | bin | 7132684 -> 6845040 bytes | |||
-rw-r--r-- | macros/luatex/latex/domaincoloring/doc/domaincoloring-doc.tex | 116 | ||||
-rw-r--r-- | macros/luatex/latex/domaincoloring/doc/titleImg.pdf | bin | 0 -> 335225 bytes | |||
-rw-r--r-- | macros/luatex/latex/domaincoloring/latex/domaincoloring.sty | 24 | ||||
-rw-r--r-- | macros/luatex/latex/domaincoloring/lua/domaincoloring-complex-numbers.lua (renamed from macros/luatex/latex/domaincoloring/lua/complex-numbers.lua) | 0 | ||||
-rw-r--r-- | macros/luatex/latex/domaincoloring/lua/domaincoloring-functions.lua | 6 | ||||
-rw-r--r-- | macros/luatex/latex/domaincoloring/lua/domaincoloring.lua | 108 |
9 files changed, 123 insertions, 144 deletions
diff --git a/macros/luatex/latex/domaincoloring/Changes b/macros/luatex/latex/domaincoloring/Changes index 1498297672..e49a69aac3 100644 --- a/macros/luatex/latex/domaincoloring/Changes +++ b/macros/luatex/latex/domaincoloring/Changes @@ -1 +1,4 @@ -0.01 2024-08-21 - first CTAN version +0.02 2024-08-22 - edit option bgcolor + - reduced header for the intermediate eps + - renamed complex-numbers.lua +0.01 2024-08-18 - first CTAN version diff --git a/macros/luatex/latex/domaincoloring/README.md b/macros/luatex/latex/domaincoloring/README.md index 3a57b45ee4..9cff64e2f1 100644 --- a/macros/luatex/latex/domaincoloring/README.md +++ b/macros/luatex/latex/domaincoloring/README.md @@ -2,9 +2,11 @@ Package domaincoloring creates a colored representation of the domain of complex function. +The package needs lualatex and does not work with pdflatex or xelatex! -%% This file is distributed under the terms of the LaTeX Project Public -%% License from CTAN archives in directory macros/latex/base/lppl.txt. -%% Either version 1.3 or, at your option, any later version. +%% This program can be redistributed and/or modified under the terms +%% of the LaTeX Project Public License Distributed from CTAN archives. +%% The latest version of this license is in +%% http://www.latex-project.org/lppl.txt hvoss@tug.org
\ No newline at end of file diff --git a/macros/luatex/latex/domaincoloring/doc/domaincoloring-doc.pdf b/macros/luatex/latex/domaincoloring/doc/domaincoloring-doc.pdf Binary files differindex 19e3b30033..8a8b79e4d9 100644 --- a/macros/luatex/latex/domaincoloring/doc/domaincoloring-doc.pdf +++ b/macros/luatex/latex/domaincoloring/doc/domaincoloring-doc.pdf diff --git a/macros/luatex/latex/domaincoloring/doc/domaincoloring-doc.tex b/macros/luatex/latex/domaincoloring/doc/domaincoloring-doc.tex index 80377e25ae..63c33ec368 100644 --- a/macros/luatex/latex/domaincoloring/doc/domaincoloring-doc.tex +++ b/macros/luatex/latex/domaincoloring/doc/domaincoloring-doc.tex @@ -1,59 +1,41 @@ -%% $Id: domaincoloring-doc.tex 945 2024-08-21 19:30:48Z herbert $ +%% $Id: domaincoloring-doc.tex 952 2024-08-22 15:40:35Z herbert $ % -% Copying and distribution of this file, with or without modification, -% are permitted in any medium, without royalty. +\listfiles +\DocumentMetadata{} +\documentclass[fontsize=11pt,english,BCOR=10mm,DIV=12,bibliography=totoc,parskip=false,headings=small, + headinclude=false,footinclude=false,oneside]{pst-doc} \listfiles -\PassOptionsToPackage{table}{xcolor} -\documentclass[fontsize=11pt,paper=a4,twoside=on,abstract=on,usegeometry]{scrartcl} -\usepackage[bmargin=1cm,tmargin=1cm,includeheadfoot]{geometry} - -\usepackage{unicode-math} -\usepackage[RM={Scale=0.94}, - SS={Scale=0.94}, - SScon={Scale=0.94}, - TT={Scale=MatchLowercase,FakeStretch=0.9}, - DefaultFeatures={Ligatures=TeX}]{libertinus-otf} -\setmonofont{AnonymousPro}[FakeStretch=0.9,Scale=MatchLowercase] -\usepackage[english]{babel} -%\usepackage[autostyle]{csquotes} -%\DeclareQuoteStyle{polish}{,,}{''}{«}{»} \usepackage{biblatex} \addbibresource{\jobname.bib} -\usepackage{array,multido} -\usepackage{metalogo} % for \XeTeX logo + \usepackage{booktabs} % for examples \usepackage{xltabular} % for examples \usepackage{enumitem} \setlist{noitemsep,nosep} + \usepackage{domaincoloring} +\let\DColFV\fileversion -\usepackage{multicol,hvlogos} % for Wikipedia W +\usepackage{hvlogos} \usepackage{listings} \lstset{columns=fixed,basicstyle=\ttfamily\small} -\pagestyle{headings} - -\usepackage[colorlinks,hyperfootnotes=false]{hyperref} -% define \code for url-like breaking of typewriter fragments. -\ifx\nolinkurl\undefined \let\code\url \else \let\code\nolinkurl \fi - -% Define \cs to prepend a backslash, and be unbreakable: -\DeclareRobustCommand\cs[1]{\mbox{\texttt{\char`\\#1}}} - -\let\Lkeyword\texttt +\def\bgImage{\includegraphics[width=7cm]{titleImg}} -\title{Domain Coloring of complex functions} +\title{Domain Coloring of complex functions\\version \DColFV} \author{Herbert Voß} \begin{document} -\maketitle +\settitle \tableofcontents \section{Introduction} +This package works only with \texttt{lualatex}! + \subsection{Loading the package} The package \texttt{domaincoloring} creates acolored interpretation of the domain of a complex function. The package itself has no options and should be loaded as @@ -67,7 +49,7 @@ The needs the following Lua modules: \begin{itemize} \item \texttt{domaincoloring.lua} the main module -\item \texttt{complex-numbers.lua} for complex math operations +\item \texttt{domaincoloring-complex-numbers.lua} for complex math operations \item \texttt{domaincoloring-functions.lua} for predefined complex functions \end{itemize} @@ -84,11 +66,11 @@ ppm-file into a png file.. \begin{verbatim} -\DomainColoring[options]{complex function} +\DomainColoring[options]{complex function in Lua notation} \end{verbatim} +Every math function has to be preceeded by \texttt{cmath} if it has a complex argument. -\clearpage \subsection{Options} \noindent @@ -98,16 +80,19 @@ 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 & \cs{jobname-tmp} & name of the created external file, must be unique\\ -grfOptions &scale=0.5 & optional arguments for \cs{includegraphics}\\ +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 & false & change black to white as background\\ -invers & false & invers colors with $color=|color-255|$\\ +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|$\\ \bottomrule \end{xltabular} -\section{examples} + + + +\section{Examples} \subsection{The default with function $f(z)=z$} \begin{lstlisting} @@ -119,20 +104,26 @@ invers & false & invers colors with $color=|color-255|$\\ %\DomainColoring[filename=demo2.png,bgcolor=true]{z} -\clearpage \subsection{Defining domain, color mode, resolution and filename} + +\begin{align} + f(z) &= \cos(z)/\sin(z^4-1) +\end{align} + +in Lua-notation: \verb|cmath.cos(z)/cmath.sin(z^4-1)|. + \begin{lstlisting} \DomainColoring[domain={-2.5,2.5,-2.5,2.5},resolution=500, grfOptions={width=0.32\linewidth}, filename=\jobname-tmp1a]{cmath.cos(z)/cmath.sin(z^4-1)} \hfill \frame{\DomainColoring[domain={-2.5,2.5,-2.5,2.5},resolution=500, - bgcolor=true,grfOptions={width=0.32\linewidth} + bgcolor=true,grfOptions={width=0.32\linewidth},bgcolor=3, filename=\jobname-tmp1b]{cmath.cos(z)/cmath.sin(z^4-1)}} \hfill \frame{\DomainColoring[domain={-2.5,2.5,-2.5,2.5},resolution=500, - invers=true,,grfOptions={width=0.32\linewidth} + invers=true,,grfOptions={width=0.32\linewidth}, filename=\jobname-tmp1c]{cmath.cos(z)/cmath.sin(z^4-1)}} \end{lstlisting} @@ -140,13 +131,18 @@ invers & false & invers colors with $color=|color-255|$\\ \DomainColoring[domain={-2.5,2.5,-2.5,2.5},resolution=500,grfOptions={width=0.32\linewidth}, filename=\jobname-tmp1a]{cmath.cos(z)/cmath.sin(z^4-1)} \hfill -\frame{\DomainColoring[domain={-2.5,2.5,-2.5,2.5},resolution=500,bgcolor=true,grfOptions={width=0.32\linewidth}, +\frame{\DomainColoring[domain={-2.5,2.5,-2.5,2.5},resolution=500,bgcolor=3,grfOptions={width=0.32\linewidth}, filename=\jobname-tmp1b]{cmath.cos(z)/cmath.sin(z^4-1)}} \hfill \frame{\DomainColoring[domain={-2.5,2.5,-2.5,2.5},resolution=500,invers=true,grfOptions={width=0.32\linewidth}, filename=\jobname-tmp1c]{cmath.cos(z)/cmath.sin(z^4-1)}} -\subsection{Option for \cs{includegraphics}} + +With \Lcs{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}} +With \Lkeyword{grfOptions} one can define optional arguments for \Lcs{includegraphics}: \begin{lstlisting} \DomainColoring[grfOptions={width=0.49\linewidth},filename=\jobname-tmp2a]{cmath.sin(z)}\hfill @@ -160,9 +156,14 @@ invers & false & invers colors with $color=|color-255|$\\ \DomainColoring[grfOptions={width=0.49\linewidth},filename=\jobname-tmp2b]{1/cmath.sin(z)} -\clearpage \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. + + \begin{lstlisting} \DomainColoring[filename=\jobname-tmp3,resolution=1000, grfOptions={width=0.49\linewidth}]{z^3-1} @@ -193,7 +194,7 @@ The color model (Wikipedia) The complex number $z=x+iy$ is converted into its trogonometrical representation $x=r\cdot \cos\phi$ and $y=r\cdot \sin\phi$ with $r=\sqrt{x^2+y^2}$. The values $r$ and $\phi$ are now taken as values for the hsv color model with a constant second value for saturation. $\phi$ is used -for hue. For example: \verb|hsv=phi,1,r|, which gives +for hue. For example: \verb|hsvrgb=phi,1,r|, which gives \begin{lstlisting} \DomainColoring[filename=\jobname-tmp5a,resolution=1000, @@ -211,34 +212,40 @@ for hue. For example: \verb|hsv=phi,1,r|, which gives grfOptions={width=0.49\linewidth}]{cmath.sin(z)*cmath.sin(0.99*z)} %For $r$ and $\phi$ we have to use $r$ and $phi$. +The optional argument \Lkeyword{hsvrgb} must define three values which can use the arguments +phi and r in any mathematical combination. It must only be compatible to the Lua math conventions, +e.g. \texttt{hsvrgb=\{phi+2,0.5,2/r\}} + + + \subsection{External function definition} -The already existing file \verb|domaincoloring.functions| collects sone +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 -of \cs{DomainColoring} has no meaning and can be empty. +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,1,1/r}, funcName=f12]{}% using predefined function + hsvrgb={phi+2*pi,1,1/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,1,1/r},funcName=f13]{} + hsvrgb={phi+2*pi,1,1/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,1,1/r}, funcName=f12]{}% using predefined function + hsvrgb={phi+2*pi,1,1/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,1,1/r},funcName=f13]{} + hsvrgb={phi+2*pi,1,1/r},funcName=f13]{} -The currently contents of the function file: +The contents of the function file of the current version of \LPack{domaincoloring} is:: \lstinputlisting[language={[5.3]Lua},basicstyle=\small\ttfamily]{domaincoloring-functions.lua} @@ -246,4 +253,5 @@ The currently contents of the function file: \nocite{*} \printbibliography + \end{document} diff --git a/macros/luatex/latex/domaincoloring/doc/titleImg.pdf b/macros/luatex/latex/domaincoloring/doc/titleImg.pdf Binary files differnew file mode 100644 index 0000000000..e68120b481 --- /dev/null +++ b/macros/luatex/latex/domaincoloring/doc/titleImg.pdf diff --git a/macros/luatex/latex/domaincoloring/latex/domaincoloring.sty b/macros/luatex/latex/domaincoloring/latex/domaincoloring.sty index 8b17cd6a8c..d668d057f0 100644 --- a/macros/luatex/latex/domaincoloring/latex/domaincoloring.sty +++ b/macros/luatex/latex/domaincoloring/latex/domaincoloring.sty @@ -1,23 +1,25 @@ -%% $Id: domaincoloring.sty 945 2024-08-21 19:30:48Z herbert $ +%% $Id: domaincoloring.sty 952 2024-08-22 15:40:35Z herbert $ %% This is file `domaincoloring.sty', %% %% Copyright (C) 2024- Herbert Voss %% -%% It may be distributed and/or modified under the -%% conditions of the LaTeX Project Public License, either version 1.3c -%% of this license or (at your option) any later version. +%% This program can be redistributed and/or modified under the terms +%% of the LaTeX Project Public License Distributed from CTAN archives. %% The latest version of this license is in %% http://www.latex-project.org/lppl.txt -%% and version 1.3c or later is part of all distributions of LaTeX -%% version 2005/12/01 or later. \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{domaincoloring} - [2024/08/21 package for domain coloring of complex values] + \RequirePackage{xkeyval} \RequirePackage{graphicx} \RequirePackage{shellesc} +\def\fileversion{0.02} +\def\filedate{2024/08/22} +\message{`DCol' v\fileversion, \filedate} +\ProvidesPackage{domaincoloring} + [\filedate\ \fileversion\ 0.02 package for domain coloring of complex functions] + \ifnum\ShellEscapeStatus < 1 \PackageError{shellesc}{ShellEscape not enabled! Use --shell-escape}% \fi @@ -42,7 +44,7 @@ filename=\jobname-tmp, % the external image filename resolution=500, % pixel per (x|y) interval domain={-2,2,-2,2}, % x|y domain - bgcolor=false, % RGB value, changes only 0,0,0 -> 255,255,255 + bgcolor=0, % 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 }% @@ -54,11 +56,11 @@ \begingroup \setDColkeys{#1}% \directlua{ - require("complex-numbers") + require("domaincoloring-complex-numbers") require ("domaincoloring") createData("#2",{\@domaincoloring@domain},{\@domaincoloring@res}, "\@domaincoloring@funcName","\@domaincoloring@hsvrgb", - "\@domaincoloring@bgcolor","\@domaincoloring@invers")}% + \@domaincoloring@bgcolor,"\@domaincoloring@invers")}% \typeout{Convert domain.eps file to \@domaincoloring@filename.pdf}% \ShellEscape{epstopdf domain.eps \@domaincoloring@filename.pdf}% % diff --git a/macros/luatex/latex/domaincoloring/lua/complex-numbers.lua b/macros/luatex/latex/domaincoloring/lua/domaincoloring-complex-numbers.lua index 7630433984..7630433984 100644 --- a/macros/luatex/latex/domaincoloring/lua/complex-numbers.lua +++ b/macros/luatex/latex/domaincoloring/lua/domaincoloring-complex-numbers.lua diff --git a/macros/luatex/latex/domaincoloring/lua/domaincoloring-functions.lua b/macros/luatex/latex/domaincoloring/lua/domaincoloring-functions.lua index 9bd96de0b2..84cfd65d7c 100644 --- a/macros/luatex/latex/domaincoloring/lua/domaincoloring-functions.lua +++ b/macros/luatex/latex/domaincoloring/lua/domaincoloring-functions.lua @@ -55,7 +55,7 @@ function f11(z) end function f12(z) -- julia - local iterateNo = 5 + local iterateNo = 15 for n=1,iterateNo do z = z^2 + complex(0.25,-0.5) end @@ -63,8 +63,8 @@ function f12(z) -- julia end function f13(z) -- mandelbrot - local iterateNo = 6 - c = z + local iterateNo = 15 + local c = z z = complex(0,0) for n=1,iterateNo do z = z^2 + c diff --git a/macros/luatex/latex/domaincoloring/lua/domaincoloring.lua b/macros/luatex/latex/domaincoloring/lua/domaincoloring.lua index a040e27424..2b2ae177ea 100644 --- a/macros/luatex/latex/domaincoloring/lua/domaincoloring.lua +++ b/macros/luatex/latex/domaincoloring/lua/domaincoloring.lua @@ -1,8 +1,19 @@ --- $Id: domaincoloring.lua 946 2024-08-21 19:32:10Z herbert $ +-- $Id: domaincoloring.lua 952 2024-08-22 15:40:35Z herbert $ + +----------------------------------------------------------------------- +-- FILE: domaincoloring.lua +-- DESCRIPTION: create a visual reprensation of a complex function +-- REQUIREMENTS: +-- AUTHOR: Herbert Voß +-- LICENSE: LPPL 1.3 +-- +----------------------------------------------------------------------- + +local version = 0.02 kpse.set_program_name("luatex") -require("complex-numbers") +require("domaincoloring-complex-numbers") local func = io.open("domaincoloring-functions.lua","r") if func~=nil then @@ -11,12 +22,12 @@ if func~=nil then end local function HSVtoRGB(h, s, v) - i = math.floor(h * 6) - f = h * 6 - i - p = v * (1 - s) - q = v * (1 - f * s) - t = v * (1 - (1 - f) * s) - no = i // 6 + local i = math.floor(h * 6) + local f = h * 6 - i + local p = v * (1 - s) + local q = v * (1 - f * s) + local t = v * (1 - (1 - f) * s) + local no = i % 6 if no == 0 then return v,t,p elseif no == 1 then return q,v,p elseif no == 2 then return p,v,t @@ -28,11 +39,14 @@ end function my_color_scheme(z,hsvrgb) r, phi = cmath.polar(z) +-- phi is in -pi,+pi; change it to [0;2pi] + phi = phi+pi h_str,s_str,v_str = hsvrgb:match("([^,]+),([^,]+),([^,]+)") -- h = load("return "..h_str)() -- s = load("return "..s_str)() -- v = load("return "..v_str)() --h,s,v = loadstring("return"..hsvrgb) + -- R,G,B, is [0,...,1] R,G,B = HSVtoRGB(load("return "..h_str)(),load("return "..s_str)(),load("return "..v_str)()) -- h,s,v) -- (phi+3.14,1,r) return { math.fmod(math.floor(R*255+0.5),255), math.fmod(math.floor(G*255+0.5),255), @@ -57,15 +71,15 @@ function write_eps_data(name,data,res) outFile = io.open(name,"w+") -- Dateiname outFile:write([[ %!PS-Adobe-3.0 EPSF-3.0 -%%Creator: (ImageMagick) +%%Creator: (Herbert Voss) %%Title: (domain.eps) -%%CreationDate: (2024-08-21T08:45:55+00:00) -]]) +%%CreationDate: (]]) + outFile:write(os.date("%Y-%m-%d-%H.%M.%S")..")\n") outFile:write("%%BoundingBox: -0 -0 "..res[1].." "..res[2].."\n") outFile:write("%%HiResBoundingBox: 0 0 "..res[1].." "..res[2].."\n") outFile:write([[ %%DocumentData: Clean7Bit -%%LanguageLevel: 1 +%%LanguageLevel: 2 %%Pages: 1 %%EndComments %%BeginDefaults @@ -79,58 +93,7 @@ function write_eps_data(name,data,res) } bind def /DirectClassImage{ columns rows 8 [ columns 0 0 rows neg 0 rows ] - { DirectClassPacket } false 3 colorimage %} -} bind def -/GrayDirectClassPacket { - currentfile color_packet readhexstring pop pop - color_packet 0 get 0.299 mul - color_packet 1 get 0.587 mul add - color_packet 2 get 0.114 mul add - cvi - /gray_packet exch def - /number_pixels 1 def - 0 1 number_pixels 1 sub { pixels exch gray_packet put } for - pixels 0 number_pixels getinterval -} bind def -/GrayPseudoClassPacket { - currentfile byte readhexstring pop 0 get - /offset exch 3 mul def - /color_packet colormap offset 3 getinterval def - color_packet 0 get 0.299 mul - color_packet 1 get 0.587 mul add - color_packet 2 get 0.114 mul add cvi - /gray_packet exch def - /number_pixels 1 def - 0 1 number_pixels 1 sub { pixels exch gray_packet put } for - pixels 0 number_pixels getinterval -} bind def -/PseudoClassPacket{ - currentfile byte readhexstring pop 0 get - /offset exch 3 mul def - /color_packet colormap offset 3 getinterval def - /number_pixels 3 def - 0 3 number_pixels 1 sub { pixels exch color_packet putinterval } for - pixels 0 number_pixels getinterval -} bind def -/PseudoClassImage{ - currentfile buffer readline pop - token pop /class exch def pop - class 0 gt { - currentfile buffer readline pop - token pop /depth exch def pop - /grays columns 8 add depth sub depth mul 8 idiv string def - columns rows depth - [ columns 0 0 rows neg 0 rows ] - { currentfile grays readhexstring pop } image - }{ - currentfile buffer readline pop - token pop /colors exch def pop - /colors colors 3 mul def - /colormap colors string def - currentfile colormap readhexstring pop pop - columns rows 8 [ columns 0 0 rows neg 0 rows ] - { PseudoClassPacket } false 3 colorimage - } ifelse + { DirectClassPacket } false 3 colorimage } bind def /DisplayImage { gsave @@ -155,7 +118,7 @@ function write_eps_data(name,data,res) token pop /class exch def pop currentfile buffer readline pop token pop /compression exch def pop - class 0 gt { PseudoClassImage } { DirectClassImage } ifelse + DirectClassImage grestore } bind def %%EndProlog @@ -196,7 +159,7 @@ DisplayImage end end outFile:write("\n") -- neue Zeile - outFile:write([[end + outFile:write([[end % of userdict %%PageTrailer %%Trailer %%EOF @@ -206,7 +169,7 @@ DisplayImage end function write_data(name,data,res) -- only valid for writing ppm files - print("Lua: writing data file "..name.." ...") + print("\nLua: writing data file "..name.." ...") -- print(data) outFile = io.open(name,"w+") -- Dateiname outFile:write("P3 ") -- Grafictype R G B @@ -254,15 +217,16 @@ function plot(fString, domain, res, funcName, hsvrgb, bgColor, invers) fz = load("return "..fString)() -- for example: cmath.cos(z)/cmath.sin(z^4-1) end color = my_color_scheme(fz,hsvrgb) - if bgColor == "true" then - if color[1] + color[2] + color[3] == 0 then - color = { 255, 255, 255 } - end - elseif invers == "true" then + if invers == "true" then for c=1,#color do color[c] = math.abs(color[c]-255) end end + if bgColor > 0 then + if color[1] + color[2] + color[3] <= bgColor then + color = { 255, 255, 255 } + end + end -- print(x,y,color[1],color[2],color[3]) img[row][col] = color end |