@@ -18,6 +18,9 @@ class AntialiasDrawer
18
18
/** @var bool */
19
19
protected $ IsNativeFunctionAvailable ;
20
20
21
+ /** @var bool */
22
+ protected $ UseNativeFunctionIfAvailable = false ;
23
+
21
24
/** @var float */
22
25
protected $ AntialiasThreshold ;
23
26
@@ -27,9 +30,14 @@ public function __construct(float $antialiasThreshold = 0.0)
27
30
$ this ->AntialiasThreshold = $ antialiasThreshold ;
28
31
}
29
32
33
+ public function enableNativeAntialiasingIfAvailable (bool $ flag )
34
+ {
35
+ $ this ->UseNativeFunctionIfAvailable = $ flag ;
36
+ }
37
+
30
38
public function drawLine ($ resource , $ x1 , $ y1 , $ x2 , $ y2 , int $ r , int $ g , int $ b , float $ alpha = 100.0 , int $ lineWidth = 1 )
31
39
{
32
- if ($ this ->IsNativeFunctionAvailable ) {
40
+ if ($ this ->IsNativeFunctionAvailable && $ this -> UseNativeFunctionIfAvailable ) {
33
41
$ this ->drawNativeLine ($ resource , $ x1 , $ y1 , $ x2 , $ y2 , $ r , $ g , $ b , $ alpha , $ lineWidth );
34
42
} else {
35
43
$ this ->drawAntialiasLine ($ resource , $ x1 , $ y1 , $ x2 , $ y2 , $ r , $ g , $ b , $ alpha , $ lineWidth );
@@ -38,6 +46,11 @@ public function drawLine($resource, $x1, $y1, $x2, $y2, int $r, int $g, int $b,
38
46
39
47
protected function drawNativeLine ($ resource , $ x1 , $ y1 , $ x2 , $ y2 , int $ r , int $ g , int $ b , float $ alpha = 100.0 , int $ lineWidth = 1 )
40
48
{
49
+ $ x1 = (int )round ($ x1 );
50
+ $ x2 = (int )round ($ x2 );
51
+ $ y1 = (int )round ($ y1 );
52
+ $ y2 = (int )round ($ y2 );
53
+
41
54
imagesetthickness ($ resource , $ lineWidth );
42
55
imagealphablending ($ resource , true );
43
56
imageantialias ($ resource , true );
0 commit comments