Class: Borealis

Inherits:
Object
  • Object
show all
Defined in:
lib/borealis.rb,
lib/borealis/color.rb,
lib/borealis/kmeans.rb,
lib/borealis/cluster.rb,
lib/borealis/version.rb,
lib/borealis/image_converter.rb

Defined Under Namespace

Classes: Cluster, Color, ImageConverter, KMeans

Constant Summary collapse

VERSION =
"0.0.2"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file, options = {}) ⇒ Borealis

Returns a new instance of Borealis.



10
11
12
13
14
# File 'lib/borealis.rb', line 10

def initialize(file, options = {})
  image_colors = ImageConverter.new(file, options[:size]).to_colors
  clusters = KMeans.new(image_colors, parse_options(options)).run
  @colors = clusters.map(&:center)
end

Instance Attribute Details

#colorsObject (readonly)

Returns the value of attribute colors.



8
9
10
# File 'lib/borealis.rb', line 8

def colors
  @colors
end

Instance Method Details

#hexesObject



16
17
18
# File 'lib/borealis.rb', line 16

def hexes
  @colors.map(&:hex)
end

#rgbsObject



20
21
22
# File 'lib/borealis.rb', line 20

def rgbs
  @colors.map(&:rgb)
end