Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How can I stretch a Postscript image, vertically only??

94 views
Skip to first unread message

Ramon F Herrera

unread,
Jan 9, 2012, 2:35:13 PM1/9/12
to

See my thread "Need minimum/tutorial Postscript code".

In essence, I need to multiply the vertical dimensions by a factor of
3.

TIA,

-Ramon

Helge Blischke

unread,
Jan 9, 2012, 3:10:15 PM1/9/12
to
What about

1 3 scale

?

Helge

Ramon F Herrera

unread,
Jan 9, 2012, 3:44:52 PM1/9/12
to
Thanks Helge!

I tried it, but it doesn't work. It scales the traces, making the
horizontal lines thicker:

http://patriot.net/~ramon/misc/Trace-Scale.png

What I need is to make the cells 3 times taller, in order to see the
inner rhombus more clearly.

-Ramon

Ramon F Herrera

unread,
Jan 9, 2012, 3:54:23 PM1/9/12
to
On Jan 9, 2:10 pm, Helge Blischke <h.blisc...@acm.org> wrote:
Here's my current Postscript code (either one, is the same file):

http://patriot.net/~ramon/misc/brain-teaser.ps

http://patriot.net/~ramon/misc/brain-teaser.ps.txt

TIA,

-Ramon

luser- -droog

unread,
Jan 9, 2012, 4:27:54 PM1/9/12
to
On Jan 9, 2:44 pm, Ramon F Herrera <ra...@conexus.net> wrote:
> On Jan 9, 2:10 pm, Helge Blischke <h.blisc...@acm.org> wrote:
>
> > Ramon F Herrera wrote:
>
> > > See my thread "Need minimum/tutorial Postscript code".
>
> > > In essence, I need to multiply the vertical dimensions by a factor of
> > > 3.
>
> > > TIA,
>
> > > -Ramon
>
>  > What about
>  >
>  > 1 3 scale
>  >
>  > ?
>  >
>  > Helge
>
> Thanks Helge!
>
> I tried it, but it doesn't work. It scales the traces, making the
> horizontal lines thicker:
>

That's not fatal! You just need to *un*scale before you `stroke`.


matrix currentmatrix % get a copy of the 'current' matrix
1 3 scale
%create path (moveto's and lineto's)
setmatrix % reinstall the saved matrix
stroke % draw the lines with the "normal" pen-shape.


In a pinch, you can use
matrix defaultmatrix setmatrix
to reset the pen-shape. But this is a bad habit; it destroys
modularity; and it's illegal in EPS. Because you can't *embed*
the program fragment anymore.

luser- -droog

unread,
Jan 10, 2012, 3:25:52 AM1/10/12
to
This is an aspect of postscript that took me a looooong time even
to notice. For line-drawing, postscript uses the Current
Transformation
Matrix /twice/! It transforms user coordinates through the CTM and
stores the current path in device-space points (so currentpoint
uses itransform to present the point in the current user-space).

Then, when you stroke, it uses the CTM a second time to define the
shape of the virtual pen (brush) that performs the drawing.

A nifty special effect is to use some crazy /skewed/ pen to draw
an otherwise static picture. It can "liven things up".

% construct path (moveto's and lineto's)
[ 1 .5 5 30 0 0 ] setmatrix stroke

Helge Blischke

unread,
Jan 10, 2012, 6:50:38 AM1/10/12
to
"illegal" is a hard statement. The core of the restrictions the PLRM states
on EPS files is that an EPS must not generate any unwanted side effects that
may have influence of the environment that includes the EPS. But if you use
e.g. setmatrix as shown above it is perfectly legal.

luser- -droog

unread,
Sep 14, 2012, 12:34:46 AM9/14/12
to
Finally looked this one up.
PLRM 2ed, Appendix I Guidelines for Specific Operators
===
setmatrix
Should be used with a matrix that was previously obtained
using the currentmatrix operator or its equivalent. It can
be used for drawing objects such as ovals:

matrix currentmatrix
rx ry scale
0 0 1 0 360 arc
setmatrix
stroke
This example ensures that the oval is drawn with an even
stroke. However, do not use this operator to perform such
operations as flipping the coordinate axes. Instead, use
the concat operator and concatenate to the current
transformation matrix. Ordinarily, Postscript programs
should modify the CTM (by using the translate, scale, rotate,
and concat operators rather than replacing it.
===

So `matrix defaultmatrix setmatrix` is definitely discouraged.
Doing this is not what one ordinarily should do.

hel...@gmail.com

unread,
Sep 24, 2012, 12:16:29 PM9/24/12
to
Am Dienstag, 10. Januar 2012 09:25:52 UTC+1 schrieb luser- -droog:
> ... For line-drawing, postscript uses the Current
>
> Transformation
>
> Matrix /twice/!

You know that this is only "half true" what you say. The path construction uses the CTM to fix up where the points have to be.
If you now invoke something like "stroke" it has to "enhance" the path to make it "substantial" and it will do this by CTM at this moment. As a "normal path" has no dimensions regarding how "thick" is a line, this is done at the moment the line is drawn. The "stroke" operator knows how thick the line has to be. So, this is wanted behavior. Nothing big to mention.

Regards,
-Helmar

luser.droog

unread,
Sep 24, 2012, 7:25:28 PM9/24/12
to
Agreed. But this appeared to be the crucial missing fact for OP's program.

Mark Carroll

unread,
Aug 3, 2013, 4:39:42 AM8/3/13
to
Ramon F Herrera <ra...@conexus.net> writes:

> In essence, I need to multiply the vertical dimensions by a factor of
> 3.

An incredibly late reply, I know, but including a,
1 3 scale
should do that just fine.

Mark

luser- -droog

unread,
Aug 15, 2013, 2:46:23 AM8/15/13
to
I'm assuming your newsgroup interface isn't showing you the whole thread.
That was a good start, but it makes horizontal lines wider than vertical
lines. A workaround was to reset the matrix before stroking.

matrix currentmatrix
1 3 scale
...
setmatrix stroke


0 new messages