Skip to content

Commit

Permalink
Merge pull request #28 from erikn69/patch-2
Browse files Browse the repository at this point in the history
Fix Cannot redeclare deg2rad, tx, sx, rx functions
  • Loading branch information
dealfonso authored Oct 24, 2022
2 parents 01acefd + 4fe8e8b commit 93d7a8c
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions src/helpers/contentgeneration.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,20 @@
use function ddn\sapp\helpers\_parsepng;
use function ddn\sapp\helpers\p_error;

function tx($x, $y) {
return sprintf(" 1 0 0 1 %.2F %.2F cm", $x, $y);
}
function sx($w, $h) {
return sprintf(" %.2F 0 0 %.2F 0 0 cm", $w, $h);
}
function deg2rad($angle) {
return $angle * pi() / 180;
}
function rx($angle) {
$angle = deg2rad($angle);
return sprintf(" %.2F %.2F %.2F %.2F 0 0 cm", cos($angle), sin($angle), -sin($angle), cos($angle));
}

/**
* Creates an image object in the document, using the content of "info"
* NOTE: the image inclusion is taken from http://www.fpdf.org/; this is a translation
Expand Down Expand Up @@ -184,20 +198,6 @@ function _add_image($object_factory, $filename, $x=0, $y=0, $w=0, $h=0, $angle =
// Generate the command to translate and scale the image
$data = "q ";

function tx($x, $y) {
return sprintf(" 1 0 0 1 %.2F %.2F cm", $x, $y);
}
function sx($w, $h) {
return sprintf(" %.2F 0 0 %.2F 0 0 cm", $w, $h);
}
function deg2rad($angle) {
return $angle * pi() / 180;
}
function rx($angle) {
$angle = deg2rad($angle);
return sprintf(" %.2F %.2F %.2F %.2F 0 0 cm", cos($angle), sin($angle), -sin($angle), cos($angle));
}

if ($keep_proportions) {
$angleRads = deg2rad($angle);
$W = abs($w * cos($angleRads) + $h * sin($angleRads));
Expand Down

0 comments on commit 93d7a8c

Please sign in to comment.