# File lib/rabbit/element/image.rb, line 25 def initialize(filename, prop) @filename = filename prop = Utils.stringify_hash_key(prop) super(filename, prop) normalized_prop = {} prop.each do |name, value| normalized_prop[name.gsub(/-/, '_')] = value end prop = normalized_prop %(caption dither_mode).each do |name| instance_variable_set("@#{name}", prop[name]) end %(keep_scale keep_ratio).each do |name| unless prop[name].nil? self.keep_ratio = true_value?(prop[name]) end end %(as_large_as_possible).each do |name| instance_variable_set("@#{name}", true_value?(prop[name])) end %(width height x_dither y_dither normalized_width normalized_height relative_width relative_height relative_margin_top relative_margin_bottom relative_margin_left relative_margin_right relative_padding_top relative_padding_bottom relative_padding_left relative_padding_right ).each do |name| begin instance_variable_set("@#{name}", prop[name] && Integer(prop[name])) rescue ArgumentError raise InvalidImageSizeError.new(filename, name, prop[name]) end end setup_draw_parameters(prop) resize(@width, @height) end
# File lib/rabbit/element/image.rb, line 124 def as_large_as_possible? @as_large_as_possible end
# File lib/rabbit/element/image.rb, line 111 def compile(canvas, x, y, w, h) super adjust_size(canvas, @x, @y, @w, @h) end
# File lib/rabbit/element/image.rb, line 107 def compile_for_horizontal_centering(canvas, x, y, w, h) _compile(canvas, x, y, w, h) end
# File lib/rabbit/element/image.rb, line 88 def dither_mode @dither_mode ||= "normal" mode_name = "DITHER_#{@dither_mode.upcase}" if Gdk::RGB.const_defined?(mode_name) Gdk::RGB.const_get(mode_name) else Gdk::RGB::DITHER_NORMAL end end
# File lib/rabbit/element/image.rb, line 65 def draw_element(canvas, x, y, w, h, simulation) draw_image(canvas, x, y, w, h, simulation) end
# File lib/rabbit/element/image.rb, line 120 def height super + @padding_top + @padding_bottom end
# File lib/rabbit/element/image.rb, line 69 def text @caption.to_s end
# File lib/rabbit/element/image.rb, line 77 def to_html(generator) src = generator.save_pixbuf(pixbuf, File.basename(@filename)) html = "<img " if @caption alt = generator.h(@caption) html << "title=\"#{alt}\" alt=\"#{alt}\" " end html << "src=\"#{src}\" />" html end
# File lib/rabbit/element/image.rb, line 116 def width super + @padding_left + @padding_right end
Generated with the Darkfish Rdoc Generator 2.