class Subconv::Position

Two-dimensional screen position relative (both x and y position between 0 and 1) to the screen size

Attributes

x[R]
y[R]

Public Class Methods

new(x, y) click to toggle source
# File lib/subconv/caption.rb, line 6
def initialize(x, y)
  self.x = x
  self.y = y
end

Public Instance Methods

==(other) click to toggle source
# File lib/subconv/caption.rb, line 11
def ==(other)
  # Ignore small differences in the position
  self.class == other.class && (@x - other.x).abs < 0.01 && (@y - other.y).abs < 0.01
end
x=(x) click to toggle source

Force x position to be a float between 0 and 1

# File lib/subconv/caption.rb, line 19
def x=(x)
  x = x.to_f
  fail RangeError, 'X position not between 0 and 1' unless x.between?(0.0, 1.0)

  @x = x
end
y=(y) click to toggle source

Force y position to be a float between 0 and 1

# File lib/subconv/caption.rb, line 27
def y=(y)
  y = y.to_f
  fail RangeError, 'Y position not between 0 and 1' unless y.between?(0.0, 1.0)

  @y = y
end