Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function hextorgb ($hex) {
- $hex = str_replace("#", "", $hex);
- $return['r'] = hexdec(substr($hex, 0, 2));
- $return['g'] = hexdec(substr($hex, 2, 2));
- $return['b'] = hexdec(substr($hex, 4, 2));
- return $return;
- }
- function rgbtohex ($r, $g, $b) {
- return "#" . dechex($r) . dechex($g) . dechex($b);
- }
- $hex['from'] = '000000';
- $hex['to'] = 'FFFFFF';
- $ursprung = hextorgb($hex['from']);
- $ziel = hextorgb($hex['to']);
- $width = 5;
- $height = 5;
- $sum = ($width * $height);
- $calc['r'] = (($ziel['r'] - $ursprung['r']) / $sum);
- $calc['g'] = (($ziel['g'] - $ursprung['g']) / $sum);
- $calc['b'] = (($ziel['b'] - $ursprung['b']) / $sum);
- for ($i = 0; $i < $width; $i++) {
- for ($x = 0; $x < $height; $x++) {
- echo '<inline style="width:50px; height:50px; background:rgb(' . round(((($i * $width) + $x) * $calc['r']) + $ursprung['r']) . ',' . round(((($i * $width) + $x) * $calc['g']) + $ursprung['g']) . ',' . round(((($i * $width) + $x) * $calc['b']) + $ursprung['b']) . ')">' . $i . ' . ' . $x . '</inline>';
- }
- echo '<br />';
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement