EpsImageBackEnd.php
9 months ago
ImageBackEndInterface.php
9 months ago
ImagickImageBackEnd.php
9 months ago
SvgImageBackEnd.php
9 months ago
TransformationMatrix.php
9 months ago
ImageBackEndInterface.php
88 lines
| 1 | <?php |
| 2 | declare(strict_types = 1); |
| 3 | |
| 4 | namespace BaconQrCode\Renderer\Image; |
| 5 | |
| 6 | use BaconQrCode\Exception\RuntimeException; |
| 7 | use BaconQrCode\Renderer\Color\ColorInterface; |
| 8 | use BaconQrCode\Renderer\Path\Path; |
| 9 | use BaconQrCode\Renderer\RendererStyle\Gradient; |
| 10 | |
| 11 | /** |
| 12 | * Interface for back ends able to to produce path based images. |
| 13 | */ |
| 14 | interface ImageBackEndInterface |
| 15 | { |
| 16 | /** |
| 17 | * Starts a new image. |
| 18 | * |
| 19 | * If a previous image was already started, previous data get erased. |
| 20 | */ |
| 21 | public function new(int $size, ColorInterface $backgroundColor) : void; |
| 22 | |
| 23 | /** |
| 24 | * Transforms all following drawing operation coordinates by scaling them by a given factor. |
| 25 | * |
| 26 | * @throws RuntimeException if no image was started yet. |
| 27 | */ |
| 28 | public function scale(float $size) : void; |
| 29 | |
| 30 | /** |
| 31 | * Transforms all following drawing operation coordinates by translating them by a given amount. |
| 32 | * |
| 33 | * @throws RuntimeException if no image was started yet. |
| 34 | */ |
| 35 | public function translate(float $x, float $y) : void; |
| 36 | |
| 37 | /** |
| 38 | * Transforms all following drawing operation coordinates by rotating them by a given amount. |
| 39 | * |
| 40 | * @throws RuntimeException if no image was started yet. |
| 41 | */ |
| 42 | public function rotate(int $degrees) : void; |
| 43 | |
| 44 | /** |
| 45 | * Pushes the current coordinate transformation onto a stack. |
| 46 | * |
| 47 | * @throws RuntimeException if no image was started yet. |
| 48 | */ |
| 49 | public function push() : void; |
| 50 | |
| 51 | /** |
| 52 | * Pops the last coordinate transformation from a stack. |
| 53 | * |
| 54 | * @throws RuntimeException if no image was started yet. |
| 55 | */ |
| 56 | public function pop() : void; |
| 57 | |
| 58 | /** |
| 59 | * Draws a path with a given color. |
| 60 | * |
| 61 | * @throws RuntimeException if no image was started yet. |
| 62 | */ |
| 63 | public function drawPathWithColor(Path $path, ColorInterface $color) : void; |
| 64 | |
| 65 | /** |
| 66 | * Draws a path with a given gradient which spans the box described by the position and size. |
| 67 | * |
| 68 | * @throws RuntimeException if no image was started yet. |
| 69 | */ |
| 70 | public function drawPathWithGradient( |
| 71 | Path $path, |
| 72 | Gradient $gradient, |
| 73 | float $x, |
| 74 | float $y, |
| 75 | float $width, |
| 76 | float $height |
| 77 | ) : void; |
| 78 | |
| 79 | /** |
| 80 | * Ends the image drawing operation and returns the resulting blob. |
| 81 | * |
| 82 | * This should reset the state of the back end and thus this method should only be callable once per image. |
| 83 | * |
| 84 | * @throws RuntimeException if no image was started yet. |
| 85 | */ |
| 86 | public function done() : string; |
| 87 | } |
| 88 |