Location: PHPKode > projects > PHP Cad and Drawing Program > functions/curve.inc
AAAAAAAAAAAAAAAAAAAAAAAAA
//
//    Draw a stylish 90 degree curved wall.
//    $direction = <u>"LU"</u>,<u>"LD"</u>,<u>"RU"</u>,<u>"RD"</u>
//     - Left Right Up Down.  $radius = <u>"1-12"</u> curvature
//
function curve($image, $radius, $direction, $scale, $x, $y)
{
    $padobe=ImageColorAllocate($image,100,100,100);
    $edge=ImageColorAllocate($image,160,160,151);
    $x=$x*$scale;
    $y=$y*$scale;
    $radius=$radius*$scale+1;
    if ($direction == "RU") {
        $y=$y-$radius+$scale+1;
        ImageArc($image,$x,$y,$radius*2,$radius*2,0,90,$edge);
        ImageArc($image,$x,$y,($radius-$scale)*2,($radius-$scale)*2,0,90,$edge);
        ImageLine($image,$x,$y+$radius,$x,$y+$radius-$scale,$edge);
        ImageLine($image,$x+$radius,$y,$x+$radius-$scale,$y,$edge);
        ImageFilltoBorder($image,$x+1,$y+$radius-($scale/2),$edge,$padobe);
    }
    if ($direction == "RD") {
        $y=$y+$radius-1;
        ImageArc($image,$x,$y,$radius*2,$radius*2,270,360,$edge);
        ImageArc($image,$x,$y,($radius-$scale)*2,($radius-$scale)*2,270,360,$edge);
        ImageLine($image,$x,$y-$radius+$scale,$x,$y-$radius,$edge);
        ImageLine($image,$x+$radius,$y,$x+$radius-$scale,$y,$edge);
        ImageFilltoBorder($image,$x+1,$y-$radius+($scale/2),$edge,$padobe);
    }
    if ($direction == "LU") {
        $y=$y-$radius+$scale+1;
        $x=$x+$scale;
        ImageArc($image,$x,$y,$radius*2,$radius*2,90,180,$edge);
        ImageArc($image,$x,$y,($radius-$scale)*2,($radius-$scale)*2,90,180,$edge);
        ImageLine($image,$x,$y+$radius,$x,$y+$radius-$scale,$edge);
        ImageLine($image,$x-$radius,$y,$x-$radius+$scale,$y,$edge);
        ImageFilltoBorder($image,$x-1,$y+$radius-$scale,$edge,$padobe);
    }
    if ($direction == "LD") {
        $y=$y+$radius-1;
        $x=$x+$scale;
        ImageArc($image,$x,$y,$radius*2,$radius*2,180,270,$edge);
        ImageArc($image,$x,$y,($radius-$scale)*2,($radius-$scale)*2,180,270,$edge);
        ImageLine($image,$x,$y-$radius+$scale,$x,$y-$radius,$edge);
        ImageLine($image,$x-$radius,$y,$x-$radius+$scale,$y,$edge);
        ImageFilltoBorder($image,$x-1,$y-$radius+($scale/2),$edge,$padobe);
    }
}
BBBBBBBBBBBBBBBBBBBBBBBBBBBB
if ($PObj=="curve") {
    $a=fopen("./files/$pfilez", "a");
    $xp= "<?php " . $PObj . "($" . "image,";
    $xp .=  $PLen . ',"' . $PDir . '",';
    $xp .= '$scale,';
    $xp .=  $xx . "," . $yy . "); ?>\n";
    fwrite($a, $xp);
    fclose($a);
}
CCCCCCCCCCCCCCCCCCCCCCCC
function curve($image,$radius,$direction,$scale,$x,$y)
{
global $floor;
global $twall;
global $tfoundation;
global $troof;
global $zz;
//corrections
if ( $direction == "LD") {$y=$y+$radius; $x=$x+1;}
if ( $direction == "LU") {$y=$y-$radius+1; $x=$x+1;}
if ( $direction == "RD") $y=$y+$radius;
if ( $direction == "RU") $y=$y-$radius+1;

$ot = "\nintersection{
difference{
cylinder {";
fwrite($zz,$ot);

$a = "<" . $x;
$a .= "," . (1+$floor) . ",";
$a .=  $y ;
$a .= ">,<";
$a .= $x;
$a .= "," . (9+$floor) . ",";
$a .= $y . ">,";
fwrite($zz,$a);

$ot=   $radius .   " open $twall}
cylinder {";
fwrite($zz,$ot);

$a = "<" .$x;
$a .= "," . (1+$floor) . "," . $y ;
$a .= ">,<";
$a .= $x;
$a .= "," . (9+$floor) . ",";
$a .= $y . ">," ;
fwrite($zz,$a);
if ($radius==1) $zzz=.1;   //fudge factor for 1 radius curves
$a= $radius-1+$zzz .   " open $twall}}\n";
fwrite($zz,$a);
if ( $direction == "LD") { $b=-1;  $c=-1; }
if ( $direction == "LU") { $b=-1;  $c=1;}
if ( $direction == "RD") { $b=1; $c=-1; }
if ( $direction == "RU") { $b=1; $c=1; }
fwrite($zz,"box {");
$a = "<";
$a .= $x+($radius*$b);
$a .=  "," . (1+$floor) . ",";
$a .= $y+($radius*$c);
$a .= ">,<";
$a .= $x;
$a .= "," . (9+$floor) . ",";
$a .= $y . ">} }\n" ;
fwrite($zz,$a);


//to draw wood-rock foundation
$ot=
"intersection{
difference{
cylinder {";
fwrite($zz,$ot);

$a = "<" . $x;
$a .=  "," . $floor . ",";
$a .=  $y ;
$a .= ">,<";
$a .= $x;
$a .= "," . (1+$floor) . ",";
$a .= $y . ">,";
fwrite($zz,$a);
$ot=   $radius .   " open $tfoundation}
cylinder {";
fwrite($zz,$ot);
$a = "<" .$x;
$a .=  "," . $floor . "," . $y ;
$a .= ">,<";
$a .= $x;
$a .= "," . (1+$floor) . ",";
$a .= $y . ">," ;
fwrite($zz,$a);
$ot=   $radius-1+$zzz .   " open $tfoundation} }\n";
fwrite($zz,$ot);
if ( $direction == "LD") { $b=-1; $c=-1; }
if ( $direction == "LU") { $b=-1; $c=1; }
if ( $direction == "RD") { $b=1; $c=-1; }
if ( $direction == "RU") { $b=1; $c=1; }
fwrite($zz,"box {");
$a = "<";
$a .= $x+($radius*$b);
$a .=  "," . $floor . ",";
$a .= $y+($radius*$c);
$a .= ">,<";
$a .= $x;
$a .= "," . ($floor+1) . ",";
$a .= $y . ">} }\n" ;
fwrite($zz,$a);
}
DDDDDDDDDDDDDDDDDDDDDDDD
$inthemenu = "yes";
$dirlist= array("LD","LU","RD","RU");
$lenlist= array("1","2","3","4","5","6","7","8","9","10","11");
$txtitem="";
EEEEEEEEEEEEEEEEEEEEEEEEEEEEE
Return current item: PHP Cad and Drawing Program