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

141 lines
2.4 KiB
PHP

<?php
function drawline($w,$h,$pi,$pa,$pb,$tf) {
$c=0;
if ($w>$h) {
$l=$h;
$lw=$w/$h;
$lh=1;
}
else if ($h>$w) {
$l=$w;
$lw=1;
$lh=$h/$w;
}
else {
$l=$w;
$lw=1;
$lh=1;
}
if ($tf==false && $pi!="tr" && $pi!="br") {
$pb=$pb+$w-$lw;
}
if ($pi=="tr") {$divstyle="top:".$pa."px;right:".$pb."px";}
else if ($pi=="br") {$divstyle="bottom:".$pa."px;right:".$pb."px";}
else if ($pi=="bl") {$divstyle="bottom:".$pa."px;left:".$pb."px";}
else {$divstyle="top:".$pa."px;left:".$pb."px";}
while ($c<$l) {
if ($w>$h) {
$cc=$c*$w/$h;
}
else {
$cc=$c;
}
if ($tf==false) {$cc=$cc*-1;}
$fl.="<div style='width:".$lw."px;height:".$lh."px;margin-left:".$cc."px'></div>";
$c++;
}
return "<div style='".$divstyle."' class='wrapper'>".$fl."</div>";
}
function drawlines($s) {
$fr.=drawline($s,$s/2,"tl",$s/4,0,true);
$fr.=drawline($s,$s,"tl",0,0,true);
$fr.=drawline($s/2,$s,"tl",0,$s/4,true);
$fr.=drawline(1,$s,"tl",0,$s/2,true);
$fr.=drawline($s,1,"tl",$s/2,0,false);
$fr.=drawline($s,$s/2,"tl",$s/4,0,false);
$fr.=drawline($s,$s,"tl",0,0,false);
$fr.=drawline($s/2,$s,"tl",0,$s/4,false);
return $fr;
}
function drawlinewrappers($n,$s) {
$c=0;
while ($c<$n) {
$fr.="<div class='box' style='height:".$s."px;width:".$s."px'>".drawlines($s)."</div>\n";
$c++;
}
return $fr;
}
function dlwx($s,$n,$r) {
$c=0;
while ($c<$n) {
$fr.="<div class='box' style='height:".$s."px;width:".$s."px'>".drawlines($s)."</div>\n";
$s=$s+$r;
$c++;
}
return $fr;
}
function drawsimplecircle($s) {
$c=0;
while ($c<$s) {
if ($c!=0) {
if ($c>round($s/2)) {
$m=$c-$s/2;
}
else {
$m=($s/4)-sqrt(pow(($s/4)-$c,2));
$m=$m+($s/2-$c)/$c;
}
}
else {
$m=$s/2;
}
$fr.="<div style='margin-left:".$m."px'></div>";
$c++;
}
return $fr;
}
?><!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">
<head>
<title>LineMaker</title>
<style type='text/css'>
* {
margin:0;
padding:0;
}
div {
background-color:#000;
width:1px;
height:1px;
}
div.wrapper {
background-color:transparent;
position:absolute;
}
div.box {
background-color:transparent;
position:relative;
float:left;
}
</style>
</head>
<body>
<?php
//echo drawlinewrappers(48,50);
//echo drawlinewrappers(24,100);
//echo drawlinewrappers(12,200);
echo dlwx(10,41,1);
//echo drawsimplecircle(100);
?>
</body>
</html>