Class: Metro::UI::Rectangle

Inherits:
Model
  • Object
show all
Defined in:
lib/metro/models/ui/rectangle.rb

Overview

The rectangle will draw a rectangle from the specified position out to the specified dimensions in the specified color.

Examples:

Drawing a red rectangle that starts at (20,20) and is 200 by 200


class IntroScene < GameScene
  draw :backdrop, model: "metro::ui::rectangle", position: "20,20",
    color: "rgba(255,0,0,1.0)", dimensions: "200,200"
end

Constant Summary

Constants included from Metro::Units

Metro::Units::Bounds

Instance Attribute Summary collapse

Attributes inherited from Model

#scene, #window

Instance Method Summary collapse

Methods inherited from Model

#_load, #_save, #after_initialize, #bounds, #completed?, #create, hierarchy, inherited, #initialize, metro_name, #model, model_name, models, #name, #notification, #saveable_to_view, #show, #to_hash, #update

Methods included from HasEvents

included

Methods included from KeyValueCoding

#get, #set

Methods included from PropertyOwner

included, #properties

Constructor Details

This class inherits a constructor from Metro::Model

Instance Attribute Details

#colorObject

The color to rectangle



23
# File 'lib/metro/models/ui/rectangle.rb', line 23

property :color

#dimensionsObject

The dimensions of the rectangle



27
28
29
# File 'lib/metro/models/ui/rectangle.rb', line 27

property :dimensions do
  window.dimensions
end

#positionObject

The position of the upper-left corner of the rectangle



19
# File 'lib/metro/models/ui/rectangle.rb', line 19

property :position

Instance Method Details

#drawObject



31
32
33
34
35
36
37
# File 'lib/metro/models/ui/rectangle.rb', line 31

def draw
  window.draw_quad(left_x,top_y,color,
    right_x,top_y,color,
    right_x,bottom_y,color,
    left_x,bottom_y,color,
    z_order)
end