Class: Shoes::Swt::Color

Inherits:
Object
  • Object
show all
Includes:
DisposedProtection
Defined in:
shoes-swt/lib/shoes/swt/color.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from DisposedProtection

#real

Constructor Details

#initialize(color) ⇒ Color

Returns a new instance of Color.

Parameters:

  • color (Shoes::Color)

    the DSL representation of this color



13
14
15
16
# File 'shoes-swt/lib/shoes/swt/color.rb', line 13

def initialize(color)
  @dsl = color
  @real = ::Swt::Graphics::Color.new(Shoes.display, @dsl.red, @dsl.green, @dsl.blue)
end

Instance Attribute Details

#dslObject (readonly)

Returns the value of attribute dsl.



22
23
24
# File 'shoes-swt/lib/shoes/swt/color.rb', line 22

def dsl
  @dsl
end

Class Method Details

.create(color) ⇒ Object



8
9
10
# File 'shoes-swt/lib/shoes/swt/color.rb', line 8

def self.create(color)
  color ? new(color) : NullColor.new
end

Instance Method Details

#alphaInteger

Returns the alpha value, from 0 (transparent) to 255 (opaque).

Returns:

  • (Integer)

    the alpha value, from 0 (transparent) to 255 (opaque)



25
26
27
# File 'shoes-swt/lib/shoes/swt/color.rb', line 25

def alpha
  @dsl.alpha
end

#apply_as_fill(gc, _dsl = nil) ⇒ Object

_dsl unused by this method, passed to satisfy the Pattern interface

Parameters:

  • gc (Swt::Graphics::GC)

    the graphics context on which to apply fill



31
32
33
34
# File 'shoes-swt/lib/shoes/swt/color.rb', line 31

def apply_as_fill(gc, _dsl = nil)
  gc.set_background real
  gc.set_alpha alpha
end

#apply_as_stroke(gc, _dsl = nil) ⇒ Object

_dsl unused by this method, passed to satisfy the Pattern interface

Parameters:

  • gc (Swt::Graphics::GC)

    the graphics context on which to apply stroke



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

def apply_as_stroke(gc, _dsl = nil)
  gc.set_foreground real
  gc.set_alpha alpha
end

#disposeObject



18
19
20
# File 'shoes-swt/lib/shoes/swt/color.rb', line 18

def dispose
  real.dispose
end