Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- header("content-type:image/png");
- $w=1000;
- $h=1000;
- $im=imagecreatetruecolor($w,$h);
- $fundo=imagecolorallocate($im,240,240,240);
- $cinza=imagecolorallocate($im,200,200,200);
- $preto=imagecolorallocate($im,0,0,0);
- $vermelho=imagecolorallocate($im,255,0,0);
- imagefilledrectangle($im,0,0,$w,$h,$fundo);
- $xx=$w/100;
- $yy=$h/100;
- for($i=0;$i<=100;$i++){
- imageline($im,$xx*$i,0,$xx*$i,1000,$cinza);
- }
- for($i=0;$i<=100;$i++){
- imageline($im,0,$yy*$i,1000,$yy*$i,$cinza);
- }
- /*[prof]*/
- function f($x){
- return ($x*$x)-16;
- }
- $x0=-10;
- $xf=10;
- $u=20;
- $delta=1/$u;
- $p2x=$x0;
- $p2y=f($p2x);
- while($p2x<=$xf)
- {
- $p1x=$p2x;
- $p1y=$p2y;
- $p2x=$p1x+$delta;
- $p2y=f($p2x);
- imageline($im,($w/2)+$u*$p1x,($h/2)-$u*$p1y,($w/2)+$u*$p2x,($h/2)-$u*$p2y,$vermelho);
- }
- /*[\prof]*/
- imageline($im,0,$w/2,1000,$w/2,$preto);
- imageline($im,$h/2,0,$h/2,1000,$preto);
- imagepng($im);
- imagecolordeallocate($im,$fundo);
- imagedestroy($im);
- ?>
Add Comment
Please, Sign In to add comment