Class: Budgie::DrawPickerMap
- Inherits:
-
Object
- Object
- Budgie::DrawPickerMap
- Includes:
- Index, GL
- Defined in:
- lib/budgie/draw_picker_map.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#map ⇒ Object
readonly
Returns the value of attribute map.
-
#partial_size ⇒ Object
readonly
Returns the value of attribute partial_size.
Instance Method Summary collapse
- #compile ⇒ Object
- #cube_color(x, y, z, index) ⇒ Object
- #draw ⇒ Object
-
#initialize(map) ⇒ DrawPickerMap
constructor
A new instance of DrawPickerMap.
- #update_partial(x, y, z) ⇒ Object
Methods included from Index
Constructor Details
#initialize(map) ⇒ DrawPickerMap
Returns a new instance of DrawPickerMap.
13 14 15 16 17 18 19 |
# File 'lib/budgie/draw_picker_map.rb', line 13 def initialize(map) @map = map @partial_size = 16 @partials = Map.new 1 + @map.max / @partial_size compile end |
Instance Attribute Details
#map ⇒ Object (readonly)
Returns the value of attribute map.
11 12 13 |
# File 'lib/budgie/draw_picker_map.rb', line 11 def map @map end |
#partial_size ⇒ Object (readonly)
Returns the value of attribute partial_size.
11 12 13 |
# File 'lib/budgie/draw_picker_map.rb', line 11 def partial_size @partial_size end |
Instance Method Details
#compile ⇒ Object
34 35 36 37 38 |
# File 'lib/budgie/draw_picker_map.rb', line 34 def compile @partials.each do |x, y, z| compile_partial x, y, z end end |
#cube_color(x, y, z, index) ⇒ Object
46 47 48 49 50 51 |
# File 'lib/budgie/draw_picker_map.rb', line 46 def cube_color(x, y, z, index) x = 1 + to_index(x) y = 1 + to_index(y) z = 1 + to_index(z) glColor3ub x, y, z end |
#draw ⇒ Object
40 41 42 43 44 |
# File 'lib/budgie/draw_picker_map.rb', line 40 def draw @partials.each do |x, y, z| draw_partial x, y, z end end |
#update_partial(x, y, z) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/budgie/draw_picker_map.rb', line 21 def update_partial(x, y, z) x /= @partial_size y /= @partial_size z /= @partial_size compile_partial x, y, z # compile_partial x - 1, y, z # compile_partial x + 1, y, z # compile_partial x, y - 1, z # compile_partial x, y + 1, z # compile_partial x, y, z - 1 # compile_partial x, y, z + 1 end |