SimpleCircleEye.php 1.2 KB

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