Debian Codegraph @

src/Renderer/Eye/PointyEye.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 outer eye as solid with a curved corner and inner eye as a circle.
10 */
11 final class PointyEye implements EyeInterface
12 {
13 /**
14 * @var self|null
15 */
16 private static $instance;
17
18 private function __construct()
19 {
20 }
21
22 public static function instance() : self
23 {
24 return self::$instance ?: self::$instance = new self();
25 }
26
27 public function getExternalPath() : Path
28 {
29 return (new Path())
30 ->move(-3.5, 3.5)
31 ->line(-3.5, 0)
32 ->ellipticArc(3.5, 3.5, 0, false, true, 0, -3.5)
33 ->line(3.5, -3.5)
34 ->line(3.5, 3.5)
35 ->close()
36 ->move(2.5, 0)
37 ->ellipticArc(2.5, 2.5, 0, false, true, 0, 2.5)
38 ->ellipticArc(2.5, 2.5, 0, false, true, -2.5, 0)
39 ->ellipticArc(2.5, 2.5, 0, false, true, 0, -2.5)
40 ->ellipticArc(2.5, 2.5, 0, false, true, 2.5, 0)
41 ->close()
42 ;
43 }
44
45 public function getInternalPath() : Path
46 {
47 return (new Path())
48 ->move(1.5, 0)
49 ->ellipticArc(1.5, 1.5, 0., false, true, 0., 1.5)
50 ->ellipticArc(1.5, 1.5, 0., false, true, -1.5, 0.)
51 ->ellipticArc(1.5, 1.5, 0., false, true, 0., -1.5)
52 ->ellipticArc(1.5, 1.5, 0., false, true, 1.5, 0.)
53 ->close()
54 ;
55 }
56 }