Skip to content

Commit

Permalink
Add tranformation matrix type and identity matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolaasuni committed Aug 29, 2024
1 parent 428e180 commit dc5d670
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.1.1
2.2.0
16 changes: 16 additions & 0 deletions src/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-pdf-graph
*
* @phpstan-type TTMatrix array{
* float,
* float,
* float,
* float,
* float,
* float,
* }
*
* @phpstan-type StyleData array{
* 'lineWidth': float,
* 'lineCap': string,
Expand Down Expand Up @@ -82,6 +91,13 @@ abstract class Base
*/
public const MPI = 3.14159265358979323846264338327950288419716939937510;

/**
* Identity matrix for transformations.
*
* @var TTMatrix
*/
public const IDMATRIX = [1.0, 0.0, 0.0, 1.0, 0.0, 0.0];

/**
* Current PDF object number
*/
Expand Down
14 changes: 8 additions & 6 deletions src/Transform.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
* @copyright 2011-2024 Nicola Asuni - Tecnick.com LTD
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
* @link https://github.com/tecnickcom/tc-lib-pdf-graph
*
* @phpstan-import-type TTMatrix from \Com\Tecnick\Pdf\Graph\Base
*/
abstract class Transform extends \Com\Tecnick\Pdf\Graph\Style
{
Expand All @@ -40,14 +42,14 @@ abstract class Transform extends \Com\Tecnick\Pdf\Graph\Style
* Array (stack) of Current Transformation Matrix (CTM),
* which maps user space coordinates used within a PDF content stream into output device coordinates.
*
* @var array<int, array<int, array<float>>>
* @var array<int, array<int, TTMatrix>>
*/
protected array $ctm = [];

/**
* Returns the transformation stack.
*
* @return array<int, array<int, array<float>>>
* @return array<int, array<int, TTMatrix>>
*/
public function getTransformStack(): array
{
Expand Down Expand Up @@ -92,7 +94,7 @@ public function getStopTransform(): string
/**
* Get the tranformation matrix (CTM) PDF string
*
* @param array<float> $ctm Transformation matrix array.
* @param TTMatrix $ctm Transformation matrix array.
*/
public function getTransformation(array $ctm): string
{
Expand Down Expand Up @@ -336,10 +338,10 @@ public function getVertSkewing(float $angy, float $posx, float $posy): string
/**
* Get the product of two Tranformation Matrix.
*
* @param array<float> $tma First Tranformation Matrix.
* @param array<float> $tmb Second Tranformation Matrix.
* @param TTMatrix $tma First Tranformation Matrix.
* @param TTMatrix $tmb Second Tranformation Matrix.
*
* @return array<float> CTM Transformation Matrix.
* @return TTMatrix CTM Transformation Matrix.
*/
public function getCtmProduct(array $tma, array $tmb): array
{
Expand Down

0 comments on commit dc5d670

Please sign in to comment.