Class: Skia::IRect
- Inherits:
-
Object
- Object
- Skia::IRect
- Defined in:
- lib/skia/rect.rb
Instance Attribute Summary collapse
-
#bottom ⇒ Object
Returns the value of attribute bottom.
-
#left ⇒ Object
Returns the value of attribute left.
-
#right ⇒ Object
Returns the value of attribute right.
-
#top ⇒ Object
Returns the value of attribute top.
Class Method Summary collapse
- .from_struct(struct) ⇒ Object
- .from_wh(width, height) ⇒ Object
- .from_xywh(x, y, width, height) ⇒ Object
Instance Method Summary collapse
- #==(other) ⇒ Object
- #empty? ⇒ Boolean
- #height ⇒ Object
-
#initialize(left = 0, top = 0, right = 0, bottom = 0) ⇒ IRect
constructor
A new instance of IRect.
- #to_a ⇒ Object
- #to_rect ⇒ Object
- #to_struct ⇒ Object
- #width ⇒ Object
Constructor Details
#initialize(left = 0, top = 0, right = 0, bottom = 0) ⇒ IRect
Returns a new instance of IRect.
124 125 126 127 128 129 |
# File 'lib/skia/rect.rb', line 124 def initialize(left = 0, top = 0, right = 0, bottom = 0) @left = left.to_i @top = top.to_i @right = right.to_i @bottom = bottom.to_i end |
Instance Attribute Details
#bottom ⇒ Object
Returns the value of attribute bottom.
122 123 124 |
# File 'lib/skia/rect.rb', line 122 def bottom @bottom end |
#left ⇒ Object
Returns the value of attribute left.
122 123 124 |
# File 'lib/skia/rect.rb', line 122 def left @left end |
#right ⇒ Object
Returns the value of attribute right.
122 123 124 |
# File 'lib/skia/rect.rb', line 122 def right @right end |
#top ⇒ Object
Returns the value of attribute top.
122 123 124 |
# File 'lib/skia/rect.rb', line 122 def top @top end |
Class Method Details
.from_struct(struct) ⇒ Object
139 140 141 |
# File 'lib/skia/rect.rb', line 139 def self.from_struct(struct) new(struct[:left], struct[:top], struct[:right], struct[:bottom]) end |
.from_wh(width, height) ⇒ Object
135 136 137 |
# File 'lib/skia/rect.rb', line 135 def self.from_wh(width, height) new(0, 0, width, height) end |
.from_xywh(x, y, width, height) ⇒ Object
131 132 133 |
# File 'lib/skia/rect.rb', line 131 def self.from_xywh(x, y, width, height) new(x, y, x + width, y + height) end |
Instance Method Details
#==(other) ⇒ Object
164 165 166 167 168 169 |
# File 'lib/skia/rect.rb', line 164 def ==(other) return false unless other.is_a?(IRect) @left == other.left && @top == other.top && @right == other.right && @bottom == other.bottom end |
#empty? ⇒ Boolean
160 161 162 |
# File 'lib/skia/rect.rb', line 160 def empty? @left >= @right || @top >= @bottom end |
#height ⇒ Object
156 157 158 |
# File 'lib/skia/rect.rb', line 156 def height @bottom - @top end |
#to_a ⇒ Object
171 172 173 |
# File 'lib/skia/rect.rb', line 171 def to_a [@left, @top, @right, @bottom] end |
#to_rect ⇒ Object
175 176 177 |
# File 'lib/skia/rect.rb', line 175 def to_rect Rect.new(@left.to_f, @top.to_f, @right.to_f, @bottom.to_f) end |
#to_struct ⇒ Object
143 144 145 146 147 148 149 150 |
# File 'lib/skia/rect.rb', line 143 def to_struct struct = Native::SKIRect.new struct[:left] = @left struct[:top] = @top struct[:right] = @right struct[:bottom] = @bottom struct end |
#width ⇒ Object
152 153 154 |
# File 'lib/skia/rect.rb', line 152 def width @right - @left end |