Class: Metro::UI::Border

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

Overview

Draws a rectanglar border around the specififed position and dimensions with the width provided. This is an unfilled rectangle.

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, #create, #draw_completed?, hierarchy, inherited, #initialize, metro_name, #model, model_name, models, #name, #notification, #saveable_to_view, #show, #to_hash, #update, #update_completed?

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

#borderObject

The width of the border lines



24
# File 'lib/metro/models/ui/border.rb', line 24

property :border, default: 2

#colorObject

The color which to use to draw the border.



20
# File 'lib/metro/models/ui/border.rb', line 20

property :color, default: "rgba(255,255,255,1.0)"

#dimensionsObject

The dimension of the border.



16
# File 'lib/metro/models/ui/border.rb', line 16

property :dimensions

#positionObject

The starting position of the border.



12
# File 'lib/metro/models/ui/border.rb', line 12

property :position

Instance Method Details

#bottomObject



84
85
86
# File 'lib/metro/models/ui/border.rb', line 84

def bottom
  y + height
end

#bottom_with_borderObject



88
89
90
# File 'lib/metro/models/ui/border.rb', line 88

def bottom_with_border
  bottom + border
end

#drawObject



26
27
28
# File 'lib/metro/models/ui/border.rb', line 26

def draw
  draw_border
end

#draw_borderObject



30
31
32
33
34
35
# File 'lib/metro/models/ui/border.rb', line 30

def draw_border
  draw_top
  draw_bottom
  draw_left
  draw_right
end

#draw_bottomObject



49
50
51
# File 'lib/metro/models/ui/border.rb', line 49

def draw_bottom
  draw_line left_with_border, bottom, right,bottom_with_border
end

#draw_leftObject



41
42
43
# File 'lib/metro/models/ui/border.rb', line 41

def draw_left
  draw_line left, top, left_with_border, bottom_with_border
end

#draw_line(start_x, start_y, finish_x, finish_y) ⇒ Object



53
54
55
56
57
58
# File 'lib/metro/models/ui/border.rb', line 53

def draw_line(start_x,start_y,finish_x,finish_y)
  window.draw_quad start_x, start_y, color,
    finish_x, start_y, color,
    finish_x, finish_y, color,
    start_x, finish_y, color, z_order
end

#draw_rightObject



45
46
47
# File 'lib/metro/models/ui/border.rb', line 45

def draw_right
  draw_line right, top, right_with_border, bottom_with_border
end

#draw_topObject



37
38
39
# File 'lib/metro/models/ui/border.rb', line 37

def draw_top
  draw_line left_with_border, top, right, top_with_border
end

#leftObject



60
61
62
# File 'lib/metro/models/ui/border.rb', line 60

def left
  x
end

#left_with_borderObject



64
65
66
# File 'lib/metro/models/ui/border.rb', line 64

def left_with_border
  x + border
end

#rightObject



68
69
70
# File 'lib/metro/models/ui/border.rb', line 68

def right
  x + width
end

#right_with_borderObject



72
73
74
# File 'lib/metro/models/ui/border.rb', line 72

def right_with_border
  right + border
end

#topObject



76
77
78
# File 'lib/metro/models/ui/border.rb', line 76

def top
  y
end

#top_with_borderObject



80
81
82
# File 'lib/metro/models/ui/border.rb', line 80

def top_with_border
  top + border
end