Pages

Monday, 7 March 2011

Sem 2 PHP Gaphics

Ass 2 Q1

<?php
$in=imagecreate(500,500)or die("could not create");
$bc=imagecolorallocate($in,255,255,255);
$c=imagecolorallocate($in,255,2,2);
$c1=imagecolorallocate($in,255,255,2);
$c2=imagecolorallocate($in,255,2,255);
$c3=imagecolorallocate($in,2,255,255);
$a=array(400,60,350,120,450,120,400,60);
$a1=array(100,300,70,350,70,400,130,400,130,350,100,300);
$a2=array(350,300,300,350,350,400,400,400,450,350,400,300,350,300);
imagefilledpolygon($in,$a,4,$c);
imagefilledpolygon($in,$a1,6,$c1);
imagefilledpolygon($in,$a2,7,$c2);
imagefilledrectangle($in,50,60,120,120,$c3);

header("content-type:image/png");
imagepng($in);
?>
********************************************************************************
Circle.php

<?php
$i=imagecreate(800,800);
$col=imagecolorallocate($i,255,255,255);

$y=15;
$k=20;
for($j=0;$j<12;$j++)
{
 $r=70+$y;
 $b=10+$y;
 $g=30+$y;
 $c=imagecolorallocate($i,$r,$b,$g);
 imagefilledellipse($i,400,400,300-$k,300-$k,$c);
 $k=$k+20;
 $y=$y+15;
}

$ncol=imagecolorallocate($i,0,0,255);
imagestring($i,30,300,400,"welcome to mind game",$ncol);

header('content-type:image/jpeg');
imagejpeg($i);
imagedestroy($i);
?>
*******************************************************************************
// html file

<html>
<body>
<pre>
<form action="test.php" method="POST"> Create image
Width<input type="text" name="w">
Height<input type="text" name="h"><br>
Text color:<br>
Red:<input type="text" name="r">
Green:<input type="text" name="g">
Blue:<input type="text" name="b"><br>
Text string:<input type="text" name="t"><br>
X Co-ordinat:<input type="text" name="xc">
y Co-ordinat:<input type="text" name="yc"><br>
Shape<select name =shape>
<option>ellipse</option>
<option>rectangle</option>
</select><br>
<input type="submit" value="draw image"><br> </pre> </form>                                                                              </body> </html>


//php file

<?php
  $w=$_POST['w'];
 $h=$_POST['h'];
 $r=$_POST['r'];
 $g=$_POST['g'];
 $b=$_POST['b'];
 $t=$_POST['t'];
 $xc=$_POST['xc'];
 $yc=$_POST['yc'];
 $shape=$_POST['shape'];

 $i=imagecreate(500,500);
 $col=imagecolorallocate($i,255,255,255);
 header('content-type:image/jpeg');

 $ncol=imagecolorallocate($i,$r,$g,$b);
 imagestring($i,10,$xc,$yc,$t,$ncol);
 if($shape=="ellipse")
   imageellipse($i,$xc,$yc,$w,$h,$ncol);
 else
   imagerectangle($i,$xc,$yc,$w,$h,$ncol);
  imagejpeg($i);
  imagedestroy($i);
?>
***************************************************************************
image.php


<?php

<?php

 $i=imagecreatefromjpeg("php.jpeg");
 $x=imagesx($i);
 $y=imagesy($i);

 $icopy=imagecreate($x/4,$y/4);
 imagecopyresized($icopy,$i,0,0,0,0,$x/4,$y/4,$x,$y);

 header('content-type:image/jpeg');
 imagejpeg($icopy,"fe.jpeg");
 imagedestroy($icopy);
?>
?>



Q 4b)

<?php

 $i=imagecreatefromjpeg("fe.jpeg");
 $x=imagesx($i);
 $y=imagesy($i);

 $icopy=imagecreate(2*$x/4,2*$y/4);
 imagecopyresized($icopy,$i,0,0,0,0,2*$x/4,2*$y/4,$x,$y);

 header('content-type:image/jpeg');
 imagejpeg($icopy);
 imagedestroy($icopy);
