Location: PHPKode > projects > PHP Cad and Drawing Program > functions/checker.inc
AAAAAAAAAAAAAAAAAAAAAAAAA
//
// Draws a checker pattern.  Use to draw bars, solid rectangles,
// and checker patterns.<br><br>
//
// $u,$v = <u>lower right corner</u>, $x,$y upper left corner.
// In the textbox enter, "acolor&bcolor&edgecolor" in hexadecimal
// For example <u>"123aef&112233&121111"</u> If you leave off
// one color parameter it will draw checker without the edge.
// If you use only one parameter, it will draw a solid
// rectangle.
//
function checker($image,$gridsize,$u,$v,$acolor,$bcolor,$edge,$scale,$x,$y)
{
    $scale=$scale/$gridsize;
    $x=$x*$gridsize;
    $y=$y*$gridsize;
    $u=$u*$gridsize;
    $v=$v*$gridsize;

    $red  = hexdec(substr($acolor,0,2));
    $grn  = hexdec(substr($acolor,2,2));
    $blu  = hexdec(substr($acolor,4,2));
    $a = ImageColorAllocate($image,$red,$grn,$blu);
    if ($bcolor != "") {
        $red  = hexdec(substr($bcolor,0,2));
        $grn  = hexdec(substr($bcolor,2,2));
        $blu  = hexdec(substr($bcolor,4,2));
    }
    $b = ImageColorAllocate($image,$red,$grn,$blu);
    if ($edge != "") {
         $red  = hexdec(substr($edge,0,2));
         $grn  = hexdec(substr($edge,2,2));
         $blu  = hexdec(substr($edge,4,2));
         $c= ImageColorAllocate($image,$red,$grn,$blu);
    }
    for($i=$x; $i<$u; ++$i) {
        for($j=$y; $j<$v; ++$j) {
            $color=$i+$j;
            if ($color % 2) {
                $color = $a;
            } else {
                $color = $b;
            }
            $xx=$i*$scale;
            $yy=$j*$scale;
            ImageFilledRectangle($image,$xx,$yy,$xx+$scale-1,$yy+$scale-1,$color);
            If ($edge != "") ImageRectangle($image,$xx,$yy,$xx+$scale,$yy+$scale,$c);
        }
    }
}
BBBBBBBBBBBBBBBBBBBBBBBBBBBB
if ($PObj=="checker") {
   $datacheck=0;
   if ($PLen > 5 or $PLen < .25) $datacheck=1;
   if ($xx > $a or $yy > $b) $datacheck=1;
   if ($u > $a or $v > $b) $datacheck=1;
   if ($xx != "" and $yy != "" and $u != "" and $v != "") {
        if ($xx > $u) {
            $sw = $u;
            $u = $xx;
            $xx = $sw;
        }
        if ($yy > $v) {
            $sw = $v;
            $v = $yy;
            $yy = $sw;
        }
       $color=array();
       $color=explode("&",$PTxt);
       for ($i = 0; $i < 3; $i++) {
            if (ereg("^[0-9a-fA-F]{6}$",$color[$i])) {
                $color[$i]=$color[$i];
            } else {
                $color[$i]="";
                if ($i=="0") $color[$i]="667799";
            }
        }
        $u=$u+1;
        $v=$v+1;
        $xp= "<?php " . $PObj . "($" . "image,";
        $xp .= "$PLen,$u,$v,";
        $xp .= '"' . $color[0] . '",';
        $xp .= '"' . $color[1] . '",';
        $xp .= '"' . $color[2] . '",';
        $xp .= '$scale,';
        $xp .=  $xx . ',' . $yy . "); ?>\n";
        if ($datacheck == "0") {
            $a=fopen("./files/$pfilez", "a");
            fwrite($a, $xp);
            fclose($a);
        }
    }
}
CCCCCCCCCCCCCCCCCCCCCCCC
function checker($image,$gridsize,$u,$v,$acolor,$bcolor,$edge,$scale,$x,$y){}
DDDDDDDDDDDDDDDDDDDDDDDD
$inthemenu = "yes";
$dirlist= array("NA");
$lenlist= array("1","2","3","4","5",".5",".333",".25");
$txtitem="AAAAAA&FFFF11&BBBBBB";
EEEEEEEEEEEEEEEEEEEEEEEEEEEEE
Return current item: PHP Cad and Drawing Program