Skip to content

Commit

Permalink
add attributes for gdtext implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
sergix44 committed Sep 23, 2023
1 parent e1af58b commit a3199a8
Showing 1 changed file with 42 additions and 7 deletions.
49 changes: 42 additions & 7 deletions src/Draws/Text.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,20 @@ abstract class Text
public Color $color;
public Position $align;
public int $angle;
public float $stroke = 0;
public Color $strokeColor;
public ?Color $background = null;
public int $shadowX = 0;
public int $shadowY = 0;
public ?Color $shadowColor = null;

/**
* @param string $text
* @param int $size
* @param Color|null $color
* @param string|null $fontPath
* @param Position $align
* @param int $angle
* @param string $text
* @param int $size
* @param Color|null $color
* @param string|null $fontPath
* @param Position $align
* @param int $angle
*/
public function __construct(
string $text,
Expand All @@ -28,7 +34,7 @@ public function __construct(
int $angle = 0,
) {
$this->text = $text;
$this->fontPath = $fontPath ?? __DIR__.'/../../assets/LiberationSans-Regular.ttf';
$this->fontPath = $fontPath ?? __DIR__ . '/../../assets/LiberationSans-Regular.ttf';
$this->size = $size;
$this->color = $color ?? Color::black();
$this->align = $align;
Expand Down Expand Up @@ -72,6 +78,35 @@ public function angle(int $angle): self
return $this;
}

public function stroke(float $stroke, ?Color $color = null): self
{
$this->stroke = $stroke;
$this->strokeColor = $color ?? Color::white();

return $this;
}

public function background(?Color $color = null): self
{
$this->background = $color ?? Color::white();

return $this;
}

public function shadow(int $x, int $y, ?Color $color = null): self
{
$this->shadowX = $x;
$this->shadowY = $y;
$this->shadowColor = $color ?? Color::black();

return $this;
}

public function hasShadow(): bool
{
return $this->shadowX !== 0 || $this->shadowY !== 0;
}

public function hasFont(): bool
{
return $this->fontPath !== null && file_exists($this->fontPath);
Expand Down

0 comments on commit a3199a8

Please sign in to comment.