lib/ctioga2/commands/doc/html.rb in ctioga2-0.13.1 vs lib/ctioga2/commands/doc/html.rb in ctioga2-0.14
- old
+ new
@@ -277,10 +277,94 @@
else
out.puts "No specific style information"
end
end
end
+ end
+ def write_color_list(colors, opts, out = STDOUT, color_names = nil)
+ columns = opts["columns"] || 5
+ cls = opts["class"] || "color-list"
+ div_cls = opts["div-class"]
+ rw = opts["rect-width"] || 80
+ rh = opts["rect-height"] || 40
+
+ div_common = (div_cls ? "class='#{div_cls}' style='" :
+ "style='width:#{rw};height:#{rh};")
+
+ out.puts "<table class='#{cls}'>"
+
+ idx = 0
+ for color in colors
+ if idx % columns == 0
+ if idx > 0
+ out.puts "</tr>"
+ end
+ out.puts "<tr>"
+ end
+ if color
+
+ cls = "##{Utils::color_to_html(color)}"
+
+ if color_names
+ c = color_names[idx]
+ else
+ c = Utils::color_name_by_value(color)
+ end
+ cb = if c
+ "#{c}<br/>"
+ else
+ ""
+ end
+
+ out.puts "<td><div #{div_common}background-color: #{cls};color: #{cls};'>#{cb}</div>#{cb}#{cls}</td>"
+ else
+ out.puts "<td>no color</td>"
+ end
+ idx += 1
+ end
+
+ out.puts "</tr></table>"
+
+ end
+
+ # Writes out a list
+ #
+ #@todo Split that to just write an ordered list of colors (get
+ #their names ?)
+ def write_colors(opts, out = STDOUT)
+ clrs = Tioga::ColorConstants::constants.sort
+ colors = clrs.map do |c|
+ Tioga::ColorConstants::const_get(c)
+ end
+ color_names = clrs.map do |c|
+ c.to_s
+ end
+
+ write_color_list(colors, opts, out, color_names)
+ end
+
+ def write_color_sets(opts, out = STDOUT)
+ sets = Graphics::Styles::CurveStyleFactory::parameters['color'].sets
+ set_names = sets.keys.sort
+
+ if opts['include']
+ set_names = set_names.select do |x|
+ x =~ opts['include']
+ end
+ elsif opts['exclude']
+ set_names = set_names.select do |x|
+ x !~ opts['exclude']
+ end
+ end
+
+ set_names = sets.keys.sort
+
+ for s in set_names
+ out.puts "<h5>Color set: <code>#{s}</code></h5>"
+ colors = sets[s]
+ write_color_list(colors, opts, out)
+ end
end
protected