[comp.lang.postscript] Stroking thick lines about arcs

jtc@motcad.portal.com (J.T. Conklin) (02/21/91)

I have been observing that stroking an arc with a ``thick'' line results
in some areas of white peeking through the line --- especially about the
outside perimeter --- on two independant PostScript implementation.

From what I understand, the stroke operator follows the path and sets
the pixels within linewith/2 along the perpendicular.  It seems to me
that the interpreters in question do not move along the path in small
enough increments, so some pixels are never considered to be on the 
perpendicular and are not set.

Is this behavior acceptable?  I can't find any documentation on anything
like a stroke step parameter.  Should the step size automagically get
smaller when stroking an arc of sufficient curvature?

I first ran into this problem with the ``GNU T-Shirt Design'', and 
have have created the following test case out of it:

	/inch { 72 mul } def
	/radius 3.5 inch def
	/points 27 def

	4.25 inch 5.5 inch translate
	points 1.5 mul setlinewidth

	newpath
	0 0 radius points 3 div add 0 360 arc
	stroke

	showpage

I would be interested to know if this prints without white specks in the
circle on a real Adobe Interpreter.

	--jtc

-- 
J.T. Conklin    jtc@motcad.portal.com, ...!portal!motcad!jtc

jlp@cbnewsh.att.com (jon.peticolas) (02/22/91)

From article <1991Feb20.161757.24206@motcad.portal.com>, by jtc@motcad.portal.com (J.T. Conklin):
> I have been observing that stroking an arc with a ``thick'' line results
> in some areas of white peeking through the line --- especially about the
> outside perimeter --- on two independant PostScript implementation.

   (stuff deleted)

> 	/inch { 72 mul } def
> 	/radius 3.5 inch def
> 	/points 27 def
 
> 	4.25 inch 5.5 inch translate
> 	points 1.5 mul setlinewidth
 
> 	newpath
> 	0 0 radius points 3 div add 0 360 arc

	closepath % Works for me

> 	stroke
 
> 	showpage


The closepath operator tells postscript that the ends of the path are
to be joined with a mitered connection. If they are not actually the
same point, the path will be completed with a straight line. This detail
is covered in chapter 3 of the Adobe blue book (in my admittedly outdated 
copy anyway).  Additional line joining details are covered in chapter 10.

-Jon

jansteen@cwi.nl (Jan van der Steen) (02/22/91)

jtc@motcad.portal.com (J.T. Conklin) writes:

>I have been observing that stroking an arc with a ``thick'' line results
>in some areas of white peeking through the line --- especially about the
>outside perimeter --- on two independant PostScript implementation.

[text deleted...]

>Is this behavior acceptable?  I can't find any documentation on anything
>like a stroke step parameter.  Should the step size automagically get
>smaller when stroking an arc of sufficient curvature?

[program deleted...]

>I would be interested to know if this prints without white specks in the
>circle on a real Adobe Interpreter.

I tested on:

	1. Data Products LZR 2665 (39.0)
	2. Agfa P3400PS (48.1)
	3. Oce 6750 PS

All three gave a closed arc with no white specks anywhere.
The Data Products and Agfa have an official Adobe board,
the Oce uses a PostScript clone.

The GhostScript interpreter *did* give the effect you described.
I could solve this by adding a "closepath" after the "arc" call:

	[...]
	newpath
	0 0 radius points 3 div add 0 360 arc
	closepath					% <<<<<<<<
	[...]

And maybe you will also need to set the linejoin parameter:

	[...]
	1 setlinejoin					% <<<<<<<<
	newpath
	0 0 radius points 3 div add 0 360 arc
	closepath
	[...]


Jan van der Steen
-- 
    -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
     Jan van der Steen                 jansteen@cwi.nl
     Centre for Mathematics and Computer Science (CWI)
     Kruislaan 413, 1098 SJ Amsterdam, The Netherlands
--
    -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
     Jan van der Steen                 jansteen@cwi.nl
     Centre for Mathematics and Computer Science (CWI)
     Kruislaan 413, 1098 SJ Amsterdam, The Netherlands

jtc@motcad.portal.com (J.T. Conklin) (02/23/91)

In article <1991Feb21.225435.15664@cbnewsh.att.com> jlp@cbnewsh.att.com (jon.peticolas) writes:
>From article <1991Feb20.161757.24206@motcad.portal.com>, by jtc@motcad.portal.com (J.T. Conklin):
>> I have been observing that stroking an arc with a ``thick'' line results
>> in some areas of white peeking through the line --- especially about the
>> outside perimeter --- on two independant PostScript implementation.
>
>The closepath operator tells postscript that the ends of the path are
>to be joined with a mitered connection. If they are not actually the
>same point, the path will be completed with a straight line. This detail
>is covered in chapter 3 of the Adobe blue book (in my admittedly outdated 
>copy anyway).  Additional line joining details are covered in chapter 10.

