iColors = array_keys($rgb->rgb_table); usort($this->iColors,'_cmp'); $this->iGradstyles = array( "Vertical",2, "Horizontal",1, "Vertical from middle",3, "Horizontal from middle",4, "Horizontal wider middle",6, "Vertical wider middle",7, "Rectangle",5 ); } function Run() { echo '

Generate gradient background

'; echo '
'; echo ''; echo "\n"; echo ''; echo "\n"; echo ''; echo ''; echo ''; echo ''; echo '
Width:
'.$this->GenHTMLInput('w',8,4,300).'
Height:
'.$this->GenHTMLInput('h',8,4,300).'
From Color:
'; echo $this->GenHTMLSelect('fc',$this->iColors); echo '
To Color:
'; echo $this->GenHTMLSelect('tc',$this->iColors); echo '
Gradient style:
'; echo $this->GenHTMLSelectCode('s',$this->iGradstyles); echo '
Filename: (empty to stream)
'; echo $this->GenHTMLInput('fn',55,100); echo '
'.$this->GenHTMLSubmit('submit').'
'; echo '
'; } function GenHTMLSubmit($name) { return ''; } function GenHTMLInput($name,$len,$maxlen=100,$val='') { return ''; } function GenHTMLSelect($name,$option,$selected="",$size=0) { $txt="\n"; } function GenHTMLSelectCode($name,$option,$selected="",$size=0) { $txt="\n"; } } // Basic application driver class Driver { var $iGraph, $iGrad; var $iWidth,$iHeight; var $iFromColor, $iToColor; var $iStyle; var $iForm; function Driver() { $this->iForm = new Form(); } function GenGradImage() { $aWidth = (int)@$_POST['w']; $aHeight = (int)@$_POST['h']; $aFrom = @$_POST['fc']; $aTo = @$_POST['tc']; $aStyle = @$_POST['s']; $aFileName = @$_POST['fn']; $this->iWidth = $aWidth; $this->iHeight = $aHeight; $this->iFromColor = $aFrom; $this->iToColor = $aTo; $this->iStyle = $aStyle; $this->graph = new CanvasGraph($aWidth,$aHeight); $this->grad = new Gradient($this->graph->img); $this->grad->FilledRectangle(0,0, $this->iWidth,$this->iHeight, $this->iFromColor, $this->iToColor, $this->iStyle); if( $aFileName != "" ) { $this->graph->Stroke($aFileName); echo "Image file '$aFileName' created."; } else $this->graph->Stroke(); } function Run() { global $HTTP_POST_VARS; // Two modes: // 1) If the script is called with no posted arguments // we show the input form. // 2) If we have posted arguments we naivly assume that // we are called to do the image. if( @$_POST['ok']===' Ok ' ) { $this->GenGradImage(); } else $this->iForm->Run(); } } $driver = new Driver(); $driver->Run(); ?>