[comp.text] Shaded Boxes in PIC

benson@dcdwest.UUCP (Peter Benson) (11/10/89)

I would like to know how to shade a box or other closed form
in pic.  Since pic generates PostSvript and shded closed
figures are possible in PostScript, there is a way, albeit
with the pic equivalent of patching the machine code.  Is
there some better way?
-- 
Peter Benson                    | ITT Defense Communications Division
(619)578-3080                   | 10060 Carroll Canyon Road
ucbvax!ucsd!dcdwest!benson      | San Diego, CA 92131
dcdwest!benson@UCSD.EDU         |

henry%angel@Sun.COM (Henry McGilton -- Software Products) (11/11/89)

In article <546@dcdwest.UUCP>, benson@dcdwest.UUCP (Peter Benson) writes:
    > I would like to know how to shade a box or other closed form
    > in pic.
In principle this cannot be done.  pic  is a preprocessor
for  troff, and  troff  is not a fully fledged graphics
editor.  End of debate.

    > Since pic generates PostSvript
The version of  pic  I have here generates  troff  drawing
requests and other things.  While it's true various people
have experimented with making  pic  crank out PostScript, I
don't know of any widely available version of this.
    > and shded closed figures are possible in PostScript,
    > there is a way, albeit
    > with the pic equivalent of patching the machine code.
As far as I can tell, although the minor premise is correct, the
major premise is incorrect, and therefore the conclusion is a
non sequitur.

The  'pic  equivalent of patching the machine code' would be to
emit PostScript code from the  pic  side via  troff's  transparent
throughput machinery (the  \!  escape sequence).  However,  pic
doesn't understand this escape sequence, so that avenue is also
closed to you.
    > Is there some better way?

In closing, I'm not at all sure it's possible to do what you want
in a simple way (not requiring modifications to both  pic  and
troff).  But if anyone else knows better I'd be happy to learn
something new.

	............ Henry

+------------------+------------------------+---------------------------+
| Henry McGilton   | I saw the future,      | arpa: hmcgilton@sun.com   |
| Sun Microsystems | and it didn't work.    | uucp: ...!sun!angel!henry |
| Mt. View, CA     |                        |                           |
+------------------+------------------------+---------------------------+

sac@conrad.UUCP (Steven A. Conrad) (11/13/89)

In article <127725@sun.Eng.Sun.COM> henry%angel@Sun.COM (Henry McGilton -- Software Products) writes:
>    > I would like to know how to shade a box or other closed form
>    > in pic.
>In principle this cannot be done.  pic  is a preprocessor
...
>In closing, I'm not at all sure it's possible to do what you want
>in a simple way (not requiring modifications to both  pic  and
>troff).  But if anyone else knows better I'd be happy to learn
>something new.

I use troff, although my postprocessor generates HP's
language instead of Postscript.  My postprocessor permits
passing of transparent control sequences, one of which is to
set the shading for subsequently drawn boxes;  I handle this
with simple macros embedded in my pic statements, and it
works beautifully.

Perhaps there is a postprocessor which handles this for
Postscript?
-- 
Steven A. Conrad,  Department of Medicine (Critical Care)
Louisiana State University Medical Center, Shreveport, LA
UUCP: sac@conrad.UUCP,   Internet: conrad@manta.pha.pa.us
"I think there is a world market for about five computers" TJ Watson Jr, 1943

johnk@opel.uu.net (John Kennedy) (11/14/89)

The facts as I understand them:

1)  Pic generates input to troff, according to troff's input language.

2)  Troff generates a device-independent output.

3)  Various filters take the troff output and generate device-specific codes.
    (I have Eroff, and it has filters to convert troff output to
     HP LaserJet, Imagen Impress, and PostScript).

Therefore,

    It is possible for pic drawings to appear on a PostScript printer.

However,

    Features of PostScript, such as shading are not in the repertoire
    of what troff handles, and thus, no output of pic can instruct
    troff to generate the appropriate output.

Oh, well.

John



-- 
John Kennedy                     johnk@opel.uu.uunet
Second Source, Inc.
Annapolis, MD

skyer@quantime.co.uk (Susannah Skyer) (11/15/89)

