Class: Gosling::Rect

Inherits:
Polygon show all
Defined in:
lib/gosling/rect.rb

Overview

A Rect is a Polygon with exactly four vertices, defined by a width and height, with sides at right angles to one another. The width and height can be modified at runtime; all vertices will be updated automatically.

Direct Known Subclasses

Sprite

Instance Attribute Summary collapse

Attributes inherited from Actor

#are_children_tangible, #are_children_visible, #children, #color, #is_mask, #is_tangible, #is_visible, #parent, #window

Attributes included from Transformable

#rotation

Instance Method Summary collapse

Methods inherited from Polygon

#get_global_vertices, #get_vertices, #is_point_in_bounds, #set_vertices, #set_vertices_rect

Methods inherited from Actor

#add_child, #alpha, #alpha=, #blue, #blue=, #draw, #get_actor_at, #get_actors_at, #get_global_position, #get_global_transform, #green, #green=, #has_child?, #inspect, #is_point_in_bounds, #red, #red=, #remove_child

Methods included from Transformable

#center, #center=, #center_x, #center_x=, #center_y, #center_y=, #reset, #scale, #scale=, #scale_x, #scale_x=, #scale_y, #scale_y=, #to_matrix, transform_point, #transform_point, #translation, #translation=, untransform_point, #untransform_point, #x, #x=, #y, #y=

Constructor Details

#initialize(window) ⇒ Rect

Creates a new Rect with a width and height of 1.



14
15
16
17
18
19
# File 'lib/gosling/rect.rb', line 14

def initialize(window)
  super(window)
  @width = 1
  @height = 1
  rebuild_vertices
end

Instance Attribute Details

#heightObject

Returns the value of attribute height.



9
10
11
# File 'lib/gosling/rect.rb', line 9

def height
  @height
end

#widthObject

Returns the value of attribute width.



9
10
11
# File 'lib/gosling/rect.rb', line 9

def width
  @width
end