Class: Shoes::Swt::ImagePattern
- Inherits:
-
Object
- Object
- Shoes::Swt::ImagePattern
- Includes:
- Common::ImageHandling, Common::Remove
- Defined in:
- shoes-swt/lib/shoes/swt/image_pattern.rb
Instance Method Summary collapse
- #apply_as_fill(gc, _dsl) ⇒ Object
- #apply_as_stroke(gc, _dsl) ⇒ Object
- #dispose ⇒ Object
-
#initialize(dsl) ⇒ ImagePattern
constructor
A new instance of ImagePattern.
-
#pattern ⇒ Object
Since colors are bound up (at least in specs) with image patterns, we can’t safely touch images during initialize, so lazily load them.
Methods included from Common::ImageHandling
#cleanup_temporary_files, #load_file_image_data
Methods included from Common::Remove
#dispose_held_resources, #remove
Constructor Details
#initialize(dsl) ⇒ ImagePattern
Returns a new instance of ImagePattern.
9 10 11 |
# File 'shoes-swt/lib/shoes/swt/image_pattern.rb', line 9 def initialize(dsl) @dsl = dsl end |
Instance Method Details
#apply_as_fill(gc, _dsl) ⇒ Object
28 29 30 |
# File 'shoes-swt/lib/shoes/swt/image_pattern.rb', line 28 def apply_as_fill(gc, _dsl) gc.set_background_pattern pattern end |
#apply_as_stroke(gc, _dsl) ⇒ Object
32 33 34 |
# File 'shoes-swt/lib/shoes/swt/image_pattern.rb', line 32 def apply_as_stroke(gc, _dsl) gc.set_foreground_pattern pattern end |
#dispose ⇒ Object
13 14 15 16 |
# File 'shoes-swt/lib/shoes/swt/image_pattern.rb', line 13 def dispose @image&.dispose @pattern&.dispose end |
#pattern ⇒ Object
Since colors are bound up (at least in specs) with image patterns, we can’t safely touch images during initialize, so lazily load them.
20 21 22 23 24 25 26 |
# File 'shoes-swt/lib/shoes/swt/image_pattern.rb', line 20 def pattern @image ||= ::Swt::Image.new(Shoes.display, load_file_image_data(@dsl.path)) @pattern ||= ::Swt::Pattern.new(Shoes.display, @image) cleanup_temporary_files @pattern end |