Sha256: e946af4faca7def49e65caac201388a36f187b23f8fc7716e162366e4153d709
Contents?: true
Size: 1.98 KB
Versions: 18
Compression:
Stored size: 1.98 KB
Contents
# Copyright 2016 Ryan Moore # Contact: moorer@udel.edu # # This file is part of Iroki. # # Iroki is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Iroki is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Iroki. If not, see <http://www.gnu.org/licenses/>. module Iroki module Color class SingleGroupGradient < Gradient attr_accessor :counts, :rel_abunds def initialize samples, counts, single_color=false abort_unless samples.count == counts.count, "Samples (#{samples.count}) and counts " + "#{counts.count} are different size." @single_color = single_color @samples = samples @counts = counts @rel_abunds = counts_to_rabunds counts @lumins = rabunds_to_lumins @rel_abunds if @single_color @color_hex_codes = single_color_gradient_hex_codes else @color_hex_codes = two_color_gradient_hex_codes end end def two_color_gradient_hex_codes @rel_abunds.map.with_index do |rel_abund, idx| lumin = @lumins[idx] col = Iroki::Color::GREEN.mix_with Iroki::Color::BLUE, rel_abund col.luminosity = lumin col.html end end def single_color_gradient_hex_codes @rel_abunds.zip(@lumins).map do |rel_abund, lumin| amt_of_orig_color = scale rel_abund, new_min=10, new_max=95 col = Iroki::Color::DARK_GREEN.lighten_by amt_of_orig_color col.html end end end end end
Version data entries
18 entries across 18 versions & 1 rubygems