Class: GlimR::Image
- Defined in:
- lib/glimr/widgets/image.rb
Overview
Image is a quad matching a texture’s dimensions.
Direct Known Subclasses
Constant Summary
Constants included from Layoutable
Instance Attribute Summary collapse
-
#bound ⇒ Object
Returns the value of attribute bound.
-
#image ⇒ Object
Returns the value of attribute image.
Attributes inherited from Widget
Attributes included from Layoutable
Attributes inherited from Model
#geometry, #material, #shader, #texture, #transform
Attributes inherited from SceneObject
#children, #drawables, #mtime, #parent, #viewport
Attributes included from EventListener
#event_listeners, #listener_count
Class Method Summary collapse
Instance Method Summary collapse
- #create_colors ⇒ Object
- #create_normals ⇒ Object
- #create_texcoords ⇒ Object
- #create_vertices ⇒ Object
- #default_config ⇒ Object
-
#initialize(*a, &b) ⇒ Image
constructor
A new instance of Image.
- #load(filename, update_geo = true) ⇒ Object
- #load_theme(filename, update_geo = true) ⇒ Object
- #texture=(t) ⇒ Object
- #update_geometry ⇒ Object
Methods inherited from Widget
#activate, #blur, #click, #focus, for, #key_down, #key_up, #lock, #mouse_down, #mouse_move, #mouse_out, #mouse_over, #mouse_up, #unlock
Methods included from Layoutable
#attach, #children_change, #constant_size?, #detach, #expand!, #expand?, #expand_height, #expand_to_max_height!, #expand_to_max_width!, #expand_width, #fit_height!, #fit_to_children!, #fit_width!, #free_height, #free_width, #full_depth, #full_height, #full_width, #inner_depth, #inner_height, #inner_width, #inspect, #layout, #layoutable_children, #margin, #margin=, #max_height=, #max_width=, #min_height=, #min_width=, #padding, #padding=, #parent=, #size_changing, size_changing_accessor, #tell_children_of_size_change, #x=, #y=
Methods inherited from Model
#absolute_transform, #apply, #inspect, #pop_state, #push_state
Methods inherited from SceneObject
#<<, #absolute_geometry, #absolute_material, #absolute_shader, #absolute_texture, #absolute_transform, #absolute_transform_for_drawing, #add_drawables, #apply, #attach, #clone, #detach, #detach_self, #inspect, #pop_state, #push_state, #remove_drawables, #render, #replace_node, #root, #touch!, #visible
Methods included from EventListener
#add_event_listener, #decrement_listener_count, #dispatch_event, #event_root, #increment_listener_count, #method_missing, #multicast_event, #process_event, #remove_event_listener
Constructor Details
#initialize(*a, &b) ⇒ Image
Returns a new instance of Image.
29 30 31 32 33 34 |
# File 'lib/glimr/widgets/image.rb', line 29 def initialize(*a,&b) super if @image load(@image) end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class GlimR::EventListener
Instance Attribute Details
#bound ⇒ Object
Returns the value of attribute bound.
20 21 22 |
# File 'lib/glimr/widgets/image.rb', line 20 def bound @bound end |
#image ⇒ Object
Returns the value of attribute image.
20 21 22 |
# File 'lib/glimr/widgets/image.rb', line 20 def image @image end |
Class Method Details
.load(filename) ⇒ Object
10 11 12 13 14 |
# File 'lib/glimr/widgets/image.rb', line 10 def self.load(filename) image = new image.load(filename) image end |
Instance Method Details
#create_colors ⇒ Object
57 58 59 |
# File 'lib/glimr/widgets/image.rb', line 57 def create_colors nil end |
#create_normals ⇒ Object
69 70 71 |
# File 'lib/glimr/widgets/image.rb', line 69 def create_normals [0,0,1, 0,0,1, 0,0,1, 0,0,1] end |
#create_texcoords ⇒ Object
73 74 75 76 77 |
# File 'lib/glimr/widgets/image.rb', line 73 def create_texcoords hb = @texture.height / @texture.bound.to_f wb = @texture.width / @texture.bound.to_f [0,0, wb,0, wb,hb, 0,hb] end |
#create_vertices ⇒ Object
61 62 63 64 65 66 67 |
# File 'lib/glimr/widgets/image.rb', line 61 def create_vertices size_changing do @min_width = @width = @texture.width @min_height = @height = @texture.height end [0,0,0, @texture.width,0,0, @texture.width,@texture.height,0, 0,@texture.height,0] end |
#default_config ⇒ Object
22 23 24 25 26 27 |
# File 'lib/glimr/widgets/image.rb', line 22 def default_config super.merge( :fit_children => false, :image => nil ) end |
#load(filename, update_geo = true) ⇒ Object
41 42 43 44 |
# File 'lib/glimr/widgets/image.rb', line 41 def load(filename,update_geo=true) @texture.load(filename) update_geometry if update_geo end |
#load_theme(filename, update_geo = true) ⇒ Object
46 47 48 |
# File 'lib/glimr/widgets/image.rb', line 46 def load_theme(filename,update_geo=true) load(GlimR.theme + filename, update_geo) end |
#texture=(t) ⇒ Object
36 37 38 39 |
# File 'lib/glimr/widgets/image.rb', line 36 def texture= t super update_geometry end |
#update_geometry ⇒ Object
50 51 52 53 54 55 |
# File 'lib/glimr/widgets/image.rb', line 50 def update_geometry @geometry.vertices = create_vertices @geometry.normals = create_normals @geometry.colors = create_colors @geometry.texcoords = create_texcoords end |