metanohi-misc-subsites/projects/x/txtcolor.php

67 lines
1.0 KiB
PHP
Raw Normal View History

2011-08-02 19:57:57 +02:00
<?php
$title="Google";
$tlen=strlen($title);
if ($tlen<6) {
$title.="abcdef";
$tlen=$tlen+6;
}
$c=0;
while ($c<$tlen) {
$t.=ord(substr($title,$c,1));
$c++;
}
$r=$t*1;
$g=strrev($t)*1;
if ($r>$g) {
$b=$r-$g;
}
else {
$b=$g-$r;
}
$ct=0;
while (strlen($t)>10) {
$ntlen=strlen($t);
$c=0;
while ($c<$ntlen) {
$gt=substr($t,$c-1,1)*1;
$nt=substr($t,$c,1)*1;
/*
if ($gt>$nt) {
$res=$gt-$nt;
}
else {
$res=$nt-$gt;
}
*/
$ft.=$gt-$nt;
$c++;
}
$t=substr($ft,0,1).str_replace("-","",str_replace("0","",substr($ft,1,strlen($ft)-1)));
$ft="";
$ct++;
}
$ro=255-$r;
$go=255-$g;
$bo=255-$b;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3c.org/1999/xhtml" xml:lang="da">
<head>
<title>txtColor</title>
<style type='text/css'>
body {
background:rgb(<?php echo $r.",".$g.",".$b; ?>);
color:rgb(<?php echo $ro.",".$go.",".$bo; ?>);
}
</style>
</head>
<body>
<?php echo $t; ?>
</body>
</html>