127, "blue" => 0, "green" => 0 ); // rule #3: tracked things have an importance, lower is more important $LIST_OF_DATATYPES = array( "radon", "humidity", "pressure", "dust", "temperature" ); $sensorCount = count($LIST_OF_SENSORS); $datatypeCount = count($LIST_OF_DATATYPES); header("Content-Type: application: xhtml+xml"); $test = new Paint(); // light gray for mixing (gray would be 0x808080) $lightGray = new Pixel(0xD3, 0xD3, 0xD3); // generate an gradient between red and yellow, use flags to make colors more distinct $redToYellow = Pixel::generatePixelLine( new Pixel(/* red */ 255,0,0), new Pixel(/* yellow */ 255,255,0), array(/* options */ "total" => $sensorCount, "flags" => PIXEL_ALTERNATE | PIXEL_ADD | PIXEL_BLUE, "bias" => 0.35 ) ); $justGreen = new Pixel(/* green */ 0,255,0); $someGreenThatILike = Pixel::mix($justGreen, new Pixel(/* blue */ 0,32,192)); // generate starting colors, I like green, use flags to make colors really distinct $blueToGreen = Pixel::generatePixelLine( $someGreenThatILike, $justGreen, array(/* options */ "total" => $sensorCount, "flags" => PIXEL_ALTERNATE | PIXEL_ADD | PIXEL_BLUE, "bias" => 0.5 ) ); $radius = 20; $cursor = new Coord(0,0); // generate palette based on starting options for($i=$sensorCount;$i--;) { // save the cursor's vertical position (technically we know it is zero, but whatever) $vertical = $cursor->y; // mix the starting and ending color in equal parts $mixture = Pixel::mix($blueToGreen[$i], $redToYellow[$i]); // mix this color with light gray with a 1:2 ratio $mixture = Pixel::mix($mixture, $lightGray, 1/3, 2/3); // for fun, make mixture fade into background $mixture->setAlpha(0.3); // but then have it fade back in, cool and fun! $redToYellow[$i]->setAlpha(0.65); // generate the first half of colors from start to this mixture, increase fade $startToMixture = Pixel::generatePixelLine( $blueToGreen[$i], $mixture, array(/* options */ "total" => (int) round($sensorCount / 2, 0, PHP_ROUND_HALF_UP), "flags" => PIXEL_SUB | PIXEL_ALPHA, "bias" => /* increase rate of fade towards mixture */ 0.25 ) ); // generate the second half of colors from this mixture to end $mixtureToEnd = Pixel::generatePixelLine( $mixture, $redToYellow[$i], array(/* options */ "total" => (int) 1 + round($sensorCount / 2, 0, PHP_ROUND_HALF_DOWN) ) ); // last pixel in the first half is same as the first in second, remove it array_pop($startToMixture); // draw all the pretty colors for this sensor $mixed = array_merge($startToMixture, $mixtureToEnd); foreach($mixed as $pixel) { $test->addCircle(new Coord($cursor->x, $cursor->y), $pixel, $radius); // move the cursor down $cursor->y += ($radius * 2); } // move the cursor to the right $cursor->x += ($radius * 2); // restore the cursor's vertical position $cursor->y = $vertical; } echo $test;