TransWikia.com

Error in asymptote using upacity to draw a lemniscate

TeX - LaTeX Asked by S. Venkataraman on January 29, 2021

I am trying to draw a lemniscate using the code from this answer:
How to draw lemniscate with TikZ

However, if when I run asymptote I get the following error messages:

Error: /undefined in .setopacityalpha
Operand stack:
   0.5
Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   2045   1   3   %oparray_pop   2044   1   3   %oparray_pop   --nostringval--   2025   1   3   %oparray_pop   1884   1   3   %oparray_pop   --nostringval--   %errorexec_pop   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--
Dictionary stack:
   --dict:967/1684(ro)(G)--   --dict:0/20(G)--   --dict:82/200(L)--
Current allocation mode is local
Current file position is 31005
GPL Ghostscript 9.26: Unrecoverable error, exit code 1                                                                                                                                                                                       
/opt/texlive/2018/texmf-dist/asymptote/plain_shipout.asy: 87.10: runtime: shipout failed                                                                                                                                                     
Error: /undefined in .setopacityalpha                                                                                                                                                                                                        
Operand stack:                                                                                                                                                                                                                               
   0.2                                                                                                                                                                                                                                       
Execution stack:                                                                                                                                                                                                                             
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   2045   1   3   %oparray_pop   2044   1   3   %oparray_pop   --nostringval--   2025   1   3   %oparray_pop   1884   1   3   %oparray_pop   --nostringval--   %errorexec_pop   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--              
Dictionary stack:                                                                                                                                                                                                                            
   --dict:967/1684(ro)(G)--   --dict:0/20(G)--   --dict:82/200(L)--                                                                                                                                                                          
Current allocation mode is local                                                                                                                                                                                                             
Current file position is 38506                                                                                                                                                                                                               
GPL Ghostscript 9.26: Unrecoverable error, exit code 1                                                                                                                                                                                       
/opt/texlive/2018/texmf-dist/asymptote/plain_shipout.asy: 87.10: runtime: shipout failed        

3 Answers

Wow.

After a lot of digging I found this bug report (which isn't actually a bug) which suggests that GhostScript (which is called by Asymptote) runs into problems when opacity is used along the the -dSAFER option. This option assures that no PostScript code which could be harmful to the system is executed. Enabling this option makes the opacity fail. If you change the line fpen=lightred+opacity(0.5); to fpen=lightred;//+opacity(0.5); and pen fpen=lightgreen+opacity(0.2); to pen fpen=lightgreen;//+opacity(0.2); (commenting out the opacity) the picture is generated:

enter image description here

but it's not what you'd expect. And if you enable the opacity the problem persists because Asymptote calls GhostScript with -dSAFER by default since 2008 (from the change log):

commit 407a627a5d18b773739a9535b486b8a177dd7c49
Author: John Bowman <[email protected]>
Date:   Mon Jun 23 11:00:40 2008 -0600

    By default run gs with -dSAFER.

After more digging through code and documentation looking for opacity without success, I searched for safe and voilà:

enter image description here

there is a -nosafe option which you can (when you trust the code your are executing) pass to asy so that the opacity will work.

So you can use the same code from the answer you linked (How to draw lemniscate with TikZ) and compile the document with:

pdflatex cassini.tex
asy -nosafe cassini-*asy
pdflatex cassini.tex

and it will work :)

Answered by Phelype Oleinik on January 29, 2021

A better workaround for this ghostscript bug has already been implemented in the git source (and will be in the upcoming 2.48 Asymptote release):

https://github.com/vectorgraphics/asymptote/issues/77

Answered by John Bowman on January 29, 2021

If you run into this error while using pstricks in general, I found a solution in different question. So give the original author an upvote, if this works for you:

% GhostScript 9.53
usepackage[pspdf={-dALLOWPSTRANSPARENCY}]{pstricks-pdf}
% GhostScript < 9.53
usepackage[pspdf={-dNOSAFER}]{pstricks-pdf}

Answered by Fabian Winkler on January 29, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP