Module: Prawn::TransformationStack
- Included in:
- Document
- Defined in:
- lib/prawn/transformation_stack.rb
Instance Method Summary collapse
- #add_to_transformation_stack(a, b, c, d, e, f) ⇒ Object
- #current_transformation_matrix_with_translation(x = 0, y = 0) ⇒ Object
- #restore_transformation_stack ⇒ Object
- #save_transformation_stack ⇒ Object
Instance Method Details
#add_to_transformation_stack(a, b, c, d, e, f) ⇒ Object
14 15 16 17 |
# File 'lib/prawn/transformation_stack.rb', line 14 def add_to_transformation_stack(a, b, c, d, e, f) @transformation_stack ||= [[]] @transformation_stack.last.push([a, b, c, d, e, f].map(&:to_f)) end |
#current_transformation_matrix_with_translation(x = 0, y = 0) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/prawn/transformation_stack.rb', line 28 def current_transformation_matrix_with_translation(x = 0, y = 0) transformations = (@transformation_stack || [[]]).last matrix = Matrix.identity(3) transformations.each do |a, b, c, d, e, f| matrix *= Matrix[[a, c, e], [b, d, f], [0, 0, 1]] end matrix *= Matrix[[1, 0, x], [0, 1, y], [0, 0, 1]] matrix.to_a[0..1].transpose.flatten end |
#restore_transformation_stack ⇒ Object
24 25 26 |
# File 'lib/prawn/transformation_stack.rb', line 24 def restore_transformation_stack @transformation_stack.pop if @transformation_stack end |
#save_transformation_stack ⇒ Object
19 20 21 22 |
# File 'lib/prawn/transformation_stack.rb', line 19 def save_transformation_stack @transformation_stack ||= [[]] @transformation_stack.push(@transformation_stack.last.dup) end |