[Top][All Lists]

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

[Groff] Perspective in Pic

From: Ted Harding
Subject: [Groff] Perspective in Pic
Date: Tue, 17 Oct 2006 00:48:05 +0100 (BST)

Hi Folks,

A little project I just completed prompts me to
raise a question which may be worth discussing.

Tha background is that I've been making an
indexed catalogue of some 200+ papers (journal
articles and similar documents) for a friend of
mine. These were passed to me in a cardboard box.

Using groff, of course ...

To round it off, I set about making a suitable
title page, done in pic.

Here is the pic code in a groff wrapper -- run it
and you'll see what I'm leading up to. Put it in
file "", say. (There's some redundancy
in the code, because of how I built it up, but
I haven't yet got round to eliminating that.)

.sp 10
.ds Contents \
.PS 4i
l1=2.5 ; c1=cos(t1) ; s1=sin(t1)
l2=1.4 ; c2=cos(t2) ; s2=sin(t2)
"\D't 1p'" at (0,0)
## A B C D A :
line from (0,0) \
  to (l1*c1,l1*s1) \
  to (l1*c1,l1*s1*sh2)+(l2*c2,l2*s2*sh2) \
  to (l1*c1,l1*s1)+(l2*c2,l2*s2)-(l1*c1,l1*s1) \
  to (0,0)
## A A'
line from (0,0) to (0,-l3)
## D D' A' B' B :
line from (l1*c1,l1*s1)+(l2*c2,l2*s2)-(l1*c1,l1*s1) \
  to (l1*c1,l1*s1)+(l2*c2,l2*s2)-(l1*c1*sh4,l1*s1*sh4)-(0,l3*sh1) \
  to (0,-l3) \
  to (l1*c1*sh3,l1*s1*sh3)-(0,l3*sh2) \
  to (l1*c1,l1*s1)
## B C :
line from (l1*c1,l1*s1) \
  to (l1*c1,l1*s1*sh2)+(l2*c2,l2*s2*sh2)
## A' A :
line from (l1*c1,l1*s1)+(l2*c2,l2*s2)-(l1*c1,l1*s1) \
  to (0,0)
line invis from \
  -0.05 between last line .c and last line .end to 2nd last line .c \
  "\*[Contents]" aligned
## A A' :
line from (0,0) to (0,-l3)
## D D'
line from (l1*c1,l1*s1)+(l2*c2,l2*s2)-(l1*c1,l1*s1) \
  to (l1*c1,l1*s1)+(l2*c2,l2*s2)-(l1*c1*sh4,l1*s1*sh4)-(0,l3*sh1)
line invis from last line .c to 2nd last line .c \
  " " "\f[HB]\s[24]\H'30'\S'-38'\h'5p'\0of\S'0'\H'0'\s0\fP" aligned
## A A' :
line from (0,0) to (0,-l3)
## B B'
line from (l1*c1,l1*s1) to (l1*c1*sh3,l1*s1*sh3)-(0,l3*sh2)
line invis from 2nd last line .c to last line .c \
  " " "\f[HB]\s[24]\H'30'\S'19'the \S'20'box\S'0'\H'0'\s0\fP" aligned

(If you keep the ".LP" you'll need ms macros).

The command for the above is

  groff -p -ms >

Now you'll see that it gives a perspective picture of
a box with "Contents" on the top, "of" on the left-hand
side, and "the box" on the facing side. The sides of the
box are drawn to give an impression of perspective, and
*also* the texts have been transformed (with "\S" and "\H"
and font size changes) to also (nearly) match the perspective.

This was done by tweaking various numbers in ".ds Contents"
and in the variables t1, t2, sh1, sh2, sh3, sh4, l1, l2, l3
in pic, until it looked right (and I think it does look
about right).

But it has occurred to me that it would have been much
easier if it were possible to

a) First construct an object as if you were looking
   at it at right angles. E.g. for the top face of
   the box,

   box wid l1 ht l2 with .sw at (0,0)
   line invis from last box .w to last box .e \
     "\f[HB]\s[24]Contents\s0\fP" aligned

b) Wrap this in a function which would, given the coordinates
   of the "viewpoint" (i.e. where the eye is), output the
   perspective drawing of it.

This could then be applied to all three visible faces.

You can't directly do this by writing a 'pic' function
to transform the coordinates in 'pic' code, since a
built-in type like "box" keep most of these under wraps.
Unless you take it apart and do it by drawing lines between
explicit points (which is basically what I've done above).
But that defeats the aim of my question!

Still less can you apply a perspective transformation to
any text, unless (as I did above) you reach in with
special tools and, again, try to do it piecemeal.

At the other end of the tube, even if you have an object
defined in PostScript code, I doubt you can write a
PostScript function to apply a perspective transformation
to a general object, since the transformation is non-linear.
This would particularly apply to any text. (though,
locally, you can approximate it linearly, but then you
have to explicitly know where you are).

I'm wondering of there is a general approach at all,
within the world of groff/PostScript.


Best wishes to all,

E-Mail: (Ted Harding) <address@hidden>
Fax-to-email: +44 (0)870 094 0861
Date: 17-Oct-06                                       Time: 00:48:01
------------------------------ XFMail ------------------------------

reply via email to

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