Class Color::GrayScale
In: lib/color.rb
lib/color/grayscale.rb
Parent: Object

A colour object representing shades of grey. Used primarily in PDF document creation.

Methods

Constants

PDF_FORMAT_STR = "%.3f %s"   The format of a DeviceGrey colour for PDF. In color-tools 2.0 this will be removed from this package and added back as a modification by the PDF::Writer package.

Attributes

g  [RW] 

Public Class methods

Creates a greyscale colour object from fractional values 0..1.

  Color::GreyScale.from_fraction(0.5)

Creates a greyscale colour object from percentages 0..100.

  Color::GrayScale.new(50)

Public Instance methods

Compares the other colour to this one. The other colour will be converted to GreyScale before comparison, so the comparison between a GreyScale colour and a non-GreyScale colour will be approximate and based on the other colour‘s to_greyscale conversion. If there is no to_greyscale conversion, this will raise an exception. This will report that two GreyScale values are equivalent if they are within 1e-4 (0.0001) of each other.

Returns the brightness value for this greyscale value; this is the greyscale value.

Darken the RGB hue by the stated percent.

Present the colour as an HTML/CSS colour string.

Lightens the greyscale colour by the stated percent.

Present the colour as a DeviceGrey fill colour string for PDF. This will be removed from the default package in color-tools 2.0.

Present the colour as a DeviceGrey stroke colour string for PDF. This will be removed from the default package in color-tools 2.0.

Convert the greyscale colour to CMYK.

to_greyscale()

Alias for to_grayscale

Returns the HSL colour encoding of the greyscale value.

Convert the greyscale colour to RGB.

Returns the YIQ (NTSC) colour encoding of the greyscale value. This is an approximation, as the values for I and Q are calculated by treating the greyscale value as an RGB value. The Y (intensity or brightness) value is the same as the greyscale value.

[Validate]