module Cura::Attributes::HasRelativeCoordinates

Adds the `absolute_x` and `absolute_y` attributes, which are relative to it's parent.

Public Class Methods

new(attributes={}) click to toggle source
Calls superclass method Cura::Attributes::HasCoordinates::new
# File lib/cura/attributes/has_relative_coordinates.rb, line 13
def initialize(attributes={})
  @absolute_x = 0
  @absolute_y = 0

  super
end

Public Instance Methods

absolute_x() click to toggle source

Get the absolute X coordinate of this object.

@return [Integer]

# 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() click to toggle source

Get the absolute Y coordinate of this object.

@return [Integer]

# 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