|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
use Cairo\Context; |
|
|
|
|
|
|
4
|
|
|
use Cairo\Surface\Image; |
|
|
|
|
|
|
5
|
|
|
use Cairo\Surface\ImageFormat; |
|
|
|
|
|
|
6
|
|
|
|
|
7
|
|
|
function splinePath($spline, $context) |
|
8
|
|
|
{ |
|
9
|
|
|
$context->save(); |
|
10
|
|
|
$context->moveTo(-$spline, 0); |
|
11
|
|
|
$context->curveTo(-$spline / 4, -$spline, $spline / 4, $spline, $spline, 0); |
|
12
|
|
|
$context->restore(); |
|
13
|
|
|
} |
|
14
|
|
|
|
|
15
|
|
|
function scaleThenSetLineWidthAndStroke($context, $spline, $scaleX, $scaleY, $lineWidth) |
|
16
|
|
|
{ |
|
17
|
|
|
$context->scale($scaleX, $scaleY); |
|
18
|
|
|
$context->setLineWidth($lineWidth); |
|
19
|
|
|
splinePath($spline, $context); |
|
20
|
|
|
$context->stroke(); |
|
21
|
|
|
} |
|
22
|
|
|
|
|
23
|
|
|
function scalePathAndLineWidth($context, $spline, $scaleX, $scaleY, $lineWidth) |
|
24
|
|
|
{ |
|
25
|
|
|
$context->save(); |
|
26
|
|
|
$context->scale($scaleX, $scaleY); |
|
27
|
|
|
splinePath($spline, $context); |
|
28
|
|
|
$context->restore(); |
|
29
|
|
|
$context->save(); |
|
30
|
|
|
$context->scale($scaleX, $scaleY); |
|
31
|
|
|
$context->setLineWidth($lineWidth); |
|
32
|
|
|
$context->stroke(); |
|
33
|
|
|
$context->restore(); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
function setLineWidthThenScaleAndStroke($context, $spline, $scaleX, $scaleY, $lineWidth) |
|
37
|
|
|
{ |
|
38
|
|
|
$context->setLineWidth($lineWidth); |
|
39
|
|
|
$context->scale($scaleX, $scaleY); |
|
40
|
|
|
splinePath($spline, $context); |
|
41
|
|
|
$context->stroke(); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
function scalePathNotLineWidth($context, $spline, $scaleX, $scaleY, $lineWidth) |
|
45
|
|
|
{ |
|
46
|
|
|
$context->save(); |
|
47
|
|
|
$context->scale($scaleX, $scaleY); |
|
48
|
|
|
splinePath($spline, $context); |
|
49
|
|
|
$context->restore(); |
|
50
|
|
|
$context->save(); |
|
51
|
|
|
$context->setLineWidth($lineWidth); |
|
52
|
|
|
$context->stroke(); |
|
53
|
|
|
$context->restore(); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
$spline = 50.0; |
|
57
|
|
|
$lineWidth = 13; |
|
58
|
|
|
$scaleX = 0.5; |
|
59
|
|
|
$scaleY = 2.0; |
|
60
|
|
|
$width = ($scaleX * $spline * 6.0); |
|
61
|
|
|
$height = ($scaleY * $spline * 2.0); |
|
62
|
|
|
|
|
63
|
|
|
$surface = new Image(ImageFormat::ARGB32, $width, $height); |
|
64
|
|
|
$context = new Context($surface); |
|
65
|
|
|
$context->setSourceRgb(1.0, 1.0, 1.0); /* white */ |
|
66
|
|
|
$context->paint(); |
|
67
|
|
|
$context->setSourceRgb(0.0, 0.0, 0.0); /* black */ |
|
68
|
|
|
|
|
69
|
|
|
for ($i = 0; $i < 4; $i++) |
|
70
|
|
|
{ |
|
71
|
|
|
$context->save(); |
|
72
|
|
|
|
|
73
|
|
|
switch ($i) |
|
74
|
|
|
{ |
|
75
|
|
|
case 0: |
|
76
|
|
|
$context->translate($width / 4, $height / 4); |
|
77
|
|
|
scaleThenSetLineWidthAndStroke($context, $spline, $scaleX, $scaleY, $lineWidth); |
|
78
|
|
|
break; |
|
79
|
|
|
case 1: |
|
80
|
|
|
$context->translate($width / 4 + $width / 2, $height / 4); |
|
81
|
|
|
scalePathAndLineWidth($context, $spline, $scaleX, $scaleY, $lineWidth); |
|
82
|
|
|
break; |
|
83
|
|
|
case 2: |
|
84
|
|
|
$context->translate($width / 4, $height / 4 + $height / 2); |
|
85
|
|
|
setLineWidthThenScaleAndStroke($context, $spline, $scaleX, $scaleY, $lineWidth); |
|
86
|
|
|
break; |
|
87
|
|
|
case 3: |
|
88
|
|
|
$context->translate($width / 4 + $width / 2, $height / 4 + $height / 2); |
|
89
|
|
|
scalePathNotLineWidth($context, $spline, $scaleX, $scaleY, $lineWidth); |
|
90
|
|
|
break; |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
$context->restore(); |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
$surface->writeToPng(dirname(__FILE__).'/line-width-scale-php.png'); |
|
97
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths