metanohi-misc-subsites/old-projects/x/gldnsctn.php

64 lines
1.4 KiB
PHP
Raw Normal View History

2011-08-02 19:57:57 +02:00
<?php
$w=$_GET["w"]*1;
$h=$_GET["h"]*1;
if ($w==0) $w=40;
if ($h==0) $h=30;
$iw=$w-(($w-(sqrt($w/2*$w/2+$w*$w)-$w/2))*2);
$pw=($w-$iw)/2;
$ih=$h-(($h-(sqrt($h/2*$h/2+$h*$h)-$h/2))*2);
$ph=($h-$ih)/2;
?>
<!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>Golden section</title>
<style type='text/css'>
body {
font:18px arial;
}
input {
width:30px;
}
#box {
width:<?php echo $w*10; ?>px;
height:<?php echo $h*10; ?>px;
border:1px solid #000;
position:relative;
margin-top:20px;
}
#sw {
width:<?php echo $iw*10; ?>px;
height:<?php echo $h*10; ?>px;
border:1px solid #000;
border-width:0 1px 0 1px;
position:absolute;
left:<?php echo $pw*10-1; ?>px;
}
#sh {
width:<?php echo $w*10; ?>px;
height:<?php echo $ih*10; ?>px;
border:1px solid #000;
border-width:1px 0 1px 0;
position:absolute;
top:<?php echo $ph*10-1; ?>px;
}
</style>
</head>
<body>
<form action='gldnsctn.php' method='get'>
Width: <input type='text' name='w' value='<?php echo $w; ?>' /><br />
Height: <input type='text' name='h' value='<?php echo $h; ?>' /><br />
<input type='submit' value='Submit' style='width:auto' />
</form>
<div id='box'>
<div id='sw'></div>
<div id='sh'></div>
</div>
</body>
</html>