Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

"Survey says..." -- Richard Dawson, weenie, on "Family Feud"


devel / comp.lang.postscript / Re: PostScript to SVG

SubjectAuthor
* Re: PostScript to SVGluser droog
`- Re: PostScript to SVGjdaw1

1
Re: PostScript to SVG

<90545dd2-e59d-471e-a5fe-f8168262247en@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=66&group=comp.lang.postscript#66

  copy link   Newsgroups: comp.lang.postscript
X-Received: by 2002:ae9:f70e:: with SMTP id s14mr12830842qkg.38.1630118837783;
Fri, 27 Aug 2021 19:47:17 -0700 (PDT)
X-Received: by 2002:a05:6830:314b:: with SMTP id c11mr10773045ots.169.1630118837477;
Fri, 27 Aug 2021 19:47:17 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.postscript
Date: Fri, 27 Aug 2021 19:47:17 -0700 (PDT)
In-Reply-To: <619da3fe-6e25-44fd-8e10-89fc063ff530o@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=24.207.183.245; posting-account=G1KGwgkAAAAyw4z0LxHH0fja6wAbo7Cz
NNTP-Posting-Host: 24.207.183.245
References: <80bb8877-f7f9-4c4e-b3ea-c454dab4aa40o@googlegroups.com> <619da3fe-6e25-44fd-8e10-89fc063ff530o@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <90545dd2-e59d-471e-a5fe-f8168262247en@googlegroups.com>
Subject: Re: PostScript to SVG
From: luser.droog@gmail.com (luser droog)
Injection-Date: Sat, 28 Aug 2021 02:47:17 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
 by: luser droog - Sat, 28 Aug 2021 02:47 UTC

On Wednesday, July 29, 2020 at 2:22:19 AM UTC-5, luser droog wrote:
> On Saturday, July 4, 2020 at 7:53:21 AM UTC-5, jdaw1 wrote:
> > Wanted: some very tight SVG, brutally short and efficient, from PostScript. It can be done by Distilling to PDF, and then using the likes of www.cloudconvert.com/pdf-to-svg to change that to SVG.
> >
> > It’s not bad. But it could be much tighter. E.g., via PDF changes arcs to Bézier, and so the SVG isn’t as tight as it could be. Going direct from PS also does this, so it might be internally transforming via PDF.
> >
> > The natural way to proceed is to go back to native PostScript. Perhaps as follows:
> >
> > • SvgCommandsDict begin
> > Necessary. Obviously an ‘end’ later ends.
> >
> > • width height SvgSetViewBox
> > Sets bounding box.
> >
> > • matrix SvgSetMatrix
> > All SVG commands will be output in this space. If currentmatrix element-wise-equals this, no transformations will be done. If not, points will be reverse transformed back to this.
> >
> > • filename SvgFinish
> > Output accumulated SVG to named file.
> >
> > SvgCommandsDict needs redefinitions of moveto, lineto, rlineto, curveto, rcurveto, closepath, arc, arcn, arct, arcto, clip, clipsave, cliprestore, gsave, grestore, fill, stroke, setlinewidth, setlinejoin, setlinecap, setdash, stroke, setrgbcolor, setgray, and maybe others. What these do is: their usual; store state data to a data object; sometimes grow an SVG text string.
> >
> > Text is harder: are fonts set with the PS, or inherited from the CSS? But my diagrams have no text, so that isn’t needed here.
> >
> > Have readers ever implemented SVG in raw PostScript? Have you working code, or advice?
> I posted an early draft of a pdf writer in PostScript that could probably
> be modified to produce SVG. Not needing a xref table means a lot of the
> code could disappear in the rewrite.
>
> Capturing arcs as arcs is trickier tho. Yeah you can capture the call,
> but then you'd have to take over a lot more operators and manage the
> path. Not impossible -- You could store it easily enough. If a path is
> an array of subpaths, a subpath is an array of elements, and an element
> is a 2-element array (moveto or lineto) or a 6-element array (curveto)
> then you could use a 5-element array for an arc. So arcs might be
> "the other 90%" of the work.
>
> https://stackoverflow.com/q/48535765/733077

I think I put in all the caveats but forgot all the features. If anyone's still
interested,...

My pdf writer converts PostScript drawings to PDF by capturing calls
to stroke and fill. Inside the override functions for these operators,
it does a pathforall to get the path data and then dumps all the
points and calls to graphics operators in PDF's shorthand format.

It certainly has the "problem" with arcs that the output only contains
"curves". But, but, but, isn't that really ... "good" enough? They look
and quack the same, don't they?

The interfacing or overriding of the operators I think is pretty clever.
But the idea is all right there in the code on SO. If anybody has questions
about it, I'd love to boast further.

Re: PostScript to SVG

<caf930fc-121f-4bd2-96f3-d335f398a29bn@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=79&group=comp.lang.postscript#79

  copy link   Newsgroups: comp.lang.postscript
X-Received: by 2002:a37:9cd:: with SMTP id 196mr5322029qkj.22.1633891595143; Sun, 10 Oct 2021 11:46:35 -0700 (PDT)
X-Received: by 2002:a9d:1b4d:: with SMTP id l71mr17604886otl.188.1633891594854; Sun, 10 Oct 2021 11:46:34 -0700 (PDT)
Path: i2pn2.org!i2pn.org!news.niel.me!aioe.org!news.uzoreto.com!tr3.eu1.usenetexpress.com!feeder.usenetexpress.com!tr2.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.postscript
Date: Sun, 10 Oct 2021 11:46:34 -0700 (PDT)
In-Reply-To: <90545dd2-e59d-471e-a5fe-f8168262247en@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=95.148.32.220; posting-account=Cp97SgoAAAC0t1Gya5PaPqyoafMoOtAn
NNTP-Posting-Host: 95.148.32.220
References: <80bb8877-f7f9-4c4e-b3ea-c454dab4aa40o@googlegroups.com> <619da3fe-6e25-44fd-8e10-89fc063ff530o@googlegroups.com> <90545dd2-e59d-471e-a5fe-f8168262247en@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <caf930fc-121f-4bd2-96f3-d335f398a29bn@googlegroups.com>
Subject: Re: PostScript to SVG
From: jdawiseman@gmail.com (jdaw1)
Injection-Date: Sun, 10 Oct 2021 18:46:35 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 4
 by: jdaw1 - Sun, 10 Oct 2021 18:46 UTC

I’m not sure to what extent there is an answer. Given PS, can I generate something like idiomatic concise SVG?

Indeed, since asking this I’ve also acquired a need for the opposite: from SVG to concise idiomatic PostScript.

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor