I am drawing a simple rectangle using postscript with following
1 -1 scale
0 -300 translate
newpath
88.9 117.25 moveto
131.6 117.25 lineto
88.9 259.75 lineto
closepath fill
88.9 117.25 moveto
111.4 94.75 lineto
154.1 94.75 lineto
131.6 117.25 lineto
closepath fill
131.6 117.25 moveto
154.1 94.75 lineto
154.1 237.25 lineto
131.6 259.75 lineto
closepath fill
%%EndDocument
The result is a 3D rectangle.
But when I add the following code, rectangle becomes inclined at some angle.
[ 0.9999999 0 -1 1 261 0 ] concat
I can understand that this behavior is caused because of the values used in matrix concatenated with CTM. Can anyone explain the use of values in above matrix and how it affects the behavior of drawing?
Edit:
Thanks a lot for the information. Actually, I am converting a bitmap to eps using post script. For this, I am converting all the operations performed on Graphics object for drawing bitmap to their equivalent post script command.
I am converting g.Transform=matrix
in C# as [ matrix.Elements[0] ...... [matrix.Elements[5] ] concat
in post script. From what I googled, both looks similar to me in functionality but the result of drawn eps is different from the bitmap image. So, I wanted to know how postscript matrix concat transformation works. Can anyone explain what's going wrong with my approach for converting to eps?
CTM is the Current Transformation Matrix, which is normally a 3x3 matrix. In Postscript, it's represented as a 6 element array, since 3 of the elements in a 3x3 CTM are constant. The Postscript CTM array
[a b c d tx ty]
corresponds to the 3x3 CTM matrix
a b 0
c d 0
tx ty 1
though it's often seen in transposed form (as in the linked article):
a c tx
b d ty
0 0 1
In any case, tx
and ty
control translation and the other values combine for other transformations. Some abcd
patterns result in named transformations: rotate, scale, reflect and shear. The one you give fits the shear pattern (if we treat 0.9999999 as 1): 1 0 k 1
, where k
is the shearing amount, which is -1 in your case.