Module: Cura::Attributes::HasRelativeCoordinates
- Includes:
- HasAncestry, HasCoordinates
- Included in:
- Component::Base
- Defined in:
- lib/cura/attributes/has_relative_coordinates.rb
Overview
Adds the ‘absolute_x` and `absolute_y` attributes, which are relative to it’s parent.
Instance Attribute Summary
Attributes included from HasAncestry
Instance Method Summary collapse
-
#absolute_x ⇒ Integer
Get the absolute X coordinate of this object.
-
#absolute_y ⇒ Integer
Get the absolute Y coordinate of this object.
- #initialize(attributes = {}) ⇒ Object
Methods included from HasCoordinates
Methods included from HasAttributes
Methods included from HasAncestry
Instance Method Details
#absolute_x ⇒ Integer
Get the absolute X coordinate of this object.
23 24 25 |
# File 'lib/cura/attributes/has_relative_coordinates.rb', line 23 def absolute_x parent? && parent.respond_to?(:absolute_x) ? @x + parent.offsets.left + parent.absolute_x : @x end |
#absolute_y ⇒ Integer
Get the absolute Y coordinate of this object.
30 31 32 |
# File 'lib/cura/attributes/has_relative_coordinates.rb', line 30 def absolute_y parent? && parent.respond_to?(:absolute_y) ? @y + parent.offsets.top + parent.absolute_y : @y end |
#initialize(attributes = {}) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/cura/attributes/has_relative_coordinates.rb', line 13 def initialize(attributes={}) @absolute_x = 0 @absolute_y = 0 super end |