--- /dev/null
+#!/bin/bash
+# set -x
+
+#
+# functions
+usage () {
+ echo
+ echo "USAGE:"
+ echo " $0 <conf-file>"
+ echo
+ exit $1
+}
+
+
+if [ $# -lt 1 ]; then
+ usage 1
+fi
+
+finname="$1"
+
+if [ ! -f "$finname" ]; then
+ exit 2
+fi
+source "$finname"
+
+for gen_id in $(seq 0 $((${#gens_prefix[@]} - 1))); do
+ echo "// GENERATION ${gens_prefix[$gen_id]}"
+ names_n="$(echo "${gens_names[$gen_id]}" | sed 's/|/\n/g' | wc -l)"
+ for name_id in $(seq 0 $((names_n - 1))); do
+ hue="$(echo "($name_id * 255 ) / $names_n" | bc -l)"
+ col100="$(./rgb_hsv.php -toxrgb 255 $hue 255.0 255.0)"
+ col33="$(./rgb_hsv.php -toxrgb 255 $hue 85.0 255.0)"
+ col17="$(./rgb_hsv.php -toxrgb 255 $hue 42.0 255.0)"
+
+ name="$(echo "${gens_names[$gen_id]}" | cut -d '|' -f $((name_id + 1)))"
+ if [ $names_n -gt 1 ]; then
+ name="${gens_prefix[$gen_id]}_${name}"
+ else
+ name="${gens_prefix[$gen_id]}"
+ fi
+ echo "// [${name}][$col100][$col33][$col17]"
+cat <<EOF
+ subgraph cluster_${name} {
+ fontsize=18;
+ label="${name}";
+ fillcolor="#${col33}";
+ color="#${col100}";
+ style="rounded,filled";
+ node [shape=record, color="#${col100}", style=filled, fillcolor="#${col17}"];
+ ${name} [label="<1>aaa aaa|<2>bbb bbb|<3>ccc ccc|<4>ddd ddd|<5>eee eee"];
+ }
+EOF
+ done
+done
+
+for gen_id in $(seq 0 $((${#gens_prefix[@]} - 1))); do
+ echo "// GENERATION ${gens_prefix[$gen_id]}"
+ names_n="$(echo "${gens_names[$gen_id]}" | sed 's/|/\n/g' | wc -l)"
+ for name_id in $(seq 0 $((names_n - 1))); do
+ hue="$(echo "($name_id * 255 ) / $names_n" | bc -l)"
+ col100="$(./rgb_hsv.php -toxrgb 255 $hue 255.0 255.0)"
+
+ gnxt_id=$((gen_id + 1))
+ if [ "${gens_prefix[$gnxt_id]}" = "" ]; then
+ break
+ fi
+ gnxt_names_n="$(echo "${gens_names[$gnxt_id]}" | sed 's/|/\n/g' | wc -l)"
+
+ start=$((name_id % gnxt_names_n))
+ startp1=$(( ( name_id + 1) % gnxt_names_n))
+
+ ct=1
+ col="#$col100"
+ for gnxt_name_id in $start $startp1; do
+
+
+ name="$(echo "${gens_names[$gen_id]}" | cut -d '|' -f $((name_id + 1)))"
+ if [ $names_n -gt 1 ]; then
+ name="${gens_prefix[$gen_id]}_${name}"
+ else
+ name="${gens_prefix[$gen_id]}"
+ fi
+ gnxt_name="$(echo "${gens_names[$gnxt_id]}" | cut -d '|' -f $((gnxt_name_id + 1)))"
+ if [ $gnxt_names_n -gt 1 ]; then
+ gnxt_name="${gens_prefix[$gnxt_id]}_${gnxt_name}"
+ else
+ gnxt_name="${gens_prefix[$gnxt_id]}"
+ fi
+ echo "${name}:${ct} -> ${gnxt_name}:2 [lhead=\"cluster_${gnxt_name}\", color=\"${col}\"];"
+
+ ct=$((ct + 1))
+ col="black"
+ done
+ done
+done
+
+exit 0
+
--- /dev/null
+#!/usr/bin/php
+<?php
+function RGB_to_HSV ($norm, $R, $G, $B) // RGB Values:Number 0-255
+{ // HSV Results:Number 0-1
+ $HSL = array();
+
+ $var_R = ($R / $norm);
+ $var_G = ($G / $norm);
+ $var_B = ($B / $norm);
+
+ $var_Min = min($var_R, $var_G, $var_B);
+ $var_Max = max($var_R, $var_G, $var_B);
+ $del_Max = $var_Max - $var_Min;
+
+ $V = $var_Max;
+
+ if ($del_Max == 0)
+ {
+ $H = 0;
+ $S = 0;
+ }
+ else
+ {
+ $S = $del_Max / $var_Max;
+
+ $del_R = ( ( ( $var_Max - $var_R ) / 6 ) + ( $del_Max / 2 ) ) / $del_Max;
+ $del_G = ( ( ( $var_Max - $var_G ) / 6 ) + ( $del_Max / 2 ) ) / $del_Max;
+ $del_B = ( ( ( $var_Max - $var_B ) / 6 ) + ( $del_Max / 2 ) ) / $del_Max;
+
+ if ($var_R == $var_Max) $H = $del_B - $del_G;
+ else if ($var_G == $var_Max) $H = ( 1 / 3 ) + $del_R - $del_B;
+ else if ($var_B == $var_Max) $H = ( 2 / 3 ) + $del_G - $del_R;
+
+ if ($H<0) $H++;
+ if ($H>1) $H--;
+ }
+
+ $HSL = array($H * $norm, $S * $norm, $V * $norm);
+
+ return $HSL;
+}
+
+function HSV_to_RGB($norm, $H, $S, $V) {
+ $H /= $norm;
+ $S /= $norm;
+ $V /= $norm;
+ //1
+ $H *= 6;
+ //2
+ $I = floor($H);
+ $F = $H - $I;
+ //3
+ $M = $V * (1 - $S);
+ $N = $V * (1 - $S * $F);
+ $K = $V * (1 - $S * (1 - $F));
+ //4
+ switch ($I) {
+ case 0:
+ list($R,$G,$B) = array($V,$K,$M);
+ break;
+ case 1:
+ list($R,$G,$B) = array($N,$V,$M);
+ break;
+ case 2:
+ list($R,$G,$B) = array($M,$V,$K);
+ break;
+ case 3:
+ list($R,$G,$B) = array($M,$N,$V);
+ break;
+ case 4:
+ list($R,$G,$B) = array($K,$M,$V);
+ break;
+ case 5:
+ case 6: //for when $H=1 is given
+ list($R,$G,$B) = array($V,$M,$N);
+ break;
+ }
+ return array($R * $norm, $G * $norm, $B * $norm);
+}
+
+function main()
+{
+ GLOBAL $argv;
+
+ if ($argv[1] == "-tohsv" || $argv[1] == "-toxhsv") {
+ $a = RGB_to_HSV($argv[2], $argv[3], $argv[4], $argv[5]);
+ if ($argv[1] == "-tohsv") {
+ printf("%f,%f,%f\n", $a[0], $a[1], $a[2]);
+ }
+ else {
+ printf("%02x%02x%02x\n", (int)$a[0], (int)$a[1], (int)$a[2]);
+ }
+ }
+
+ if ($argv[1] == "-torgb" || $argv[1] == "-toxrgb") {
+ $a = HSV_to_RGB($argv[2], $argv[3], $argv[4], $argv[5]);
+ if ($argv[1] == "-torgb") {
+ printf("%f,%f,%f\n", $a[0], $a[1], $a[2]);
+ }
+ else {
+ printf("%02x%02x%02x\n", (int)$a[0], (int)$a[1], (int)$a[2]);
+ }
+ }
+}
+
+main();
+
+?>
\ No newline at end of file