Skip to content

Commit

Permalink
Reworked PDF colors.
Browse files Browse the repository at this point in the history
  • Loading branch information
laurentmuller committed Jan 31, 2025
1 parent 0c3e48f commit e2ebd43
Show file tree
Hide file tree
Showing 7 changed files with 869 additions and 500 deletions.
22 changes: 11 additions & 11 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

234 changes: 0 additions & 234 deletions src/Pdf/Colors/AbstractPdfColor.php

This file was deleted.

25 changes: 18 additions & 7 deletions src/Pdf/Colors/PdfDrawColor.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,36 @@

namespace App\Pdf\Colors;

use App\Pdf\Interfaces\PdfDocumentUpdaterInterface;
use fpdf\Color\PdfRgbColor;
use fpdf\PdfDocument;

/**
* Color used color for all drawing operations (lines, rectangles and for cell borders).
* RGB color used for all drawing operations (lines, rectangles and for cell borders).
*/
class PdfDrawColor extends AbstractPdfColor
readonly class PdfDrawColor extends PdfRgbColor implements PdfDocumentUpdaterInterface
{
public function apply(PdfDocument $doc): void
{
$color = PdfRgbColor::instance($this->red, $this->green, $this->blue);
$doc->setDrawColor($color);
$doc->setDrawColor($this);
}

/**
* The default draw color is black.
* Gets the cell border color.
*
* The value is RGB(221, 221, 221).
*/
public static function default(): self
public static function cellBorder(): self
{
return self::black();
return new self(221, 221, 221);
}

/**
* Gets the default draw color (black).
*/
public static function default(): static
{
/** @psalm-var static */
return static::black();
}
}
Loading

0 comments on commit e2ebd43

Please sign in to comment.