Conversation started Feb 14, 2023 at 22:26.
Feb 14, 2023 22:26
@yo' eps not really designed for preview (unless it has a tiff header for that purpose) it can take an arbitrary amount of time eg
%!PS-Adobe-3.0 EPSF-3.0
/fun {4 3 roll dup dup mul 5 4 roll dup dup mul 2 index exch sub 6 1 roll 2 index
2 mul mul 6 1 roll pop pop 4 1 roll dup 5 1 roll add 4 1 roll 1 index add 4 3 roll exch 4 2 roll} def
/res 700 def /iter 500 def 300 300 translate 90 rotate -150 -260 translate
0 1 res {/x exch def 0 1 res {/y exch def 0 0 -2.5 4 x mul res div add 2 4 y mul res div sub
iter -1 0 {/n exch store fun 2 index dup mul 4 index dup mul add sqrt 4 gt {exit} if} for
pop pop pop pop n 0 gt {1 setgray x y 0.7 0 360 arc fill} {0 setgray x y 0.5 0 360 arc fill} ifelse} for}for
 
10 hours later…
yo'
yo'
Feb 15, 2023 08:48
@DavidCarlisle well, the question is, can you convert it to PDF on the fly on the client side? If so, we could ship the convertor, let the user convert, and then display the PDF using pdfjs (which is what we plan to use for PDF preview). However, that means compiling ghostscript to WebAssembly, which is probably not really possible. We'll still try to try :)
yo'
yo'
Feb 15, 2023 09:06
Seems there's an NPM package :) npmjs.com/package/@jspawn/ghostscript-wasm
Feb 15, 2023 09:33
@barbarabeeton I'm too young, heard of TOPS-20 for the first time :)
@yo' you can, but it can take an arbitrarily long time (which basically is why PDF got produced, pre-digested PostScript.) I suppose if it is protected by the same kind of timeout you apply to the tex run it might be OK
yo'
yo'
@DavidCarlisle got it -- thanks! We'd probably (1) do it "lazily" (so not blocking anything) and (2) time it out (it would be running client-side where we don't have any real protections for cases like this...
@barbarabeeton why do we allow children on this site?
3
@DavidCarlisle :)
@yo' It would be dangrous just to fire up a preview of eps clientside without some javascript timeout, rendering postscript can use an arbitrary amount of time and memory. Add one more 0 to the iteration limit in the mandelbrot example above and it will make ghostscript spin for an hour
2
yo'
yo'
Feb 15, 2023 09:43
@DavidCarlisle yeah sure! Thanks again :)
@yo' @Skillmon is probably too young to have been reprimanded for locking up the department's only laser printer with some non terminating PostScript experiments:-)
yo'
yo'
@DavidCarlisle :-D
@AlanMunn note that the low level clist-splitting code I posted yesterday has its limitations: It'll not do the right thing on input like 1, 1, (spaces after or before commas), if that's an issue remove the {} around the parameters in the \clist_set:Nn (but that might result in brace loss and not do the right thing for input like 1,{1,2},). So to get something robust, use some \clist_pop:NN in a loop, or something similar with highlevel clist-functions.
yo'
yo'
@DavidCarlisle which number is the number of iterations?
@yo' /iter 500 def
yo'
yo'
Feb 15, 2023 09:55
ok thanks :) I wasn't sure as I know PS is postfix, but there are cases where it's different...
@yo' actually I stole that from some gist let me find it again to give credit.... gist.github.com/rberenguel/9a5239034cafdeaabdf6654446521254
yo'
yo'
thanks
@yo' officially that's not E PS as it has no bounding box comment and it has an unguarded showpage, but both would be easily fixed.
yo'
yo'
@DavidCarlisle good point :)
 
Conversation ended Feb 15, 2023 at 10:03.