PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 2.4.4
Booking for Appointments and Events Calendar – Amelia v2.4.4
2.4.4 2.4.3 2.4.2 2.4.1 2.4 trunk 1.2.1 1.2.10 1.2.11 1.2.12 1.2.13 1.2.14 1.2.15 1.2.16 1.2.17 1.2.18 1.2.19 1.2.2 1.2.20 1.2.21 1.2.22 1.2.23 1.2.24 1.2.25 1.2.26 1.2.27 1.2.28 1.2.29 1.2.3 1.2.30 1.2.31 1.2.32 1.2.33 1.2.34 1.2.35 1.2.36 1.2.37 1.2.38 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.1.3 2.2 2.2.1 2.3
ameliabooking / vendor / bacon / bacon-qr-code / src / Renderer / Image / TransformationMatrix.php
ameliabooking / vendor / bacon / bacon-qr-code / src / Renderer / Image Last commit date
EpsImageBackEnd.php 8 months ago ImageBackEndInterface.php 8 months ago ImagickImageBackEnd.php 8 months ago SvgImageBackEnd.php 8 months ago TransformationMatrix.php 8 months ago
TransformationMatrix.php
69 lines
1 <?php
2 declare(strict_types = 1);
3
4 namespace BaconQrCode\Renderer\Image;
5
6 final class TransformationMatrix
7 {
8 /**
9 * @var float[]
10 */
11 private $values;
12
13 public function __construct()
14 {
15 $this->values = [1, 0, 0, 1, 0, 0];
16 }
17
18 public function multiply(self $other) : self
19 {
20 $matrix = new self();
21 $matrix->values[0] = $this->values[0] * $other->values[0] + $this->values[2] * $other->values[1];
22 $matrix->values[1] = $this->values[1] * $other->values[0] + $this->values[3] * $other->values[1];
23 $matrix->values[2] = $this->values[0] * $other->values[2] + $this->values[2] * $other->values[3];
24 $matrix->values[3] = $this->values[1] * $other->values[2] + $this->values[3] * $other->values[3];
25 $matrix->values[4] = $this->values[0] * $other->values[4] + $this->values[2] * $other->values[5]
26 + $this->values[4];
27 $matrix->values[5] = $this->values[1] * $other->values[4] + $this->values[3] * $other->values[5]
28 + $this->values[5];
29
30 return $matrix;
31 }
32
33 public static function scale(float $size) : self
34 {
35 $matrix = new self();
36 $matrix->values = [$size, 0, 0, $size, 0, 0];
37 return $matrix;
38 }
39
40 public static function translate(float $x, float $y) : self
41 {
42 $matrix = new self();
43 $matrix->values = [1, 0, 0, 1, $x, $y];
44 return $matrix;
45 }
46
47 public static function rotate(int $degrees) : self
48 {
49 $matrix = new self();
50 $rad = deg2rad($degrees);
51 $matrix->values = [cos($rad), sin($rad), -sin($rad), cos($rad), 0, 0];
52 return $matrix;
53 }
54
55
56 /**
57 * Applies this matrix onto a point and returns the resulting viewport point.
58 *
59 * @return float[]
60 */
61 public function apply(float $x, float $y) : array
62 {
63 return [
64 $x * $this->values[0] + $y * $this->values[2] + $this->values[4],
65 $x * $this->values[1] + $y * $this->values[3] + $this->values[5],
66 ];
67 }
68 }
69