Debian Codegraph @

src/Renderer/Eye/SimpleCircleEye.php

raw
1 <?php
2 declare(strict_types = 1);
3
4 namespace BaconQrCode\Renderer\Eye;
5
6 use BaconQrCode\Renderer\Path\Path;
7
8 /**
9 * Renders the inner eye as a circle.
10 */
11 final class SimpleCircleEye implements EyeInterface
12 {
13 private static ?SimpleCircleEye $instance = null;
14
15 private function __construct()
16 {
17 }
18
19 public static function instance() : self
20 {
21 return self::$instance ?: self::$instance = new self();
22 }
23
24 public function getExternalPath() : Path
25 {
26 return (new Path())
27 ->move(-3.5, -3.5)
28 ->line(3.5, -3.5)
29 ->line(3.5, 3.5)
30 ->line(-3.5, 3.5)
31 ->close()
32 ->move(-2.5, -2.5)
33 ->line(-2.5, 2.5)
34 ->line(2.5, 2.5)
35 ->line(2.5, -2.5)
36 ->close()
37 ;
38 }
39
40 public function getInternalPath() : Path
41 {
42 return (new Path())
43 ->move(1.5, 0)
44 ->ellipticArc(1.5, 1.5, 0., false, true, 0., 1.5)
45 ->ellipticArc(1.5, 1.5, 0., false, true, -1.5, 0.)
46 ->ellipticArc(1.5, 1.5, 0., false, true, 0., -1.5)
47 ->ellipticArc(1.5, 1.5, 0., false, true, 1.5, 0.)
48 ->close()
49 ;
50 }
51 }