groff
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Groff] Depict symmetric difference in PIC


From: Tadziu Hoffmann
Subject: Re: [Groff] Depict symmetric difference in PIC
Date: Tue, 11 Oct 2016 00:45:04 +0200
User-agent: Mutt/1.5.21 (2010-09-15)

> I would like to know if anyone can help me depict symmetric
> difference of sets in PIC.

I believe it can't be done with pic alone, at least not with
filled shapes, because

 (a)  pic can only fill "atomic" shapes (boxes, circles, and
      ellipses), but not composite objects and arcs, and for
      the crescent we have a boundary composed of two arcs,
 (b)  pic has no concept of "clipping", to prevent drawing
      over existing stuff to fill only part of a shape.

But if you're willing to accept device-level hacking, then
here's a specially tuned solution that fiddles with grops's
utility routines to achieve the desired effect.  Obviously,
it works only with groff, and only with the postscript device.

  .\" pic
  .\" ----------------------------------------------------------------
  .PS
  "\X'ps: exec grops begin /DA { newpath arcn gsave } def end'"
  arc at -.5,0 from 0,1 to 0,-1 colored "lightgray"
  "\X'ps: exec grops begin /DA { grestore arc fill } def end'"
  arc at  .5,0 from 0,-1 to 0,1
  "\X'ps: exec grops begin /DA { newpath arcn gsave } def end'"
  arc at  .5,0 from 0,-1 to 0,1
  "\X'ps: exec grops begin /DA { grestore arc fill } def end'"
  arc at -.5,0 from 0,1 to 0,-1
  "\X'ps: exec grops begin /DA { newpath arcn stroke } def end'"
  circle at -.5,0 radius sqrt(1.25) outline "black"
  circle at  .5,0 radius sqrt(1.25)
  .PE

(The gsave/grestore is used to get rid of the moveto that grops
inserts as part of the \X escape.)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]