Subversion Repositories Applications.gtt

Rev

Rev 61 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
60 jpm 1
<?php
2
/*
3
 * This work is hereby released into the Public Domain.
4
 * To view a copy of the public domain dedication,
5
 * visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
6
 * Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
7
 *
8
 */
9
 
10
require_once "../MathPlot.class.php";
11
 
12
 
13
$graph = new Graph(300, 300);
14
 
15
// Set graph title
16
$graph->title->set('f(x) = x * x');
17
$graph->title->setBackgroundColor(new White(0));
18
$graph->title->setPadding(NULL, NULL, 10, 10);
19
$graph->title->move(0, -10);
20
 
21
$plot = new MathPlot(-3, 3, 10, -2);
22
$plot->setInterval(0.2);
23
$plot->setPadding(NULL, NULL, NULL, 20);
24
 
25
// Defines x²
26
function x2($x) {
27
	return $x * $x;
28
}
29
 
30
$function = new MathFunction('x2');
31
$function->setColor(new Orange);
32
$plot->add($function);
33
 
34
$graph->add($plot);
35
$graph->draw();
36
?>