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
protected $style = awTick::IN;
* Ticks number by other tick
* @param int $number Number of ticks
* @param int $size Ticks size
$this->style = (int) $style;
public function setColor(awColor $color) {
$this->size = (int) $size;
* Change interval of ticks
* Get interval between each tick
* Change number of ticks relative to others ticks
* @param awTick $tick Ticks reference
* @param int $number Number of ticks
$this->numberByTick = array(&$tick, (int)$number);
public function hide($hide) {
$this->hide = (bool) $hide;
* @param awDriver $driver A driver
* @param awVector $vector A vector
public function draw(awDriver $driver, awVector $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);
protected function drawTicks(awDriver $driver, awVector $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);
protected function drawTick(awDriver $driver, awPoint $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.')'.'/';
|