Class: SkippyLib::Color

Inherits:
Sketchup::Color
  • Object
show all
Defined in:
modules/color.rb

Overview

Since:

  • 3.0.0

Instance Method Summary collapse

Instance Method Details

#grayscale?Boolean

Returns:

  • (Boolean)

Since:

  • 3.0.0



22
23
24
# File 'modules/color.rb', line 22

def grayscale?
  red == green && green == blue
end

#luminanceInteger

Returns Value between 0 - 255.

Returns:

  • (Integer)

    Value between 0 - 255

Since:

  • 3.0.0



28
29
30
31
32
33
34
35
36
# File 'modules/color.rb', line 28

def luminance
  # Colorimetric conversion to grayscale.
  # Original:
  # http://forums.sketchucation.com/viewtopic.php?t=12368#p88865
  # (red * 0.3) + (green * 0.59) + (blue * 0.11)
  # Current: https://stackoverflow.com/a/596243/486990
  #  => https://www.w3.org/TR/AERT/#color-contrast
  ((red * 299) + (green * 587) + (blue * 114)) / 1000
end