Class: Tone

Inherits:
Object
  • Object
show all
Defined in:
lib/tone.rb

Overview

Note:

Setting gray to anything but 0 will increase processing time for color manipulation.

Color adjustments grouped into a single object. Tones consist of red, green, blue, and gray. Each color component uses a floating-point value and is restricted to the range -255 to 255. Gray, however, has the range of 0 to 255.

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Tone) initialize(red = 0, green = 0, blue = 0, gray = 0) - (Tone) initialize(red, green, blue, gray = 0)

Creates the tone object and sets the initial values.

Overloads:

  • - (Tone) initialize(red = 0, green = 0, blue = 0, gray = 0)

    Initializes all components (including gray) to 0.

  • - (Tone) initialize(red, green, blue, gray = 0)

    Initializes the color components to the specified values.

    Parameters:

    • red (Float)

      Value of the red component - -255 to 255.

    • green (Float)

      Value of the green component - -255 to 255.

    • blue (Float)

      Value of the blue component - -255 to 255.

    • gray (Float) (defaults to: 0)

      Value of the gray component - 0 to 255.



18
19
20
# File 'lib/tone.rb', line 18

def initialize(*args)
  fail NotImplementedError
end

Instance Attribute Details

- (Float) blue

Value of the blue component from -255 to 255. Out of range values are automatically corrected.

Returns:

  • (Float)


50
51
52
# File 'lib/tone.rb', line 50

def blue
  @blue
end

- (Float) gray

Value of the gray component from 0 to 255. Out of range values are automatically corrected.

Returns:

  • (Float)


55
56
57
# File 'lib/tone.rb', line 55

def gray
  @gray
end

- (Float) green

Value of the green component from -255 to 255. Out of range values are automatically corrected.

Returns:

  • (Float)


45
46
47
# File 'lib/tone.rb', line 45

def green
  @green
end

- (Float) red

Value of the red component from -255 to 255. Out of range values are automatically corrected.

Returns:

  • (Float)


40
41
42
# File 'lib/tone.rb', line 40

def red
  @red
end

Instance Method Details

- (self) set(red, green, blue, gray = 255) - (self) set(tone)

Sets all components at once.

Overloads:

  • - (self) set(red, green, blue, gray = 255)

    Sets all of the color components to the specified values.

    Parameters:

    • red (Float)

      Value of the red component - -255 to 255.

    • green (Float)

      Value of the green component - -255 to 255.

    • blue (Float)

      Value of the blue component - -255 to 255.

    • gray (Float) (defaults to: 255)

      Value of the gray component - 0 to 255.

  • - (self) set(tone)

    Copies the component values from another tone.

    Parameters:

    • tone (Tone)

      Tone to copy component values from.

Returns:

  • (self)


33
34
35
# File 'lib/tone.rb', line 33

def set(*args)
  fail NotImplementedError
end