In article <309@opel.uu.net> johnk@opel.UUCP (John Kennedy) writes:

>1)  Pic generates input to troff, according to troff's input language.
>
>2)  Troff generates a device-independent output.

>Therefore,
>
>    It is possible for pic drawings to appear on a PostScript printer.
>
>However,
>
>    Features of PostScript, such as shading are not in the repertoire
>    of what troff handles, and thus, no output of pic can instruct
>    troff to generate the appropriate output.

.
.
.
It's true that pic does not write PostScript, but this is not to say
that you can't get shaded shapes in your troff'ed document.

There should be a way in your pic/troff doc to pass instructions directly
through to the printer (i.e., the PostScript, imPress, or whatever interpreter)
I've used SoftQuad's sqtroff and they have macros that allow you to insert
and position EPS (Encapsulated PostScript) files within your troff file.

What this means is you can draw whatever you want in a PostScript program,
and then insert it into your troff. I know you can do the same thing with 
imPress (I've seen this in the Imagen manuals), but I haven't tried it.

Hope this helps.

Susannah Skyer
Technical Author
Quantime UK
skyer@qtlon.UUCP

lee@sq.sq.com (Liam R. E. Quin) (11/16/89)

>    > I would like to know how to shade a box or other closed form
>    > in pic.

Since pic emits troff instructions, you are limited by what troff can do.
Now, whilst commercial versions of troff might allow one to fill and
shade boxes, most versions do not.

But do not despair!

Pic has "for" loops, and you can use these to draw lots of dotted lines.
You will need to experiment a little with this, but here is the idea.

	.\" demonstration of shading in pic
	.\" Liam R. QUin, Unixsys (UK) Ltd., 1989



	.PS

	A:	box  # draw the border
		
		# now shade it a little

		# use small dots (3 pt)
	.ps 3
		# change the 20 and 50 to alter the shading intensity.
		for j = 0 to boxht by boxht / 20 do Y
			for i = 0 to boxwid by boxwid/50 do X
				"\&." at A.sw + (i, j)
			X
		Y
	.ps 10
		
		box "Hello!" at A
	.PE

Hope this helps.

Another approach is to define a PostScript font containing little grey
squares, but this is less general, and harder to describe!


Lee
-- 
Liam R. Quin, Unixsys (UK) Ltd [note: not an employee of "sq" - a visitor!]
lee@sq.com (Whilst visiting Canada from England)
lee@anduk.co.uk (Upon my return to England at Christmas)

rick@pcrat.uucp (Rick Richardson) (11/16/89)

In article <1989Nov15.171726.28275@sq.sq.com> lee@sq.com (Liam R. E. Quin) writes:
>>    > I would like to know how to shade a box or other closed form
>>    > in pic.

>Since pic emits troff instructions, you are limited by what troff can do.
>Now, whilst commercial versions of troff might allow one to fill and
>shade boxes, most versions do not.

Actually, troff does little with the drawing primitives that "pic"
emits.  The postprocessor does all the work.  It is possible to
produce shaded objects if your postprocessor is up to it.  Ideally,
of course, the "pic" language should be extended to make this more
convenient.  As it is, JetRoff uses the transparent pass-thru
feature to do shaded/patterned rectangles only, with the command:

	\X'shade percent xpos ypox width height'

I've toyed with the idea of providing arbitrary fills of an
enclosed area, such as what typical "paint" programs do, with
a pass-thru like:

	\X'shadefill percent xpos ypox'

Assuming that 'xpos, ypos' was a coordinate within an area
enclosed by one or more lines, circles, elipses, arcs, or
splines, this pass-thru would flood fill up to the boundaries
of the area.

We start to get into an area of functionality, though, where
a screen oriented drawing program would be better use of time
than the pic language.  Its output could be either postscript,
or for portability, a richer set of troff compatible *standard*
primitives (either pass-thrus or builtins).

I believe that I mentioned this (a richer set of drawing primitives)
to Brian Kernighan as a wish list item for his next version of troff.

-- 
Rick Richardson | JetRoff "di"-troff to LaserJet Postprocessor| Ask about
PC Research,Inc.| Mail: uunet!pcrat!jetroff; For anon uucp do:|   FaxiX
uunet!pcrat!rick| uucp jetroff!~jetuucp/file_list ~nuucp/.    | for UNIX/386
jetroff Wk2200-0300,Sa,Su ACU {2400,PEP} 12013898963 "" \d\r\d ogin: jetuucp

murray@sq.sq.com (Murray Maloney) (11/17/89)

In article <309@opel.uu.net> johnk@opel.UUCP (John Kennedy) writes:
>The facts as I understand them:
>1)  Pic generates input to troff, according to troff's input language.
>2)  Troff generates a device-independent output.
>3)  Various filters take the troff output and generate device-specific codes.
>Therefore,
>    It is possible for pic drawings to appear on a PostScript printer.
>However,
>    Features of PostScript, such as shading are not in the repertoire
>    of what troff handles, and thus, no output of pic can instruct
>    troff to generate the appropriate output.
>-- 
>John Kennedy                     johnk@opel.uu.uunet
>Second Source, Inc.
>Annapolis, MD

