Contents
Login Register Wishes Forum About
FAQ » Transparent background
Help topics
Latest updates
1997d  replaceImageMapTitle
1997d  replaceImageMapValues
1997d  createFunctionSerie
1997d  setAbsicssaPosition
1997d  negateValues
Toolbox
  Download as PDF
  Print this page
  Share this page
  Create an account
  Feed the updates!
Google AdSense
Transparent Background

With pChart 2.0 it is now possible to fully use the PNG alpha channels event on pictures that have no background. You can create pictures that have a transparent background easily but don‘t forget that today some browser or picture editors can use it. Transparent backgrounds used with non-linear borders and transparency can create really interesting results. Rendering time will not change while enabling it.

To enable the transparent background processing just create the pImage object this way :
 $myPicture = new pImage(700,230,$myData,TRUE);
..or if you don‘t have any pData object and just want to use the core drawing functions :
 $myPicture = new pImage(700,230,NULL,TRUE);

Example #1



Let‘s assume the following dataset :
 /* pChart library inclusions */
 include("../class/pDraw.class.php");
 include("../class/pImage.class.php");

 /* Create the pChart object */
 $myPicture = new pImage(700,230,NULL,TRUE);

 /* Draw a rounded filled rectangle */
 $RectangleSettings = array("R"=>209,"G"=>31,"B"=>27,"Alpha"=>50,"Surrounding"=>30);
 $myPicture->drawRoundedFilledRectangle(10,25,70,55,5,$RectangleSettings);

 /* Draw a rounded filled rectangle */
 $RectangleSettings = array("R"=>209,"G"=>125,"B"=>27,"Alpha"=>50,"Surrounding"=>30);
 $myPicture->drawRoundedFilledRectangle(10,85,70,115,5,$RectangleSettings);

 /* Draw a rounded filled rectangle */
 $RectangleSettings = array("R"=>209,"G"=>198,"B"=>27,"Alpha"=>50,"Surrounding"=>30);
 $myPicture->drawRoundedFilledRectangle(10,135,70,165,5,$RectangleSettings);

 /* Draw a rounded filled rectangle */
 $RectangleSettings = array("R"=>134,"G"=>209,"B"=>27,"Alpha"=>50,"Surrounding"=>30);
 $myPicture->drawRoundedFilledRectangle(10,185,70,215,5,$RectangleSettings);

 /* Enable shadow computing */
 $myPicture->setShadow(TRUE,array("X"=>2,"Y"=>2,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>20));

 /* Draw a rounded filled rectangle */
 $RectangleSettings = array("R"=>209,"G"=>198,"B"=>27,"Alpha"=>100,"Surrounding"=>30,"Radius"=>20);
 $myPicture->drawRoundedFilledRectangle(100,20,680,210,20,$RectangleSettings);

 /* Render the picture (choose the best way) */
 $myPicture->autoOutput("pictures/example.transparent.background.png");

Example #2



Let‘s assume the following dataset :
 /* pChart library inclusions */
 include("../class/pData.class.php");
 include("../class/pDraw.class.php");
 include("../class/pPie.class.php");
 include("../class/pImage.class.php");

 /* Create and populate the pData object */
 $MyData = new pData();   
 $MyData->addPoints(array(40,30,20),"ScoreA");  
 $MyData->setSerieDescription("ScoreA","Application A");

 /* Define the absissa serie */
 $MyData->addPoints(array("A","B","C"),"Labels");
 $MyData->setAbscissa("Labels");

 /* Create the pChart object */
 $myPicture = new pImage(240,180,$MyData,TRUE);

 /* Set the default font properties */ 
 $myPicture->setFontProperties(array("FontName"=>"../fonts/Forgotte.ttf","FontSize"=>10,"R"=>80,"G"=>80,"B"=>80));

 /* Create the pPie object */ 
 $PieChart = new pPie($myPicture,$MyData);

 /* Enable shadow computing */ 
 $myPicture->setShadow(TRUE,array("X"=>3,"Y"=>3,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>10));

 /* Draw a splitted pie chart */ 
 $PieChart->draw3DPie(120,90,array("Radius"=>100,"DataGapAngle"=>10,"DataGapRadius"=>6,"Border"=>TRUE));

 /* Write the legend box */ 
 $myPicture->setFontProperties(array("FontName"=>"../fonts/Silkscreen.ttf","FontSize"=>6,"R"=>255,"G"=>255,"B"=>255));
 $PieChart->drawPieLegend(140,160,array("Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL));

 /* Render the picture (choose the best way) */
 $myPicture->autoOutput("pictures/example.draw3DPie.png");
Last updated on 01/17/2011 
by Jean-Damien 
Linked resources
  There is no linked topic yet.
Community comments
  No comments have been posted yet.
© Copyrights
Components used on this web site : Famfamfam icons has been made by Mark James, Rounded corners lite has been coded by Cameron Cooke and Tim Hutchison, SyntaxHighlighter has been written by Alex Gorbatchev. pChart and this web site have been created by Jean-Damien POGOLOTTI. This documentation contains 185 pages and 56 comments. 409 users have registered. This page has been rendered in 0,02 seconds. Wiki revision 1.37.