Class: CTioga2::Graphics::Styles::ImageStyle
- Inherits:
-
BasicStyle
- Object
- BasicStyle
- CTioga2::Graphics::Styles::ImageStyle
- Defined in:
- lib/ctioga2/graphics/styles/image.rb
Overview
This class represents the style for an image
Constant Summary
Constants inherited from BasicStyle
BasicStyle::AllStyles, BasicStyle::OldAttrAccessor
Instance Method Summary collapse
-
#draw_image(t, file, tl, br) ⇒ Object
Draws an image according to this.
Methods inherited from BasicStyle
alias_for, aliases, attr_accessor, attribute_type, attribute_types, attributes, convert_string_hash, defined_aliases, deprecated_attribute, from_hash, inherited, #instance_variable_defined?, normalize_hash, normalize_in, normalize_out, options_hash, #set_from_hash, sub_style, sub_styles, #to_hash, typed_attribute, #update_from_other, #use_defaults_from
Instance Method Details
#draw_image(t, file, tl, br) ⇒ Object
Draws an image according to this
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/ctioga2/graphics/styles/image.rb', line 56 def draw_image(t, file, tl, br) info = t.jpg_info(file) if ! info info = t.load_png(file) end r = Types::Rect.new(tl, br) ul, ll, lr = r.make_corners(t, (@auto_rotate == nil ? true : @auto_rotate), @aspect_ratio || :ignore, info['width']*1.0/info['height']) dict = info.dup dict.merge!('ul' => ul, 'll' => ll, 'lr' => lr) # @todo provide a way to reuse images ? t.context do if @transparency t.fill_opacity = 1 - @transparency end t.show_image(dict) end end |