Class: Skia::IPoint

Inherits:
Object
  • Object
show all
Defined in:
lib/skia/point.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(x = 0, y = 0) ⇒ IPoint

Returns a new instance of IPoint.



68
69
70
71
# File 'lib/skia/point.rb', line 68

def initialize(x = 0, y = 0)
  @x = x.to_i
  @y = y.to_i
end

Instance Attribute Details

#xObject

Returns the value of attribute x.



66
67
68
# File 'lib/skia/point.rb', line 66

def x
  @x
end

#yObject

Returns the value of attribute y.



66
67
68
# File 'lib/skia/point.rb', line 66

def y
  @y
end

Class Method Details

.from_struct(struct) ⇒ Object



73
74
75
# File 'lib/skia/point.rb', line 73

def self.from_struct(struct)
  new(struct[:x], struct[:y])
end

Instance Method Details

#==(other) ⇒ Object



84
85
86
87
88
# File 'lib/skia/point.rb', line 84

def ==(other)
  return false unless other.is_a?(IPoint)

  @x == other.x && @y == other.y
end

#to_aObject



90
91
92
# File 'lib/skia/point.rb', line 90

def to_a
  [@x, @y]
end

#to_structObject



77
78
79
80
81
82
# File 'lib/skia/point.rb', line 77

def to_struct
  struct = Native::SKIPoint.new
  struct[:x] = @x
  struct[:y] = @y
  struct
end