php - Fill the gradient colour in my custom shape polygon jpgraph -


i working jpgraph , creating radar chart.

facing issue fill custom shape polygon gradient colour.

i have function fill gradient colour polygon flat bottom , want fill gradient colour in custom shape polygon. can me? how can this?

current output:

enter image description here

desired output:

enter image description here

you can find gradient class @ here.

http://code.google.com/r/linksoftafrica-maison-george/source/browse/libs/jpgraph/jpgraph_gradient.php

// fill special case of polygon flat bottom // gradient. can used filled line plots. // please note not generic gradient polygon fill // routine. assumes bottom flat (like drawing // of mountain) function filledflatpolygon($pts,$from_color,$to_color) {     if( count($pts) == 0 ) return;      $maxy=$pts[1];     $miny=$pts[1];               $n = count($pts) ;     for( $i=0, $idx=0; $i < $n; $i += 2) {         $x = round($pts[$i]);         $y = round($pts[$i+1]);         $miny = min($miny,$y);         $maxy = max($maxy,$y);     }      $colors = array();     $this->getcolarray($from_color,$to_color,abs($maxy-$miny)+1,$colors,$this->numcolors);     for($i=$miny, $idx=0; $i <= $maxy; ++$i ) {         $colmap[$i] = $colors[$idx++];      }      $n = count($pts)/2 ;     $idx = 0 ;     while( $idx < $n-1 ) {         $p1 = array(round($pts[$idx*2]),round($pts[$idx*2+1]));         $p2 = array(round($pts[++$idx*2]),round($pts[$idx*2+1]));          // find largest rectangle can fill         $y = max($p1[1],$p2[1]) ;         for($yy=$maxy; $yy > $y; --$yy) {             $this->img->current_color = $colmap[$yy];             $this->img->line($p1[0],$yy,$p2[0]-1,$yy);         }          if( $p1[1] == $p2[1] ) continue;           // fill rest using lines (slow...)         $slope = ($p2[0]-$p1[0])/($p1[1]-$p2[1]);         $x1 = $p1[0];         $x2 = $p2[0]-1;         $start = $y;         if( $p1[1] > $p2[1] ) {             while( $y >= $p2[1] ) {                 $x1=$slope*($start-$y)+$p1[0];                 $this->img->current_color = $colmap[$y];                 $this->img->line($x1,$y,$x2,$y);                 --$y;             }          }         else {             while( $y >= $p1[1] ) {                 $x2=$p2[0]+$slope*($start-$y);                 $this->img->current_color = $colmap[$y];                 $this->img->line($x1,$y,$x2,$y);                 --$y;             }          }     } } 

it looks me current code not suitable task. need code gouraud shaded triangles (3-sided polygons).

when have code that, draw 3 triangles on point of triangle in center of graph , 2 points on radar axles.

unfortunately, didn't find ready-made code jpgraph.


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -