Source for file Tick.class.php
Documentation is available at Tick.class.php
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
require_once dirname(__FILE__ ). "/../Graph.class.php";
* @package linea21.externals
* Ticks number by other tick
* @param int $number Number of ticks
* @param int $size Ticks size
function awTick($number, $size) {
$this->style = (int) $style;
$this->size = (int) $size;
* Change interval of ticks
* Get interval between each tick
* Change number of ticks relative to others ticks
* @param &$tick Ticks reference
* @param int $number Number of ticks
$this->hide = (bool) $hide;
* @param $driver A driver
* @param &$vector A vector
function draw($driver, &$vector) {
$this->number = 1 + ($tick->getNumber() - 1) * ($number + 1);
$angle = $vector->getAngle();
// echo "INIT:".$angle."<br>";
$this->drawTicks($driver, $vector, NULL, $angle + M_PI / 2);
$this->drawTicks($driver, $vector, $angle + 3 * M_PI / 2, NULL);
$this->drawTicks($driver, $vector, $angle + M_PI / 2, $angle + 3 * M_PI / 2);
function drawTicks($driver, &$vector, $from, $to) {
$this->drawTick($driver, $vector->p2, $from, $to);
$size = $vector->getSize();
// Get tick increment in pixels
// Check if we must hide the first tick
for($i = $start; round($i, 6) < $stop; $i += $inc) {
round($i * cos($vector->getAngle()), 6),
round($i * sin($vector->getAngle() * - 1), 6)
$this->drawTick($driver, $p, $from, $to);
function drawTick($driver, $p, $from, $to) {
// echo $this->size.':'.$angle.'|<b>'.cos($angle).'</b>/';
// The round avoid some errors in the calcul
// For example, 12.00000008575245 becomes 12
//echo $p1->x.':'.$p2->x.'('.$p1->y.':'.$p2->y.')'.'/';
|