Class: HexaPDF::Rectangle
Overview
Implementation of the PDF rectangle data structure.
Rectangles are used for describing page and bounding boxes. They are represented by arrays of four numbers specifying the (x,y) coordinates of any diagonally opposite corners.
This class simplifies the usage of rectangles by automatically normalizing the coordinates so that they are in the order:
[llx, lly, urx, ury]
where llx
is the lower-left x-coordinate, lly
is the lower-left y-coordinate, urx
is the upper-right x-coordinate and ury
is the upper-right y-coordinate.
See: PDF1.7 s7.9.5
Constant Summary
Constants inherited from Object
Object::NOT_DUPLICATABLE_CLASSES
Instance Attribute Summary
Attributes inherited from Object
#data, #document, #must_be_indirect
Instance Method Summary collapse
-
#bottom ⇒ Object
Returns the y-coordinate of the lower-left corner.
-
#height ⇒ Object
Returns the height of the rectangle.
-
#left ⇒ Object
Returns the x-coordinate of the lower-left corner.
-
#right ⇒ Object
Returns the x-coordinate of the upper-right corner.
-
#top ⇒ Object
Returns the y-coordinate of the upper-right corner.
-
#width ⇒ Object
Returns the width of the rectangle.
Methods inherited from Object
#<=>, #==, deep_copy, #deep_copy, #document?, #eql?, #gen, #gen=, #hash, #indirect?, #initialize, #inspect, #must_be_indirect?, #null?, #oid, #oid=, #type, #validate, #value, #value=
Constructor Details
This class inherits a constructor from HexaPDF::Object
Instance Method Details
#bottom ⇒ Object
Returns the y-coordinate of the lower-left corner.
65 66 67 |
# File 'lib/hexapdf/rectangle.rb', line 65 def bottom value[1] end |
#height ⇒ Object
Returns the height of the rectangle.
80 81 82 |
# File 'lib/hexapdf/rectangle.rb', line 80 def height value[3] - value[1] end |
#left ⇒ Object
Returns the x-coordinate of the lower-left corner.
55 56 57 |
# File 'lib/hexapdf/rectangle.rb', line 55 def left value[0] end |
#right ⇒ Object
Returns the x-coordinate of the upper-right corner.
60 61 62 |
# File 'lib/hexapdf/rectangle.rb', line 60 def right value[2] end |
#top ⇒ Object
Returns the y-coordinate of the upper-right corner.
70 71 72 |
# File 'lib/hexapdf/rectangle.rb', line 70 def top value[3] end |
#width ⇒ Object
Returns the width of the rectangle.
75 76 77 |
# File 'lib/hexapdf/rectangle.rb', line 75 def width value[2] - value[0] end |