Issues (331)

examples/random-intersections.php (4 issues)

Labels
Severity
1
<?php
2
3
use Cairo\Context;
0 ignored issues
show
The type Cairo\Context was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
4
use Cairo\FillRule;
0 ignored issues
show
The type Cairo\FillRule was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
5
use Cairo\Surface\Image;
0 ignored issues
show
The type Cairo\Surface\Image was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use Cairo\Surface\ImageFormat;
0 ignored issues
show
The type Cairo\Surface\ImageFormat was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
8
function uniformRandom($state, $minValue, $maxValue)
9
{
10
	$poly = 0x9a795537;
11
	$state = 2 * $state < $state ? (2 * $state ^ $poly) : 2 * $state;
12
	
13
	return floor($minValue + $state * ($maxValue - $minValue) / 4294967296.0);
14
}
15
16
$size = 512;
17
$segments = 128;
18
$width = $size + 3;
19
$height = $size + 3;
20
$state = 0x123456;
21
22
$surface = new Image(ImageFormat::ARGB32, $size + 3, $size + 3);
23
$context = new Context($surface);
24
25
$context->setSourceRgb(0, 0, 0);
26
$context->paint();
27
28
$context->translate(1, 1);
29
$context->setFillRule(FillRule::EVEN_ODD);
30
$context->moveTo(0, 0);
31
32
for ($i = 0; $i < $segments; $i++)
33
{
34
	$x = uniformRandom($state, 0, $width);
35
	$y = uniformRandom($state, 0, $height);
36
	$context->lineTo($x, $y);
37
}
38
39
$context->closePath();
40
$context->setSourceRgb(1, 0, 0);
41
$context->fillPreserve();
42
$context->setSourceRgb(0, 1, 0);
43
$context->setLineWidth(0.5);
44
$context->stroke();
45
46
$surface->writeToPng(dirname(__FILE__).'/random-intersections-php.png');
47