|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Barryvanveen\CCA\Config; |
|
6
|
|
|
|
|
7
|
|
|
use Barryvanveen\CCA\Exceptions\InvalidPresetException; |
|
8
|
|
|
|
|
9
|
|
|
class Presets |
|
10
|
|
|
{ |
|
11
|
|
|
const PRESET_313 = '313'; |
|
12
|
|
|
const PRESET_AMOEBA = 'amoeba'; |
|
13
|
|
|
const PRESET_CCA = 'cca'; |
|
14
|
|
|
const PRESET_CUBISM = 'cubism'; |
|
15
|
|
|
const PRESET_CYCLIC_SPIRALS = 'cyclic_spirals'; |
|
16
|
|
|
const PRESET_GH = 'gh'; |
|
17
|
|
|
const PRESET_LAVALAMP = 'lavalamp'; |
|
18
|
|
|
const PRESET_PERFECT = 'perfect'; |
|
19
|
|
|
const PRESET_SQUARISH_SPIRALS = 'squarish_spirals'; |
|
20
|
|
|
|
|
21
|
|
|
const VALID_PRESETS = [ |
|
22
|
|
|
Presets::PRESET_313, |
|
23
|
|
|
Presets::PRESET_AMOEBA, |
|
24
|
|
|
Presets::PRESET_CCA, |
|
25
|
|
|
Presets::PRESET_CUBISM, |
|
26
|
|
|
Presets::PRESET_CYCLIC_SPIRALS, |
|
27
|
|
|
Presets::PRESET_GH, |
|
28
|
|
|
Presets::PRESET_LAVALAMP, |
|
29
|
|
|
Presets::PRESET_PERFECT, |
|
30
|
|
|
Presets::PRESET_SQUARISH_SPIRALS, |
|
31
|
|
|
]; |
|
32
|
|
|
|
|
33
|
|
|
protected static $preset_options = [ |
|
34
|
|
|
self::PRESET_313 => [ |
|
35
|
|
|
Options::NEIGHBORHOOD_SIZE => 1, |
|
36
|
|
|
Options::NEIGHBORHOOD_TYPE => NeighborhoodOptions::NEIGHBORHOOD_TYPE_MOORE, |
|
37
|
|
|
Options::STATES => 3, |
|
38
|
|
|
Options::THRESHOLD => 3, |
|
39
|
|
|
], |
|
40
|
|
|
self::PRESET_AMOEBA => [ |
|
41
|
|
|
Options::NEIGHBORHOOD_SIZE => 3, |
|
42
|
|
|
Options::NEIGHBORHOOD_TYPE => NeighborhoodOptions::NEIGHBORHOOD_TYPE_NEUMANN, |
|
43
|
|
|
Options::STATES => 2, |
|
44
|
|
|
Options::THRESHOLD => 10, |
|
45
|
|
|
], |
|
46
|
|
|
self::PRESET_CCA => [ |
|
47
|
|
|
Options::NEIGHBORHOOD_SIZE => 1, |
|
48
|
|
|
Options::NEIGHBORHOOD_TYPE => NeighborhoodOptions::NEIGHBORHOOD_TYPE_NEUMANN, |
|
49
|
|
|
Options::STATES => 14, |
|
50
|
|
|
Options::THRESHOLD => 1, |
|
51
|
|
|
], |
|
52
|
|
|
self::PRESET_CUBISM => [ |
|
53
|
|
|
Options::NEIGHBORHOOD_SIZE => 2, |
|
54
|
|
|
Options::NEIGHBORHOOD_TYPE => NeighborhoodOptions::NEIGHBORHOOD_TYPE_NEUMANN, |
|
55
|
|
|
Options::STATES => 3, |
|
56
|
|
|
Options::THRESHOLD => 5, |
|
57
|
|
|
], |
|
58
|
|
|
self::PRESET_CYCLIC_SPIRALS => [ |
|
59
|
|
|
Options::NEIGHBORHOOD_SIZE => 3, |
|
60
|
|
|
Options::NEIGHBORHOOD_TYPE => NeighborhoodOptions::NEIGHBORHOOD_TYPE_MOORE, |
|
61
|
|
|
Options::STATES => 8, |
|
62
|
|
|
Options::THRESHOLD => 5, |
|
63
|
|
|
], |
|
64
|
|
|
self::PRESET_GH => [ |
|
65
|
|
|
Options::NEIGHBORHOOD_SIZE => 3, |
|
66
|
|
|
Options::NEIGHBORHOOD_TYPE => NeighborhoodOptions::NEIGHBORHOOD_TYPE_MOORE, |
|
67
|
|
|
Options::STATES => 8, |
|
68
|
|
|
Options::THRESHOLD => 5, |
|
69
|
|
|
], |
|
70
|
|
|
self::PRESET_LAVALAMP => [ |
|
71
|
|
|
Options::NEIGHBORHOOD_SIZE => 2, |
|
72
|
|
|
Options::NEIGHBORHOOD_TYPE => NeighborhoodOptions::NEIGHBORHOOD_TYPE_MOORE, |
|
73
|
|
|
Options::STATES => 3, |
|
74
|
|
|
Options::THRESHOLD => 10, |
|
75
|
|
|
], |
|
76
|
|
|
self::PRESET_PERFECT => [ |
|
77
|
|
|
Options::NEIGHBORHOOD_SIZE => 1, |
|
78
|
|
|
Options::NEIGHBORHOOD_TYPE => NeighborhoodOptions::NEIGHBORHOOD_TYPE_MOORE, |
|
79
|
|
|
Options::STATES => 4, |
|
80
|
|
|
Options::THRESHOLD => 3, |
|
81
|
|
|
], |
|
82
|
|
|
self::PRESET_SQUARISH_SPIRALS => [ |
|
83
|
|
|
Options::NEIGHBORHOOD_SIZE => 2, |
|
84
|
|
|
Options::NEIGHBORHOOD_TYPE => NeighborhoodOptions::NEIGHBORHOOD_TYPE_NEUMANN, |
|
85
|
|
|
Options::STATES => 6, |
|
86
|
|
|
Options::THRESHOLD => 2, |
|
87
|
|
|
], |
|
88
|
|
|
]; |
|
89
|
|
|
|
|
90
|
6 |
|
public static function getPresetOptions(string $preset): array |
|
91
|
|
|
{ |
|
92
|
6 |
|
if (!in_array($preset, Presets::VALID_PRESETS)) { |
|
93
|
3 |
|
throw new InvalidPresetException(); |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
3 |
|
return self::$preset_options[$preset]; |
|
97
|
|
|
} |
|
98
|
|
|
} |
|
99
|
|
|
|