function getcolorat($x, $y, $dist) { global $radius; $x_ = $x - $radius; $y_ = $y - $radius; // always use atan2, returns up to 360 degs $h = atan2($x_, $y_); $h /= 2 * pi(); $s = 1; $l = $dist / $radius; $c = Color::fromHSL($h, $s, $l); return $c; }
} ?> <p> <code><strong>Varying Lightness</strong> // Hue = 2/3, Saturation = 1.0</code> </p> <?php $s = 1; $h = 2 / 3.0; for ($i = 0; $i <= 100; $i++) { $l = $i / 100.0; $hex = Color::fromHSL($h, $s, $l)->toHexString(); echo "<b style='background:{$hex}'></b>"; } ?> <br /> <?php for ($i = 0; $i <= 100; $i++) { $s = 1; $h = 2 / 3.0; $l = $i / 100.0; $hex = Color::fromHSL($h, $s, $l)->toHexString(); $rgb = Color::fromHexString($hex); list($h, $s, $l) = $rgb->toHSL(); Color::fromHSL($h, $s, $l)->toHexString(); echo "<b style='background:{$hex}'></b>"; } ?> </body>