Method: PDF::Reader::Rectangle#apply_rotation

Defined in:
lib/pdf/reader/rectangle.rb

#apply_rotation(degrees) ⇒ Object

: (Integer) -> void



91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/pdf/reader/rectangle.rb', line 91

def apply_rotation(degrees)
  return if degrees != 90 && degrees != 180 && degrees != 270

  if degrees == 90
    new_x1 = bottom_left.x
    new_y1 = bottom_left.y - width
    new_x2 = bottom_left.x + height
    new_y2 = bottom_left.y
  elsif degrees == 180
    new_x1 = bottom_left.x - width
    new_y1 = bottom_left.y - height
    new_x2 = bottom_left.x
    new_y2 = bottom_left.y
  elsif degrees == 270
    new_x1 = bottom_left.x - height
    new_y1 = bottom_left.y
    new_x2 = bottom_left.x
    new_y2 = bottom_left.y + width
  end
  set_corners(new_x1 || 0, new_y1 || 0, new_x2 || 0, new_y2 || 0)
end