Simple CTM Manipulation Introduction In this section of the course we will introduce the Current Transformation Matrix (CTM) and how to manipulate it.
Rotating the Coordinate System All PostScript commands conform to the CTM. the ability to easily change the CTM allows any image to be rotated, scaled or moved, simply by preceeding it with a CTM changing command. moveto sets the current point. Once set, the current point remains fixed to the paper until moved again. rotate changes the current coordinate system (usually called the CTM). The current point remains with the paper, and does not move with the coordinate system. Program "Up Hill Text" |
|
|
Program "Up Hill Text" - Details |
|
|
|
|
|
|
Question: What would happen if the rotate came before the move? Spinning the Axis (rotate)Solution Rotating the coordinate system (rotate)
Negative angles rotate coordinate system clockwise. rotate is cumulative. "60 rotate" rotates coordinate system an additional 60 degrees counter-clockwise. The current origin is always the pivot point of the rotation.
Program "Down Hill" |
|
|
Program "Down Hill" - Details |
|
|
Exercise Try adding the word "Race" after "Hill" but parallel to the bottom edge of the paper. Stretching the Coordinate System (scale)
The current point remains fixed to the paper. Text conforms to the CTM, so subsequent text will be stretched. Stretches current axis, not original axis.
Tall Letters |
|
|
Exercise swap the move and scale and see what happens Program "Tall Letters" - Details |
|
|
Note that although the scale changes the coordinate system, the current point remains fixed on the page. |
|
|
Question: What would happen if the moveto came after the scale? Short Letters |
|
|
|
|
|
|
|
|
Moving the Coordinate System (translate)
Moves the origin to TxTy. The current point (if any) remains fixed to the paper.
All three change the CTM persistently. All three use the most recent value of the CTM when computing the new value. Program "Venus & Mars" - Output |
|
|
Program "Venus & Mars" - Details |
|
|
|
|
|
|
|
|
|
|
|
|
Question: What happens if the second moveto were omitted? What about the first? Wrong Reading A negative scale factor "flips" the axis; The positive and negative directions are reversed. The show command always conforms to the CTM, so flipping the axis will also flip the text. A -1 1 scale flips the X-axis. A 1 -1 scale flips the Y-axis. You can combine flipping and stretching at the same time, 2 -3 scale, stretches and flips at the same time. Program "Mirror Image Text" |
|
|
|
|
|
|
|
|
Question: What if the moveto was before the scale? What if negative scales are used for both X and Y? Review The Current Transformation Matrix (CTM) controls the mapping from user space to the paper. rotate - changes the CTM by spinning the axis around the origin. scale - changes the CTM by stretching the X and Y axis (negative numbers stretch and flip). translate - changes the CTM by moving the origin. CTM changes are persistent. All subsequent operations conform to the new CTM. You can change the CTM as often as you like. Rule of thumb: |
|
[Home] [Goals] [Intro] [Simple Text] [Simple CTM] |
Copyright © 1998, Mefco, Inc., All Rights Reserved |