Thanks for the hints about closepath, as it solved a different problem with
the example that occurs with Ghostscript --- A little sliver of  white is
not filled at the point where the two ends of the arc should joins. 

The original problem, was that little slivers of white were peeking
through spaced evenly about the perimeter of the circle.  The vendor
of the interpreter in question has admitted the problem and I hope
they will be able to send me a fix soon.

But Jon's point about closepath brings up another newbie type question:
Does a 360 degree close itself automagically, or is an explicit closepath
necessary?

Thanks,

-- 
J.T. Conklin    jtc@motcad.portal.com, ...!portal!motcad!jtc

aki@akix.uucp (Aki Atoji) (02/24/91)

jtc@motcad.portal.com (J.T. Conklin) writes:

>I have been observing that stroking an arc with a ``thick'' line results
>in some areas of white peeking through the line --- especially about the
>outside perimeter --- on two independant PostScript implementation.

Which two PostScript were these?

[.. stuff deleted..]

>I would be interested to know if this prints without white specks in the
>circle on a real Adobe Interpreter.

I handed this info off to PS people here at Talaris to see if we get
the same results on Talaris printers with PostScript emulatioin.  The
resulting page had no white specks.  I'd be interested to know what
the outcome on true Adobe would be as well.

On the related topic of compatibility, if Adobe does white specks on
thick arcs or any other peculiarities not in the blue/red/black book,
what should be the correct implementation for non-Adobe people who
writes PostScript implementation?  How should 100% adobe compatibility
defined anyways?  100% conformance to the book?  Or 100% emulation of
Adobe postscript itself if they differ?

>	--jtc

>-- 
>J.T. Conklin    jtc@motcad.portal.com, ...!portal!motcad!jtc

---------------------------------------------------------------------------
Aki Atoji                                    {ncr-sd,ucsd}!serene!akix!aki
aki@akix.uucp             {nosc,ucsd,hplabs!hp-sdd}!crash!telesys!akix!aki
---------------------------------------------------------------------------
My employer doesn't know I speak.  Therefore I don't speak for my employer.
---------------------------------------------------------------------------

jaa@cs.su.oz (James Ashton) (02/25/91)

In article <1991Feb22.171314.5128@motcad.portal.com> jtc@motcad.portal.com (J.T. Conklin) writes:
>In article <1991Feb21.225435.15664@cbnewsh.att.com> jlp@cbnewsh.att.com (jon.peticolas) writes:
>>From article <1991Feb20.161757.24206@motcad.portal.com>, by jtc@motcad.portal.com (J.T. Conklin):
>>> I have been observing that stroking an arc with a ``thick'' line results
>>> in some areas of white peeking through the line --- especially about the
>>> outside perimeter --- on two independant PostScript implementation.
>>
>>The closepath operator tells postscript that the ends of the path are
>>to be joined with a mitered connection. If they are not actually the
>>same point, the path will be completed with a straight line. This detail
>>is covered in chapter 3 of the Adobe blue book (in my admittedly outdated 
>>copy anyway).  Additional line joining details are covered in chapter 10.
>
>Thanks for the hints about closepath, as it solved a different problem with
>the example that occurs with Ghostscript --- A little sliver of  white is
>not filled at the point where the two ends of the arc should joins. 
>
>The original problem, was that little slivers of white were peeking
>through spaced evenly about the perimeter of the circle.  The vendor
>of the interpreter in question has admitted the problem and I hope
>they will be able to send me a fix soon.
>

You might like to try using setflat to fix this problem.  Setflat
controls how many straight line segments are used to approximate
the bezier curves used in PostScript.  In the case of the arc
operator, bezier curves are generated to approximate real circles
since PostScript doesn't have real circles.  The argument to setflat
controls the maximum error between the bezier and it's approximating
line segment as measured in device pixels.  Se if a 

	currentflat 5 div setflat

fixes your problem.  Even the adobe interpreters can be pushed too
far and exhibit similar problems.  Try the code below for an example
of this.

	currentflat 5 mul setflat
	144 setlinewidth
	300 300 18 0 180 arc
	stroke
	showpage

Of course decreasing the currentflat has performance implications
so be sure to put it back the way you found it after you've finished
with the critical part or your printer will take a performance hit.

						James Ashton.