zauguin / luapstricks

8 stars 0 forks source link

Extension of support for `pst-grad` package #17

Closed pablgonz closed 3 years ago

pablgonz commented 3 years ago

Hello, at the moment the pst-grad package is supported only with the exception of the GradientHSB key. Example file:

% arara: latex
% arara: dvips
% arara: ps2pdf: { options : [ -dALLOWPSTRANSPARENCY -dPDFSETTINGS=/prepress ] }
% arara: clean: { extensions : [ aux, log, dvi, ps ] }
\RequirePackage{pdfmanagement-testphase}
\DeclareDocumentMetadata{}
\documentclass{article}
\usepackage{pstricks}
\usepackage{pst-grad}
\pagestyle{empty}
\setlength{\parindent}{0pt}
\addtolength{\hoffset}{-1.5cm}
% short
\newcommand{\BSS}[1]{\textbf{\textbackslash{#1}}}
\newcommand{\AC}[1]{\{#1\}}
\newcommand{\BS}[1]{$\backslash$#1}
\begin{document}
% Adapted form visualpstricks
\section{Package \texttt{pst-grad}}

\begin{center}
\begin{tabular}{|c|c|c|c|}
\hline
\multicolumn{4}{|c|}{\BS{}psframe[fillstyle=\textcolor{red}{gradient}](0.5,.5)(2.5,2.5)} \\
\hline
\begin{pspicture}(3,3)
  \psframe[fillstyle=gradient](0.5,.5)(2.5,2.5)
\end{pspicture}
&
\begin{pspicture}(3,3)
  \psframe[fillstyle=gradient,gradbegin=green](0.5,.5)(2.5,2.5)
\end{pspicture}
&
\begin{pspicture}(3,3)
  \psframe[fillstyle=gradient,gradend=green](0.5,.5)(2.5,2.5)
\end{pspicture}
&
\begin{pspicture}(3,3)
  \psframe[fillstyle=gradient,gradbegin=red,gradend=green](0.5,.5)(2.5,2.5)
\end{pspicture} \\
\hline
{\color{blue} By default} & \textcolor{red}{gradbegin}=green & \textcolor{red}{gradend}=green & {\red gradbegin}=red \\
& & & {\red gradend}=green \\
\hline
\hline

\begin{pspicture}(3,3)
  \psframe[fillstyle=gradient,gradlines=5](0.5,.5)(2.5,2.5)
\end{pspicture}
&
\begin{pspicture}(3,3)
  \psframe[fillstyle=gradient,gradmidpoint=0.7](0.5,.5)(2.5,2.5)
\end{pspicture}
&
\begin{pspicture}(3,3)
  \psframe[fillstyle=gradient,gradangle=45](0.5,.5)(2.5,2.5)
\end{pspicture}
&
\begin{pspicture}(3,3)
\psframe[fillstyle=gradient,gradangle=90](0.5,.5)(2.5,2.5)
\end{pspicture} \\
\hline
\textcolor{red}{gradlines}=5 & \textcolor{red}{gradmidpoint}=0.7 & \textcolor{red}{gradangle}=45 & \textcolor{red}{gradangle}=90 \\
\hline
{\color{blue} By default: 500} & {\color{blue} By default: 0.9} &  \multicolumn{2}{c|}{\color{blue} By default: 0} \\
\hline
\end{tabular}
\end{center}

\begin{center}
\begin{tabular}{|c|c|c|c|}
\hline
\multicolumn{4}{|c|}{\BS{}psframe[fillstyle=gradient,\textcolor{red}{GradientCircle}=true](0.5,.5)(2.5,2.5)} \\
\hline
\begin{pspicture}(3,3)
  \psframe[fillstyle=gradient,GradientCircle=true](0.5,.5)(2.5,2.5)
\end{pspicture}
&
\begin{pspicture}(3,3)
  \psframe[fillstyle=gradient,GradientCircle=true,GradientScale=.5](0.5,.5)(2.5,2.5)
\end{pspicture}
&
\begin{pspicture}(3,3)
  \psframe[fillstyle=gradient,GradientCircle=true,GradientScale=2](0.5,.5)(2.5,2.5)
\end{pspicture}
&
\begin{pspicture}(3,3)
  \psframe[fillstyle=gradient,GradientCircle=true,GradientPos={(1,1)}](0.5,.5)(2.5,2.5)
\end{pspicture} \\
\hline
& \textcolor{red}{GradientScale}=.5 & \textcolor{red}{GradientScale}=2 & \textcolor{red}{GradientPos}=\AC{(1,1)} \\
\hline
\end{tabular}
\end{center}

\subsection{\texttt{GradientHSB}}
% from doc
\newcommand{\Fig}[1][]{%
\begin{pspicture}(5.5,5.5)
  \psframe[#1](5,5)
\end{pspicture}}
\definecolor{ColorA}{hsb}{0.7, 0.1, 0.8}
\definecolor{ColorB}{hsb}{0.7, 0.9, 0.8}
\definecolor{ColorC}{hsb}{0, 0, 0}
\definecolor{ColorD}{hsb}{0, 0, 1}
\definecolor{ColorE}{hsb}{0, 0, 0.5}
\definecolor{ColorF}{hsb}{0, 1, 0.5}
\definecolor{ColorG}{hsb}{0, 0, 0.5}
\definecolor{ColorH}{hsb}{0.99999, 0, 0.5}  % As it's cycliç 1=0 !
\definecolor{ColorI}{hsb}{1, 1, 1}
\definecolor{ColorJ}{hsb}{1, 0, 0}
\definecolor{ColorK}{hsb}{0.99999, 1, 1}    % As it's cyclic 1=0 !
\definecolor{ColorL}{hsb}{0, 1, 0}
\definecolor{ColorM}{hsb}{0.99999, 1, 1}    % As it's cyclic 1=0 !
\definecolor{ColorN}{hsb}{0, 0, 1}
\definecolor{ColorO}{hsb}{0, 0.6, 0.7}
\definecolor{ColorP}{hsb}{0.99999, 0.7, 0.7}% As it's cyclic 1=0 !
\definecolor{ColorQ}{hsb}{0.3, 0, 0.8}
\definecolor{ColorR}{hsb}{0.3, 1, 0.8}
\definecolor{ColorS}{hsb}{0.6, 0.3, 0}
\definecolor{ColorT}{hsb}{0.6, 0.3, 1}
\psset{fillstyle=gradient,gradmidpoint=1}
\Fig[gradbegin=yellow,gradend=green]
\Fig[gradientHSB=true,gradbegin=ColorA,gradend=ColorB]

\Fig[gradbegin=green,gradend=yellow]
\psset{gradientHSB=true}
\Fig[gradbegin=ColorC,gradend=ColorD]

\Fig[gradbegin=ColorE,gradend=ColorF]
\Fig[gradbegin=ColorG,gradend=ColorH]

\Fig[gradbegin=ColorI,gradend=ColorJ]
\Fig[gradbegin=ColorK,gradend=ColorL]

\Fig[gradbegin=ColorM,gradend=ColorN]
\Fig[gradbegin=ColorO,gradend=ColorP]

\Fig[gradbegin=ColorQ,gradend=ColorR]
\Fig[gradbegin=ColorS,gradend=ColorT]

\end{document}
[2./luapstricks.lua:462: Unknown name "currenthsbcolor"
stack traceback:
    [C]: in function 'error'
    ./luapstricks.lua:462: in upvalue 'lookup'
    ./luapstricks.lua:2636: in upvalue 'execute_tok'
    ./luapstricks.lua:2666: in upvalue 'execute_ps'
    ./luapstricks.lua:2727: in function <./luapstricks.lua:2724>
    [C]: in function 'vf.node'
    ./luapstricks.lua:2717: in function <./luapstricks.lua:2708>.
<argument> ...not:N \tex_shipout:D \box_use:N \l_shipout_box 
                                                  \__shipout_drop_firstpage_...

Expected output:

test-pst-grad-crop-1 test-pst-grad-crop-2 test-pst-grad-crop-3

zauguin commented 3 years ago

I fixed HSB, but gradangle is still broken in an odd way: gradangle itself works, but it has been used at least once all further gradients produce incorrect output.

pablgonz commented 3 years ago

I fixed HSB, but gradangle is still broken in an odd way: gradangle itself works,

Great :D, now it works

but it has been used at least once all further gradients produce incorrect output.

Not cool, is this a pst-grad problem?

zauguin commented 3 years ago

Should be fixed now.