From: Matteo Nastasi (mop) Date: Mon, 2 Sep 2013 05:44:49 +0000 (+0200) Subject: girones.sh script added X-Git-Tag: v4.10.0~2 X-Git-Url: https://mop.ddnsfree.com/gitweb/?p=brisk.git;a=commitdiff_plain;h=a7c27731c76675c8b96af91501dba188ba4c506f girones.sh script added --- diff --git a/bin/girones.sh b/bin/girones.sh new file mode 100755 index 0000000..cc16e44 --- /dev/null +++ b/bin/girones.sh @@ -0,0 +1,98 @@ +#!/bin/bash +# set -x + +# +# functions +usage () { + echo + echo "USAGE:" + echo " $0 " + 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 < ${gnxt_name}:2 [lhead=\"cluster_${gnxt_name}\", color=\"${col}\"];" + + ct=$((ct + 1)) + col="black" + done + done +done + +exit 0 + diff --git a/bin/rgb_hsv.php b/bin/rgb_hsv.php new file mode 100755 index 0000000..d081972 --- /dev/null +++ b/bin/rgb_hsv.php @@ -0,0 +1,108 @@ +#!/usr/bin/php +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 diff --git a/data/champions.conf b/data/champions.conf new file mode 100644 index 0000000..4baac92 --- /dev/null +++ b/data/champions.conf @@ -0,0 +1,2 @@ +declare -a gens_prefix=("girone" "quarto" "semi" "finale") +declare -a gens_names=("a|b|c|d|e|f|g|h|i|l" "q1|q2|q3|q4" "s1|s2" "") diff --git a/data/insieme_per_gioco.conf b/data/insieme_per_gioco.conf new file mode 100644 index 0000000..0d13eaf --- /dev/null +++ b/data/insieme_per_gioco.conf @@ -0,0 +1,2 @@ +declare -a gens_prefix=("pregirone" "girone" "ottavo" "quarto" "semi" "finale") +declare -a gens_names=("p1|p2|p3|p4|p5|p6|p7|p8|p9" "a1|a2|a3|a4|a5|a6|a7|a8" "b1|b2|b3|b4|b5|b6" "c1|c2|c3|c4" "d1|d2" "")