Class: Prawn::Document::BoundingBox

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

Direct Known Subclasses

LazyBoundingBox

Instance Method Summary collapse

Constructor Details

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

:nodoc:



193
194
195
196
197
# File 'lib/prawn/document/bounding_box.rb', line 193

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



274
275
276
# File 'lib/prawn/document/bounding_box.rb', line 274

def absolute_bottom
  @y - height
end

#absolute_bottom_leftObject

Absolute bottom-left point of the bounding box



292
293
294
# File 'lib/prawn/document/bounding_box.rb', line 292

def absolute_bottom_left
  [absolute_left, absolute_bottom]
end

#absolute_bottom_rightObject

Absolute bottom-left point of the bounding box



298
299
300
# File 'lib/prawn/document/bounding_box.rb', line 298

def absolute_bottom_right
  [absolute_right, absolute_bottom]
end

#absolute_leftObject

Absolute left x-coordinate of the bounding box



256
257
258
# File 'lib/prawn/document/bounding_box.rb', line 256

def absolute_left
  @x
end

#absolute_rightObject

Absolute right x-coordinate of the bounding box



262
263
264
# File 'lib/prawn/document/bounding_box.rb', line 262

def absolute_right
  @x + width
end

#absolute_topObject

Absolute top y-coordinate of the bounding box



268
269
270
# File 'lib/prawn/document/bounding_box.rb', line 268

def absolute_top
  @y
end

#absolute_top_leftObject

Absolute top-left point of the bounding box



280
281
282
# File 'lib/prawn/document/bounding_box.rb', line 280

def absolute_top_left
  [absolute_left, absolute_top]
end

#absolute_top_rightObject

Absolute top-right point of the bounding box



286
287
288
# File 'lib/prawn/document/bounding_box.rb', line 286

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



202
203
204
# File 'lib/prawn/document/bounding_box.rb', line 202

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

#bottomObject

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



226
227
228
# File 'lib/prawn/document/bounding_box.rb', line 226

def bottom
  0
end

#bottom_leftObject

Relative bottom-left point of the bounding box



250
251
252
# File 'lib/prawn/document/bounding_box.rb', line 250

def bottom_left
  [left,bottom]
end

#bottom_rightObject

Relative bottom-right point of the bounding box



244
245
246
# File 'lib/prawn/document/bounding_box.rb', line 244

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.



312
313
314
# File 'lib/prawn/document/bounding_box.rb', line 312

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

#leftObject

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



208
209
210
# File 'lib/prawn/document/bounding_box.rb', line 208

def left
  0
end

#rightObject

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



214
215
216
# File 'lib/prawn/document/bounding_box.rb', line 214

def right
  @width
end

#stretchy?Boolean

Returns false when the box has a defined height, true when the height is being calculated on the fly based on the current vertical position.

Returns:

  • (Boolean)


319
320
321
# File 'lib/prawn/document/bounding_box.rb', line 319

def stretchy?
  !@height 
end

#topObject

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



220
221
222
# File 'lib/prawn/document/bounding_box.rb', line 220

def top
  height
end

#top_leftObject

Relative top-left point of the bounding_box



232
233
234
# File 'lib/prawn/document/bounding_box.rb', line 232

def top_left
  [left,top]
end

#top_rightObject

Relative top-right point of the bounding box



238
239
240
# File 'lib/prawn/document/bounding_box.rb', line 238

def top_right
  [right,top]
end

#widthObject

Width of the bounding box



304
305
306
# File 'lib/prawn/document/bounding_box.rb', line 304

def width
  @width
end