Class: Budgie::Selection
- Inherits:
-
Object
- Object
- Budgie::Selection
- Includes:
- Index
- Defined in:
- lib/budgie/selection.rb
Instance Attribute Summary collapse
-
#b ⇒ Object
Returns the value of attribute b.
-
#g ⇒ Object
Returns the value of attribute g.
-
#normal_x ⇒ Object
Returns the value of attribute normal_x.
-
#normal_y ⇒ Object
Returns the value of attribute normal_y.
-
#normal_z ⇒ Object
Returns the value of attribute normal_z.
-
#r ⇒ Object
Returns the value of attribute r.
-
#selected ⇒ Object
Returns the value of attribute selected.
-
#x ⇒ Object
Returns the value of attribute x.
-
#y ⇒ Object
Returns the value of attribute y.
-
#z ⇒ Object
Returns the value of attribute z.
Instance Method Summary collapse
-
#from_color(r, g, b) ⇒ Object
Nothing is selected when color is [0, 0, 0] Everything else maps to [x, y, z] indexes of the map.
-
#initialize ⇒ Selection
constructor
A new instance of Selection.
- #new_x ⇒ Object
- #new_y ⇒ Object
- #new_z ⇒ Object
-
#normal_from_color(r, g, b) ⇒ Object
Cube normals can be [-1|0|1, -1|0|1, -1|0|1] Normals are encoded like [1|2|3, 1|2|3, 1|2|3].
Methods included from Index
Constructor Details
#initialize ⇒ Selection
Returns a new instance of Selection.
6 7 8 9 |
# File 'lib/budgie/selection.rb', line 6 def initialize @x = @y = @z = @normal_x = @normal_y = @normal_z = @r = @g = @b = 0 @selected = false end |
Instance Attribute Details
#b ⇒ Object
Returns the value of attribute b.
4 5 6 |
# File 'lib/budgie/selection.rb', line 4 def b @b end |
#g ⇒ Object
Returns the value of attribute g.
4 5 6 |
# File 'lib/budgie/selection.rb', line 4 def g @g end |
#normal_x ⇒ Object
Returns the value of attribute normal_x.
4 5 6 |
# File 'lib/budgie/selection.rb', line 4 def normal_x @normal_x end |
#normal_y ⇒ Object
Returns the value of attribute normal_y.
4 5 6 |
# File 'lib/budgie/selection.rb', line 4 def normal_y @normal_y end |
#normal_z ⇒ Object
Returns the value of attribute normal_z.
4 5 6 |
# File 'lib/budgie/selection.rb', line 4 def normal_z @normal_z end |
#r ⇒ Object
Returns the value of attribute r.
4 5 6 |
# File 'lib/budgie/selection.rb', line 4 def r @r end |
#selected ⇒ Object
Returns the value of attribute selected.
4 5 6 |
# File 'lib/budgie/selection.rb', line 4 def selected @selected end |
#x ⇒ Object
Returns the value of attribute x.
4 5 6 |
# File 'lib/budgie/selection.rb', line 4 def x @x end |
#y ⇒ Object
Returns the value of attribute y.
4 5 6 |
# File 'lib/budgie/selection.rb', line 4 def y @y end |
#z ⇒ Object
Returns the value of attribute z.
4 5 6 |
# File 'lib/budgie/selection.rb', line 4 def z @z end |
Instance Method Details
#from_color(r, g, b) ⇒ Object
Nothing is selected when color is [0, 0, 0] Everything else maps to [x, y, z] indexes of the map
25 26 27 28 29 30 31 32 |
# File 'lib/budgie/selection.rb', line 25 def from_color(r, g, b) @selected = r * g * b != 0 if @selected @x = from_index(r - 1) @y = from_index(g - 1) @z = from_index(b - 1) end end |
#new_x ⇒ Object
11 12 13 |
# File 'lib/budgie/selection.rb', line 11 def new_x @x + @normal_x end |
#new_y ⇒ Object
15 16 17 |
# File 'lib/budgie/selection.rb', line 15 def new_y @y + @normal_y end |
#new_z ⇒ Object
19 20 21 |
# File 'lib/budgie/selection.rb', line 19 def new_z @z + @normal_z end |
#normal_from_color(r, g, b) ⇒ Object
Cube normals can be [-1|0|1, -1|0|1, -1|0|1] Normals are encoded like [1|2|3, 1|2|3, 1|2|3]
36 37 38 39 40 |
# File 'lib/budgie/selection.rb', line 36 def normal_from_color(r, g, b) @normal_x = r - 2 @normal_y = g - 2 @normal_z = b - 2 end |