?>
*********************************************************************************
Computer
<?php

 $i=imagecreate(500,500);
 $col=imagecolorallocate($i,255,255,255);
 $c=imagecolorallocate($i,0,0,0);
 imagerectangle($i,100,100,250,250,$c);
 imagerectangle($i,110,110,240,240,$c);
 imagerectangle($i,70,300,280,260,$c);
 $a=array(70,310,50,370,300,370,280,310,70,310);
 imagepolygon($i,$a,5,$c);
 imagesetthickness($i,5);
 imageline($i,70,320,280,320,$c);
 imageline($i,68,340,282,340,$c);
 imageline($i,64,360,286,360,$c);
 header('content-type:image/jpeg');
 imagejpeg($i,"comp.jpeg");
 imagedestroy($i);
?>
*****************************************************************************

SQUARE


<?
$in=imagecreate(500,500)or die("could not create");
$bc=imagecolorallocate($in,255,255,255);
$c=imagecolorallocate($in,0,0,0);
$c1=imagecolorallocate($in,255,255,255);
imagefilledrectangle($in,30,60,300,250,$c);
imagefilledrectangle($in,50,80,280,230,$c1);
imagefilledrectangle($in,70,100,260,210,$c);
imagefilledrectangle($in,90,120,240,180,$c1);
imagefilledrectangle($in,120,140,220,160,$c);
header("content-type:image/png");
imagepng($in);
?>
**************************************************************************

3 circles :


<?php
$i = imagecreate(200,200);
$col = imagecolorallocate($i,200,200,0);
$col = imagecolorallocate($i,0,0);
$x = 100;
$y = 100;
$w = 50;
$h = 50;
for($cnt = 0; $cnt < 3 ;$cnt ++ )
{
    $y = $y - 10 ;
    $w = $w + 20 ;
    $h = $h + 20;
    imageellipse($i , $x,  $y,  $h, $w, $lcol );
}
header(" content_type:image/jpeg ");
imagejpeg ( $i );
imagedestroy ( $i );
?>





10 comments:

  1. Thank you for allowing me to read it, welcome to the next in a recent article. And thanks for sharing the nice article, keep posting or updating news article.
    java training in chennai | java training in bangalore


    java training in tambaram | java training in velachery

    ReplyDelete
  2. This is most informative and also this post most user friendly and super navigation to all posts... Thank you so much for giving this information to me.. 

    Devops training in sholinganallur

    ReplyDelete
  3. Well done! Pleasant post! This truly helps me to discover the solutions for my inquiry. Trusting, that you will keep posting articles having heaps of valuable data. You're the best! 
    Blueprism training in Pune

    Blueprism training in Chennai

    ReplyDelete
  4. I wanted to thank you for this great read!! I definitely enjoying every little bit of it I have you bookmarked to check out new stuff you post.is article.

    angularjs Training in bangalore

    angularjs Training in btm

    angularjs Training in electronic-city

    angularjs online Training

    angularjs Training in marathahalli

    ReplyDelete
  5. Hello! Someone in my Facebook group shared this website with us, so I came to give it a look. I’m enjoying the information
    nebosh course in chennai

    ReplyDelete
  6. This is an awesome post.Really very informative and creative contents. These concept is a good way to enhance the knowledge.I like it and help me to development very well.Thank you for this brief explanation and very nice information.Well, got a good knowledge.

    devops online training

    aws online training

    data science with python online training

    data science online training

    rpa online training

    ReplyDelete
  7. I likable the posts and offbeat format you've got here! I’d wish many thanks for sharing your expertise and also the time it took to post!!
    Microsoft Azure online training
    Selenium online training
    Java online training
    Python online training
    uipath online training

    ReplyDelete
  8. thank you so much for this nice information Article, Digital marketing is tha good skill in grouth tha career For website creation, promotion and development contact here. For your digital marketing needs just have a look at Click Perfect.Automation Anywhere Training in Bangalore

    ReplyDelete