User Tools

Site Tools


pdf:transformationexamples

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
pdf:transformationexamples [2015/04/02 17:46]
christian [no transformation]
pdf:transformationexamples [2015/04/02 18:12] (current)
christian [flip vertically]
Line 22: Line 22:
 page saveAndShowAs:​ '​demo10_transformationsNone.pdf'​ page saveAndShowAs:​ '​demo10_transformationsNone.pdf'​
 </​code>​ </​code>​
 +
 +{{demo10_transformationsnone.pdf}}
  
 ===== flip vertically ===== ===== flip vertically =====
  
- "x -> x  ,  y -> -y   +<code smalltalk>​ 
- In this example the matrix is coded manually.  +"x -> x  ,  y -> -y 
- It can also be coded as 'Matrix scale: 4 @ -4' ​to get '[4 0 0 -4 0 0]'  +In this example the matrix is coded manually.  
- and '(Matrix scale: 4 @ -4) translate: 50 @ 50' ​to get '[4 0 0 -4 50 50]'"​ +It can also be coded as Matrix scale: 4 @ -4 to get '[4 0 0 -4 0 0]'  
- page := Graphics.PDF.Page +and (Matrix scale: 4 @ -4) translate: 50 @ 50 to get '[4 0 0 -4 50 50]'"​ 
- newInBounds:​ (-100 @ -100 corner: 100 @ 100) + 
- colorspace: DeviceRGB new +page := Graphics.PDF.Page 
- render: [:renderer ¦ +  newInBounds:​ (-100 @ -100 corner: 100 @ 100) 
- renderer concat: (Matrix scale: 1 @ -1). +  colorspace: DeviceRGB new 
- renderer moveTo: -100 @ 0; lineTo: 100 @ 0; stroke. ​ "line at y = 0" +  render: [:renderer ¦ 
- renderer moveTo: 0 @ -100; lineTo: 0 @ 100; stroke. ​ "line at x = 0" +    renderer concat: (Matrix scale: 1 @ -1). 
- renderer textObjectDo:​ [ +    renderer moveTo: -100 @ 0; lineTo: 100 @ 0; stroke. ​ "line at y = 0" 
- renderer setFont: #Helvetica size: 1. +    renderer moveTo: 0 @ -100; lineTo: 0 @ 100; stroke. ​ "line at x = 0" 
- renderer textMatrix: #(4 0 0 -4 50 50); showString: '(50 50)'​. +    renderer textObjectDo:​ [ 
- renderer textMatrix: #(2 0 0 -2 -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)'​. 
- page saveAndShowAs:​ '​demo10a_transformationsFlipVertically.pdf'​+      renderer textMatrix: #(2 0 0 -2 50 -50); showString: '(50 -50)'​. 
 +      renderer textMatrix: #(2 0 0 -2 -50 -50); showString: '(-50 -50)'​]]. 
 +page saveAndShowAs:​ '​demo10a_transformationsFlipVertically.pdf'​ 
 +</​code>​
  
 +{{demo10a_transformationsflipvertically.pdf}}
 ===== 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}}
  
 ===== flip diagonally ===== ===== flip diagonally =====
  
- "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:​ '​demo10c_transformationsFlipDiagonal.pdf'​+      renderer textMatrix: #(-2 0 0 -2 -50 -50); showString: '(-50 -50)'​]]. 
 +page saveAndShowAs:​ '​demo10c_transformationsFlipDiagonal.pdf'​ 
 +</​code>​ 
 +{{demo10c_transformationsflipdiagonal.pdf}}
  
 ===== flip vertically and located origin in upper left corner ===== ===== flip vertically and located origin in upper left corner =====
  
- "This is the more common layout used for reports"​ +<code smalltalk>​ 
- page := Graphics.PDF.Page +"This is the more common layout used for reports"​ 
- newInBounds:​ (0 @ 0 corner: 100 @ -100) +page := Graphics.PDF.Page 
- colorspace: DeviceRGB new +  newInBounds:​ (0 @ 0 corner: 100 @ -100) 
- render: [:renderer ¦ +  colorspace: DeviceRGB new 
- renderer concat: (Matrix scale: 1 @ -1). +  render: [:renderer ¦ 
- renderer textObjectDo:​ [ +    renderer concat: (Matrix scale: 1 @ -1). 
- renderer setFont: #Helvetica size: 1. +    renderer textObjectDo:​ [ 
- renderer textMatrix: #(2 0 0 -2 10 10); showString: '(10 10)'.  +      renderer setFont: #Helvetica size: 1. 
- renderer textMatrix: #(2 0 0 -2 10 20); showString: '(10 20)'​. +      renderer textMatrix: #(2 0 0 -2 10 10); showString: '(10 10)'.  
- renderer textMatrix: #(2 0 0 -2 10 30); showString: '(10 30)'​. +      renderer textMatrix: #(2 0 0 -2 10 20); showString: '(10 20)'​. 
- renderer textMatrix: #(2 0 0 -2 10 40); showString: '(10 40)'​. +      renderer textMatrix: #(2 0 0 -2 10 30); showString: '(10 30)'​. 
- renderer textMatrix: #(2 0 0 -2 20 10); showString: '(20 10)'.  +      renderer textMatrix: #(2 0 0 -2 10 40); showString: '(10 40)'​. 
- renderer textMatrix: #(2 0 0 -2 20 20); showString: '(20 20)'​. +      renderer textMatrix: #(2 0 0 -2 20 10); showString: '(20 10)'.  
- renderer textMatrix: #(2 0 0 -2 20 30); showString: '(20 30)'​. +      renderer textMatrix: #(2 0 0 -2 20 20); showString: '(20 20)'​. 
- renderer textMatrix: #(2 0 0 -2 20 40); showString: '(20 40)'​]]. +      renderer textMatrix: #(2 0 0 -2 20 30); showString: '(20 30)'​. 
- page saveAndShowAs:​ '​demo10d_transformationsFlipVerticallyTranslateOrigin.pdf'​+      renderer textMatrix: #(2 0 0 -2 20 40); showString: '(20 40)'​]]. 
 +page saveAndShowAs:​ '​demo10d_transformationsFlipVerticallyTranslateOrigin.pdf'​ 
 +</​code>​ 
 +{{demo10d_transformationsflipverticallytranslateorigin.pdf}}
/var/www/virtual/code4hl/html/dokuwiki/data/attic/pdf/transformationexamples.1427989609.txt.gz · Last modified: 2015/04/02 17:46 by christian