Class: Shoes::Swt::Gradient

Inherits:
Object
  • Object
show all
Includes:
Common::Remove
Defined in:
shoes-swt/lib/shoes/swt/gradient.rb

Instance Method Summary collapse

Methods included from Common::Remove

#remove

Constructor Details

#initialize(dsl) ⇒ Gradient

Returns a new instance of Gradient.



19
20
21
22
23
24
# File 'shoes-swt/lib/shoes/swt/gradient.rb', line 19

def initialize(dsl)
  @dsl = dsl
  @patterns = []
  @color1 = nil
  @color2 = nil
end

Instance Method Details

#alphaObject



43
44
45
# File 'shoes-swt/lib/shoes/swt/gradient.rb', line 43

def alpha
  @dsl.alpha
end

#apply_as_fill(gc, dsl) ⇒ Object



47
48
49
50
# File 'shoes-swt/lib/shoes/swt/gradient.rb', line 47

def apply_as_fill(gc, dsl)
  pattern = create_pattern(dsl)
  gc.set_background_pattern pattern
end

#apply_as_stroke(gc, dsl) ⇒ Object



52
53
54
55
# File 'shoes-swt/lib/shoes/swt/gradient.rb', line 52

def apply_as_stroke(gc, dsl)
  pattern = create_pattern(dsl)
  gc.set_foreground_pattern pattern
end

#color1Object



35
36
37
# File 'shoes-swt/lib/shoes/swt/gradient.rb', line 35

def color1
  @color1 ||= Color.create @dsl.color1
end

#color2Object



39
40
41
# File 'shoes-swt/lib/shoes/swt/gradient.rb', line 39

def color2
  @color2 ||= Color.create @dsl.color2
end

#disposeObject



26
27
28
29
30
31
32
33
# File 'shoes-swt/lib/shoes/swt/gradient.rb', line 26

def dispose
  @color1&.dispose
  @color2&.dispose

  @patterns.each do |pattern|
    pattern.dispose unless pattern.disposed?
  end
end