This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
pdf:transformationexamples [2015/04/02 18:10] christian [flip diagonally] |
pdf:transformationexamples [2015/04/02 18:12] (current) christian [flip vertically] |
||
---|---|---|---|
Line 27: | Line 27: | ||
===== flip vertically ===== | ===== flip vertically ===== | ||
- | **x -> x , y -> -y** | + | <code smalltalk> |
+ | "x -> x , y -> -y | ||
In this example the matrix is coded manually. | In this example the matrix is coded manually. | ||
- | It can also be coded as <code smalltalk>Matrix scale: 4 @ -4</code> to get ''[4 0 0 -4 0 0]'' | + | It can also be coded as Matrix scale: 4 @ -4 to get '[4 0 0 -4 0 0]' |
- | and <code smalltalk>(Matrix scale: 4 @ -4) translate: 50 @ 50</code> to get ''[4 0 0 -4 50 50]''" | + | and (Matrix scale: 4 @ -4) translate: 50 @ 50 to get '[4 0 0 -4 50 50]'" |
- | <code smalltalk> | ||
page := Graphics.PDF.Page | page := Graphics.PDF.Page | ||
newInBounds: (-100 @ -100 corner: 100 @ 100) | newInBounds: (-100 @ -100 corner: 100 @ 100) | ||
Line 53: | Line 52: | ||
===== flip horizontally ===== | ===== flip horizontally ===== | ||
- | "x -> -x , y -> y" | + | <code smalltalk> |
- | page := Graphics.PDF.Page | + | "x -> -x , y -> y" |
- | newInBounds: (-100 @ -100 corner: 100 @ 100) | + | page := Graphics.PDF.Page |
- | colorspace: DeviceRGB new | + | newInBounds: (-100 @ -100 corner: 100 @ 100) |
- | render: [:renderer ¦ | + | colorspace: DeviceRGB new |
- | renderer concat: (Matrix scale: -1 @ 1). | + | render: [:renderer ¦ |
- | renderer moveTo: -100 @ 0; lineTo: 100 @ 0; stroke. "line at y = 0" | + | renderer concat: (Matrix scale: -1 @ 1). |
- | renderer moveTo: 0 @ -100; lineTo: 0 @ 100; stroke. "line at x = 0" | + | renderer moveTo: -100 @ 0; lineTo: 100 @ 0; stroke. "line at y = 0" |
- | renderer textObjectDo: [ | + | renderer moveTo: 0 @ -100; lineTo: 0 @ 100; stroke. "line at x = 0" |
- | renderer setFont: #Helvetica size: 1. | + | renderer textObjectDo: [ |
- | renderer textMatrix: #(-4 0 0 4 50 50); showString: '(50 50)'. | + | renderer setFont: #Helvetica size: 1. |
- | renderer textMatrix: #(-2 0 0 2 -50 50); showString: '(-50 50)'. | + | renderer textMatrix: #(-4 0 0 4 50 50); showString: '(50 50)'. |
- | renderer textMatrix: #(-2 0 0 2 50 -50); showString: '(50 -50)'. | + | renderer textMatrix: #(-2 0 0 2 -50 50); showString: '(-50 50)'. |
- | renderer textMatrix: #(-2 0 0 2 -50 -50); showString: '(-50 -50)']]. | + | renderer textMatrix: #(-2 0 0 2 50 -50); showString: '(50 -50)'. |
- | page saveAndShowAs: 'demo10b_transformationsFlipHorizontally.pdf' | + | renderer textMatrix: #(-2 0 0 2 -50 -50); showString: '(-50 -50)']]. |
+ | page saveAndShowAs: 'demo10b_transformationsFlipHorizontally.pdf' | ||
+ | </code> | ||
{{demo10b_transformationsfliphorizontally.pdf}} | {{demo10b_transformationsfliphorizontally.pdf}} | ||