1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* JPGraph v4.0.3 |
5
|
|
|
*/ |
6
|
|
|
|
7
|
|
|
namespace Amenadiel\JpGraph\Image; |
8
|
|
|
|
9
|
|
|
use Amenadiel\JpGraph\Plot; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* File: JPGRAPH_SCATTER.PHP |
13
|
|
|
* // Description: Scatter (and impuls) plot extension for JpGraph |
14
|
|
|
* // Created: 2001-02-11 |
15
|
|
|
* // Ver: $Id: jpgraph_scatter.php 1397 2009-06-27 21:34:14Z ljp $ |
16
|
|
|
* // |
17
|
|
|
* // Copyright (c) Asial Corporation. All rights reserved. |
18
|
|
|
*/ |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @class FieldArrow |
22
|
|
|
* // Description: Draw an arrow at (x,y) with angle a |
23
|
|
|
*/ |
24
|
|
|
class FieldArrow |
25
|
|
|
{ |
26
|
|
|
public $iColor = 'black'; |
27
|
|
|
public $iSize = 10; // Length in pixels for arrow |
28
|
|
|
public $iArrowSize = 2; |
29
|
|
|
private $isizespec = [ |
30
|
|
|
[2, 1], [3, 2], [4, 3], [6, 4], [7, 4], [8, 5], [10, 6], [12, 7], [16, 8], [20, 10], |
31
|
|
|
]; |
32
|
|
|
|
33
|
|
|
public function __construct() |
34
|
|
|
{ |
35
|
|
|
// Empty |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
public function SetSize($aSize, $aArrowSize = 2) |
39
|
|
|
{ |
40
|
|
|
$this->iSize = $aSize; |
41
|
|
|
$this->iArrowSize = $aArrowSize; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
public function SetColor($aColor) |
45
|
|
|
{ |
46
|
|
|
$this->iColor = $aColor; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
public function Stroke($aImg, $x, $y, $a) |
50
|
|
|
{ |
51
|
|
|
// First rotate the center coordinates |
52
|
|
|
list($x, $y) = $aImg->Rotate($x, $y); |
53
|
|
|
|
54
|
|
|
$old_origin = $aImg->SetCenter($x, $y); |
55
|
|
|
$old_a = $aImg->a; |
56
|
|
|
$aImg->SetAngle(-$a + $old_a); |
57
|
|
|
|
58
|
|
|
$dx = round($this->iSize / 2); |
59
|
|
|
$c = [$x - $dx, $y, $x + $dx, $y]; |
60
|
|
|
$x += $dx; |
61
|
|
|
|
62
|
|
|
list($dx, $dy) = $this->isizespec[$this->iArrowSize]; |
63
|
|
|
$ca = [$x, $y, $x - $dx, $y - $dy, $x - $dx, $y + $dy, $x, $y]; |
64
|
|
|
|
65
|
|
|
$aImg->SetColor($this->iColor); |
66
|
|
|
$aImg->Polygon($c); |
67
|
|
|
$aImg->FilledPolygon($ca); |
68
|
|
|
|
69
|
|
|
$aImg->SetCenter($old_origin[0], $old_origin[1]); |
70
|
|
|
$aImg->SetAngle($old_a); |
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
|