Class: Prawn::Document::BoundingBox

Inherits:
Object
  • Object
show all
Defined in:
lib/prawn/document/bounding_box.rb

Instance Method Summary collapse

Constructor Details

#initialize(parent, point, options = {}) ⇒ BoundingBox

:nodoc:



129
130
131
132
133
# File 'lib/prawn/document/bounding_box.rb', line 129

def initialize(parent, point, options={}) #:nodoc:
  @parent = parent
  @x, @y = point
  @width, @height = options[:width], options[:height]
end

Instance Method Details

#absolute_bottomObject

Absolute bottom y-coordinate of the bottom box



210
211
212
# File 'lib/prawn/document/bounding_box.rb', line 210

def absolute_bottom
  @y - height
end

#absolute_bottom_leftObject

Absolute bottom-left point of the bounding box



228
229
230
# File 'lib/prawn/document/bounding_box.rb', line 228

def absolute_bottom_left
  [absolute_left, absolute_bottom]
end

#absolute_bottom_rightObject

Absolute bottom-left point of the bounding box



234
235
236
# File 'lib/prawn/document/bounding_box.rb', line 234

def absolute_bottom_right
  [absolute_right, absolute_bottom]
end

#absolute_leftObject

Absolute left x-coordinate of the bounding box



192
193
194
# File 'lib/prawn/document/bounding_box.rb', line 192

def absolute_left
  @x
end

#absolute_rightObject

Absolute right x-coordinate of the bounding box



198
199
200
# File 'lib/prawn/document/bounding_box.rb', line 198

def absolute_right
  @x + width
end

#absolute_topObject

Absolute top y-coordinate of the bounding box



204
205
206
# File 'lib/prawn/document/bounding_box.rb', line 204

def absolute_top
  @y
end

#absolute_top_leftObject

Absolute top-left point of the bounding box



216
217
218
# File 'lib/prawn/document/bounding_box.rb', line 216

def absolute_top_left
  [absolute_left, absolute_top]
end

#absolute_top_rightObject

Absolute top-right point of the bounding box



222
223
224
# File 'lib/prawn/document/bounding_box.rb', line 222

def absolute_top_right
  [absolute_right, absolute_top]
end

#anchorObject

The translated origin (x,y-height) which describes the location of the bottom left corner of the bounding box



138
139
140
# File 'lib/prawn/document/bounding_box.rb', line 138

def anchor
  [@x, @y - height]
end

#bottomObject

Relative bottom y-coordinate of the bounding box (Always 0)



162
163
164
# File 'lib/prawn/document/bounding_box.rb', line 162

def bottom
  0
end

#bottom_leftObject

Relative bottom-left point of the bounding box



186
187
188
# File 'lib/prawn/document/bounding_box.rb', line 186

def bottom_left
  [left,bottom]
end

#bottom_rightObject

Relative bottom-right point of the bounding box



180
181
182
# File 'lib/prawn/document/bounding_box.rb', line 180

def bottom_right
  [right,bottom]
end

#heightObject

Height of the bounding box. If the box is ‘stretchy’ (unspecified height attribute), height is calculated as the distance from the top of the box to the current drawing position.



248
249
250
# File 'lib/prawn/document/bounding_box.rb', line 248

def height
  @height || absolute_top - @parent.y
end

#leftObject

Relative left x-coordinate of the bounding box. (Always 0)



144
145
146
# File 'lib/prawn/document/bounding_box.rb', line 144

def left
  0
end

#rightObject

Relative right x-coordinate of the bounding box. (Equal to the box width)



150
151
152
# File 'lib/prawn/document/bounding_box.rb', line 150

def right
  @width
end

#topObject

Relative top y-coordinate of the bounding box. (Equal to the box height)



156
157
158
# File 'lib/prawn/document/bounding_box.rb', line 156

def top
  height
end

#top_leftObject

Relative top-left point of the bounding_box



168
169
170
# File 'lib/prawn/document/bounding_box.rb', line 168

def top_left
  [left,top]
end

#top_rightObject

Relative top-right point of the bounding box



174
175
176
# File 'lib/prawn/document/bounding_box.rb', line 174

def top_right
  [right,top]
end

#widthObject

Width of the bounding box



240
241
242
# File 'lib/prawn/document/bounding_box.rb', line 240

def width
  @width
end