/** * * Make an array of colors complete with styles. The colors are arranged by hue families. * * @param int slices The number of families. 6-15 is probably good. * @param int trisize Proportional with the square root of the size of each family 4 to 6 is probably good. * @return array an array with the values at 'options' and styles in 'styles' */ function makeColorArrays($slices, $triSize) { $options = array(); $styles = array(); $options[''] = "Default"; $styles[''] = ""; for ($dark = 0; $dark <= $triSize; $dark++) { $goalDark = 255.99 * $dark / $triSize; $arr = GUIComponentUtility::addColor($goalDark, $goalDark, $goalDark); $val0 = $arr[0]; $val1 = $arr[1]; $options[$val0] = $val0; $styles[$val0] = $val1; } for ($rot = 0; $rot < $slices; $rot++) { $angle_R = $rot / $slices * 2 * M_PI + M_PI * 1 / 3; $angle_G = $rot / $slices * 2 * M_PI + M_PI * 5 / 3; $angle_B = $rot / $slices * 2 * M_PI + M_PI * 3 / 3; $baseR = 128 + 127.99 * sin($angle_R); $baseG = 128 + 127.99 * sin($angle_G); $baseB = 128 + 127.99 * sin($angle_B); for ($dark = $triSize; $dark > 0; $dark--) { $baseDarknessR = $baseR * $dark / $triSize; $baseDarknessG = $baseG * $dark / $triSize; $baseDarknessB = $baseB * $dark / $triSize; $goalDark = 255.99 * $dark / $triSize; for ($gray = 0; $gray < $dark; $gray++) { $actual_r = $baseDarknessR * ($dark - $gray) + $goalDark * $gray; $actual_g = $baseDarknessG * ($dark - $gray) + $goalDark * $gray; $actual_b = $baseDarknessB * ($dark - $gray) + $goalDark * $gray; $actual_r /= $dark; $actual_g /= $dark; $actual_b /= $dark; $arr = GUIComponentUtility::addColor($actual_r, $actual_g, $actual_b); $val0 = $arr[0]; $val1 = $arr[1]; $options[$val0] = $val0; $styles[$val0] = $val1; } } } //this hack takes care of the fact that I really want to return them both. $ret = array(); $ret['options'] = $options; $ret['styles'] = $styles; return $ret; }