Features such as pattern-filling of closed objects (boxes, circles, ellipses)
and grey-scaling are in the repertoire of sqtroff.  So, there is a way
for pic (or sqpic) to generate the appropriate output.  Fill patterns
are enabled and selected with \D'f N' -- where `N' represents a standard
pattern on the imaging device (0=no pattern, 1=solid, ...).  The level of 
grey scale is specified with \D'w N' -- where `N' ranges from 0 (black) 
to 1 (white).  Using these in combination boxes can be shaded most any way
that you would like.

********************************************************************************
Murray C. Maloney		uucp:		{utai|utzoo|uunet}!sq!murray
Documentation Specialist	Internet:	murray@sq.com
SoftQuad Inc.			Phone:		(416) 963-8337

rick@pcrat.uucp (Rick Richardson) (11/17/89)

In article <117@qtlon.quantime.co.uk> skyer@qtlon.UUCP (Susannah Skyer) writes:

>It's true that pic does not write PostScript, but this is not to say
>that you can't get shaded shapes in your troff'ed document.

>There should be a way in your pic/troff doc to pass instructions directly
>through to the printer (i.e., the PostScript, imPress, or whatever interpreter)

What we really need to do though, to improve the portability
of troff documents, is to come up with an extended, upwardly
compatible set of standard troff input and output primitives
that will cover many of these cases without having to resort
to inclusion of printer specific commands within a document.
I mean, it does seem silly to me to resort to using embedded
printer commands because you want to have a shaded box in a
pic diagram.  I really would like to think that we could agree
on a common set of troff input and output *additions* to the
current languages.

-Rick

-- 
Rick Richardson |       Looking for FAX software for UNIX/386 ??????     mention
PC Research,Inc.|                  WE'RE SHIPPING			 your
uunet!pcrat!rick|    Ask about FaxiX - UNIX Facsimile System (tm)        FAX #
(201) 389-8963  | Or JetRoff - troff postprocessor for the HP {Laser,Desk}Jet

rauletta@gmuvax2.gmu.edu (Richard J. Auletta) (11/18/89)

In article <1989Nov16.144956.9559@pcrat.uucp> rick@pcrat.UUCP (Rick Richardson) writes:
>In article <1989Nov15.171726.28275@sq.sq.com> lee@sq.com (Liam R. E. Quin) writes:
>>>    > I would like to know how to shade a box or other closed form
>>>    > in pic.

I would suggest using a full-feature graphics editor that supports
postscript and then incorporating the postscript into the your
troff. Of course this assumes access to a postscript printer, but
if you had a graphics editor that will generate HP Laser Jet
files the same procedure might be workable.

I use pic, xfig, idraw (a macdraw for X11) and postscript to
create the figures I need. I find none of these do everything
I want in one package. An example is subscripts. In pic and
xfig I can include equations, in idraw this seems impossible.
In idraw I can rotate text through an arbitrary angle, even
mirror-imaged, not likely any time soon in pic/troff.
For seals with circular text I write the postscript directly and
for electric circuits I have a set of pic macros that 
do schematics....I suppose what I'm saying is use the right
tool for the job!

--R J Auletta