Title, a fill chart with a polygon draw is jagged. The Imageantialias function is not valid.
Bitmap aliasing is inevitable.
Imageantialias anti-aliasing is useful, you can compare the effect when he turns on and off
If you are not satisfied with the effect of Imageantialias (after all, GD is not a professional image processing package), then you have to solve your own programming
He's an scrambling cipher, and he's free to study.
It's so boring, and finally it's JS.
JS has ready-made plug-ins to do out of the very beautiful ... What do you do with PHP?
PHP Code
Create (Func_get_arc (0), Func_get_arc (1)); else $this->create (400,300); /** * Draw dots at ($x, $y) * * function pixel ($x, $y) {$p = $this->get_view ($x, $y); Imagesetpixel ($this->im, $p [' X '], $p [' Y '], $this->color); $this->xo = $p [' x ']; $this->yo = $p [' y ']; /** * Move to ($x, $y) */function MoveTo ($x, $y) {$p = $this->get_view ($x, $y); $this->xo = $p [' x ']; $this->yo = $p [' y ']; }/** * FROM ($x 1, $y 1) to ($x 2, $y 2) Draw line */function lines ($x 1, $y 1, $x 2, $y 2) {$p 1 = $this->get_view ($x 1, $y 1); $p 2 = $this->get_view ($x 2, $y 2); Imageline ($this->im, $p 1[' x '], $p 1[' y '], $p 2[' x '], $p 2[' y '), $this->color); /** * Draw line from current position to ($x, $y) * * Function LineTo ($x, $y) {$p = $this->get_view ($x, $y); Imageline ($this->im, $this->xo, $this->yo, $p [' X '], $p [' Y '], $this->color); $this->xo = $p [' x ']; $this->yo = $p [' y ']; }/** * Sets the current color */function color ($clr) {$r = ($clr >>16) & 0xFF; $g = ($CLR >>8) & 0xFF; $b = ($CLR) & 0xFF; $this->color = imagecolorallocate ($this->im, $r, $g, $b); $this->fillcolor = imagecolorallocate ($this->im, $r, $g, $b); $this->filldarkcolor = imagecolorallocate ($this->im, $r/2, $g/2, $b/2); return $this->color; }/** * Sets the current fill color */function FillColor ($clr) {$r = ($clr >>16) & 0xFF; $g = ($clr >>8) & 0xFF; $b = ($CLR) & 0xFF; $this->fillcolor = imagecolorallocate ($this->im, $r, $g, $b); return $this->fillcolor; /** * Create a GD handle and set the coordinate system */function Create ($x, $y) {$this->im = Imagecreatetruecolor ($x, $y); Imageantialias ($this- >im, 1); Imagefill ($this->im, 0, 0, $this->color (0XFFFFFF)); $this->viewx = $x-1; $this->viewy =-($y-1); $this->winx = $x; $this->winy = $y; $this->ORGX = 0; $this->orgy = 0;//$y; $this->colors = $this->color (0XFFFFFF); Settype ($this->ksin, "double"); Settype ($tHis->kcos, "double"); $this->ksin = sin (deg2rad (0)); $this->kcos = cos (deg2rad (0)); }/** * Coordinate mapping */function Get_view ($x, $y) {$this->xo = $x * $this->kcos-$y * $this->ksin; $this->yo = $x * $this->ksin + $y * $this->kcos; $p [' x '] = ($this->xo + $this->orgx) * ($this->viewx/$this->winx); $p [' y '] = ($this->yo + $this->orgy) * ($this->viewy/$this->winy)-$this->viewy; return $p; }/** * Set limit */function Set_ext ($x, $y =0) {$this->winx = $x; if ($y = = 0) {$this->winy =-$x * $this->viewy/$this->viewx; }else {$this->winy = $y; }}/** * Set rotation angle */function Set_r ($p) {$this->ksin = sin (Deg2rad ($p)); $this->kcos = cos (Deg2rad ($p)); }/** * Constructs graphics that must be overloaded in derived classes this method */function Paint () {/** * must be overloaded by derived classes * must contain statements $this->create (width, height); */Die ("The paint method must be overloaded by derived classes!"); }/** * Output graphics */function run () {$this->paint (); $func = "ImAge ". $this->type; if (! function_exists ($func)) {$this->type = "png"; $func = "Image". $this->type; } Header ("Content-type:image/{$this->type}"); $func ($this->im); Imagedestroy ($this->im); }/** * Round graph data generation, parameter $p coordinates rotation angle */function Get_point ($ox, $oy, $w, $h, $start, $end) {$a = $w/2; $b = $h/2; $rs = Array (); $i = $start; for ($i = $start; $i <= $end; $i +=5) {$n = Deg2rad ($i); $x = $a *cos ($n); $y = $b *sin ($n); $p = $this->get_view ($ox + $x, $oy + $y); $rs [] = $p [' x ']; $rs [] = $p [' y ']; if ($i = = $end) break; if ($i +5 > $end) $i = $end-5; } $p = $this->get_view ($ox, $oy); $rs [] = $p [' x ']; $rs [] = $p [' y ']; $rs [] = $rs [0]; $rs [] = $rs [1]; return $rs; /** * Bow */function chord ($left, $top, $w, $h, $start, $end, $z =0) {$ar = $this->get_point ($left, $top, $w, $h, $sta RT, $end, $p); for ($i =0; $i
Get_view ($ar [$i], $ar [$i +1]); $ar [$i] = $p [' x ']; $ar [$i +1] = $p [' y ']; } imagefilledpolygon ($this->im, $ar, Count ($ar)/2-1, $this->fillcolor); Imagepolygon ($this->im, $ar, Count ($ar)/2-1, $this->color); }/** * Fan */function Pie ($left, $top, $w, $h, $start, $end, $z =0) {$this->get_view ($left, $top + $z); $ar = $this->get_point ($left, $top + $z, $w, $h, $start, $end); $this->get_view ($left, $top); $arh = $this->get_point ($left, $top, $w, $h, $start, $end); for ($j =0; $j
Filltype) Imagefilledpolygon ($this->im, $t, 4, $this->filldarkcolor); else Imagepolygon ($this->im, $t, 4, $this->color); } if ($this->filltype) Imagefilledpolygon ($this->im, $ar, Count ($ar)/2-1, $this->fillcolor); }/** * Arc */function arc ($left, $top, $w, $h, $start, $end, $z =0) {$ar = $this->get_point ($left, $top, $w, $h, $start , $end, $p); $this->moveto ($ar [0], $ar [1]); for ($i =2; $i
LineTo ($ar [$i], $ar [$i +1]); }}/** * The Paint method of the overloaded base class */class Mygraph extends Graph {function paint () {//$this->create (400,300); $this->create (200,150), $this->set_ext (400); $this->set_r (10); Rotation $this->filltype = false; Filling $k = 40; High $a = 200; Center x $b = 150; Center y $c = 200; Long axis $d = 100; Short axis $this->color (0x000000); $this->color (0xff0000); $this->pie ($a, $b, $c, $d, 0,100, $k); $this->color (0X00FF00); $this->pie ($a, $b, $c, $d, 120,240, $k); $this->color (0X0000FF); $this->pie ($a +10, $b -10, $c, $d, 240,360, $k); $this->color (0X8080FF); $this->pie (50,80,40,20,0,360,50); $this->line ($a, 0, $a, $b *); $this->line (0, $b, $a * *, $b);
}} $g = new mygraph; $g->run ();