Class: Wads::ImageWidget
Overview
Displays an image on the screen at the specific x, y location. The image can be scaled by setting the scale attribute. The image attribute to the construcor can be the string file location or a Gosu::Image instance
Instance Attribute Summary collapse
-
#img ⇒ Object
Returns the value of attribute img.
-
#scale ⇒ Object
Returns the value of attribute scale.
Attributes inherited from Widget
#base_z, #children, #gui_theme, #height, #is_selected, #layout, #overlay_widget, #override_color, #text_input_fields, #visible, #width, #x, #y
Instance Method Summary collapse
-
#initialize(x, y, image, args = {}) ⇒ ImageWidget
constructor
A new instance of ImageWidget.
- #render ⇒ Object
- #widget_z ⇒ Object
Methods inherited from Widget
#add, #add_axis_lines, #add_button, #add_child, #add_delete_button, #add_document, #add_graph_display, #add_image, #add_multi_select_table, #add_overlay, #add_panel, #add_plot, #add_single_select_table, #add_table, #add_text, #border_color, #bottom_edge, #button_down, #button_up, #center_children, #center_x, #center_y, #clear_children, #contains_click, #debug, #disable_background, #disable_border, #draw, #draw_background, #draw_border, #enable_background, #enable_border, #error, #get_layout, #get_theme, #graphics_color, #handle_key_held_down, #handle_key_press, #handle_key_up, #handle_mouse_down, #handle_mouse_up, #handle_right_mouse, #handle_update, #info, #intercept_widget_event, #left_edge, #move_recursive_absolute, #move_recursive_delta, #overlaps_with, #pad, #relative_x, #relative_y, #relative_z_order, #remove_child, #remove_children, #remove_children_by_type, #right_edge, #selection_color, #set_absolute_position, #set_dimensions, #set_layout, #set_selected, #set_theme, #text_color, #top_edge, #unset_selected, #update, #uses_layout, #warn, #x_pixel_to_screen, #y_pixel_to_screen, #z_order
Constructor Details
#initialize(x, y, image, args = {}) ⇒ ImageWidget
Returns a new instance of ImageWidget.
1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 |
# File 'lib/wads/widgets.rb', line 1784 def initialize(x, y, image, args = {}) super(x, y) if image.is_a? String @img = Gosu::Image.new(image) elsif image.is_a? Gosu::Image @img = image elsif image.is_a? Gosu::Color @img = nil @override_color = image else raise "ImageWidget requires either a filename or a Gosu::Image object" end if args[ARG_THEME] @gui_theme = args[ARG_THEME] end @scale = 1 disable_border disable_background set_dimensions(@img.width, @img.height) if @img end |
Instance Attribute Details
#img ⇒ Object
Returns the value of attribute img.
1781 1782 1783 |
# File 'lib/wads/widgets.rb', line 1781 def img @img end |
#scale ⇒ Object
Returns the value of attribute scale.
1782 1783 1784 |
# File 'lib/wads/widgets.rb', line 1782 def scale @scale end |
Instance Method Details
#render ⇒ Object
1805 1806 1807 1808 1809 1810 1811 1812 |
# File 'lib/wads/widgets.rb', line 1805 def render if @img.nil? # TODO draw a box Gosu::draw_rect(@x, @y, @width - 1, @height - 1, @override_color, relative_z_order(Z_ORDER_GRAPHIC_ELEMENTS)) else @img.draw @x, @y, z_order, @scale, @scale end end |
#widget_z ⇒ Object
1814 1815 1816 |
# File 'lib/wads/widgets.rb', line 1814 def Z_ORDER_FOCAL_ELEMENTS end |