GraphicControlExtension.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. <?php
  2. declare(strict_types=1);
  3. namespace Intervention\Gif\Blocks;
  4. use Intervention\Gif\AbstractExtension;
  5. use Intervention\Gif\DisposalMethod;
  6. class GraphicControlExtension extends AbstractExtension
  7. {
  8. public const LABEL = "\xF9";
  9. public const BLOCKSIZE = "\x04";
  10. /**
  11. * Existance flag of transparent color
  12. *
  13. * @var bool
  14. */
  15. protected bool $transparentColorExistance = false;
  16. /**
  17. * Transparent color index
  18. *
  19. * @var int
  20. */
  21. protected int $transparentColorIndex = 0;
  22. /**
  23. * User input flag
  24. *
  25. * @var bool
  26. */
  27. protected bool $userInput = false;
  28. /**
  29. * Create new instance
  30. *
  31. * @param int $delay
  32. * @param DisposalMethod $disposalMethod
  33. * @return void
  34. */
  35. public function __construct(
  36. protected int $delay = 0,
  37. protected DisposalMethod $disposalMethod = DisposalMethod::UNDEFINED,
  38. ) {
  39. }
  40. /**
  41. * Set delay time (1/100 second)
  42. *
  43. * @param int $value
  44. */
  45. public function setDelay(int $value): self
  46. {
  47. $this->delay = $value;
  48. return $this;
  49. }
  50. /**
  51. * Return delay time (1/100 second)
  52. *
  53. * @return int
  54. */
  55. public function getDelay(): int
  56. {
  57. return $this->delay;
  58. }
  59. /**
  60. * Set disposal method
  61. *
  62. * @param DisposalMethod $method
  63. * @return self
  64. */
  65. public function setDisposalMethod(DisposalMethod $method): self
  66. {
  67. $this->disposalMethod = $method;
  68. return $this;
  69. }
  70. /**
  71. * Get disposal method
  72. *
  73. * @return DisposalMethod
  74. */
  75. public function getDisposalMethod(): DisposalMethod
  76. {
  77. return $this->disposalMethod;
  78. }
  79. /**
  80. * Get transparent color index
  81. *
  82. * @return int
  83. */
  84. public function getTransparentColorIndex(): int
  85. {
  86. return $this->transparentColorIndex;
  87. }
  88. /**
  89. * Set transparent color index
  90. *
  91. * @param int $index
  92. */
  93. public function setTransparentColorIndex(int $index): self
  94. {
  95. $this->transparentColorIndex = $index;
  96. return $this;
  97. }
  98. /**
  99. * Get current transparent color existance
  100. *
  101. * @return bool
  102. */
  103. public function getTransparentColorExistance(): bool
  104. {
  105. return $this->transparentColorExistance;
  106. }
  107. /**
  108. * Set existance flag of transparent color
  109. *
  110. * @param bool $existance
  111. */
  112. public function setTransparentColorExistance(bool $existance = true): self
  113. {
  114. $this->transparentColorExistance = $existance;
  115. return $this;
  116. }
  117. /**
  118. * Get user input flag
  119. *
  120. * @return bool
  121. */
  122. public function getUserInput(): bool
  123. {
  124. return $this->userInput;
  125. }
  126. /**
  127. * Set user input flag
  128. *
  129. * @param bool $value
  130. */
  131. public function setUserInput(bool $value = true): self
  132. {
  133. $this->userInput = $value;
  134. return $this;
  135. }
  136. }