Module: Sai::Conversion::RGB::ColorIndexer Private
- Defined in:
- lib/sai/conversion/rgb/color_indexer.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Color indexing utilities
Class Method Summary collapse
-
.color_cube(rgb) ⇒ Integer
private
Convert RGB values to 256-color cube index.
-
.grayscale(rgb) ⇒ Integer
private
Convert RGB values to grayscale index.
Class Method Details
.color_cube(rgb) ⇒ Integer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Convert RGB values to 256-color cube index
25 26 27 28 |
# File 'lib/sai/conversion/rgb/color_indexer.rb', line 25 def color_cube(rgb) r, g, b = rgb.map { |c| ((c / 255.0) * 5).round } #: [Integer, Integer, Integer] 16 + (r * 36) + (g * 6) + b end |
.grayscale(rgb) ⇒ Integer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Convert RGB values to grayscale index
41 42 43 |
# File 'lib/sai/conversion/rgb/color_indexer.rb', line 41 def grayscale(rgb) 232 + ((rgb[0] / 255.0) * 23).round end |