Login   Register  
PHP Classes
elePHPant
Icontem

File: readme.txt

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Omar Ortiz  >  cSpeedometer  >  readme.txt  >  Download  
File: readme.txt
Role: Documentation
Content type: text/plain
Description: readme file
Class: cSpeedometer
Render a speed meter as image or HTML5 canvas
Author: By
Last change: add canvas with gradient effect and canvas explanation
Date: 1 year ago
Size: 2,104 bytes
 

Contents

Class file image Download
Steps to generate a speedometer:
1. Include cspeedometer.php library in your script
require_once("cSpeedometer.php");
2. Create an array with the selected colors if you want to change default colors.
   See color method for defined colors, See __construct method for custom colors.
   the array only need the colors that you want to change
examples:
$colors = array(BCKGND=>"pink",BORDER => "darkBlue",SPEED=>"darkRed",SPD_IND=>"black",SPD_MARK=>"darkGreen",RED_ZN=>"red",GRN_ZN=>"green",YLW_ZN="yellow");
$colors = array(BCKGND=>"pink",BORDER => "darkBlue",SPEED=>"darkRed");
2. create a cSpeedometer object 
$sp1 = new cSpeedometer(250,$colors);
1st parameter is the size in pixels, default is 500
2nd parameter is colors array see (2.)
3. Set max value (default is 100) 
$sp1->setMaxValue(150);
3. Set min value (default is 0) 
$sp1->setMinValue(10);
4. Set speed
$sp1->setValue(35);
5. if you need a green zone then set de green zone
$sp1->setGZone(100,150);
1st parameter is the starting point of green zone
2nd parameter is the ending point of green zone
6. if you need a yellow zone then set de yellow zone
$sp1->setYZone(50,100);
1st parameter is the starting point of yellow zone
2nd parameter is the ending point of yellow zone
7. if you need a red zone then set de red zone
$sp1->setRZone(10,50);
1st parameter is the starting point of red zone
2nd parameter is the ending point of red zone
8. Create the image or de canvas
$sp1->getImage("GIF","sp3");
1st parameter is the format (GIF, PNG, JPG), default is PNG
2nd parameter is the name of the file (without extension) if you omit this parameter, the image is output to screen
The image is generate in tmp directory, see FILE_PATH constant defined in cSpeedometer.php library
echo $sp1->getCanvas("sp1",2,true);
1st parameter is the id to use in canvas
2nd parameter is the number of decimals in seepd and marks
3th parameter active gradient effect in yellow zone
echo $sp1->getSVG("sp1",2);
1st parameter is the id to use in svg object
2nd parameter is the number of decimals in seepd and marks