class GraphColorLibrary
Used for auto color grabber
Constants
- ADDITIONAL_COLORS
other random picked up, SVG need #RGB and I'm too lazy :]
- BASIC_COLORS
rock solid colors www.imagemagick.org/script/color.php
- FAIL_COLOR
- MAX_INTENSITY
not too bright
Public Class Methods
new()
click to toggle source
# File lib/technical_graph/graph_color_library.rb, line 44 def initialize reset end
Public Instance Methods
get_color()
click to toggle source
# File lib/technical_graph/graph_color_library.rb, line 65 def get_color color = @colors.shift #return FAIL_COLOR if color.nil? # better, create random colors just in time return random_color if color.nil? return color end
random_color()
click to toggle source
Best solution, create random color JIT
# File lib/technical_graph/graph_color_library.rb, line 57 def random_color str = "#" 3.times do str += colour = "%02x" % (rand * MAX_INTENSITY) end return str end
reset()
click to toggle source
Reset color bank
# File lib/technical_graph/graph_color_library.rb, line 49 def reset @colors = BASIC_COLORS + ADDITIONAL_COLORS.sort { rand } end