-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFocalAreaBox.php
More file actions
70 lines (66 loc) · 2.51 KB
/
Copy pathFocalAreaBox.php
File metadata and controls
70 lines (66 loc) · 2.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
namespace MatchBot\Domain;
use Assert\Assertion;
use OpenApi\Attributes as OA;
/**
* Defines the position of focal area within an image, which should be preserved and if necessary enlarged
* when the image is presented on screen, despite the image needing to be cropped and have other content on top.
*
* All numbers are given as percentage of image dimensions, measured as displacement right and down from the top left
* corner. We use four numbers to define two opposite corners of the box.
*/
#[OA\Schema(description: "Defines the position of focal area within an image that should be preserved during cropping")]
readonly class FocalAreaBox
{
/**
* For now default position is always used - it's possible that the choosable focal position per meta-campaign
* was more than we needed. If that's confirmed we can get rid of this class and just hard-coded the position
* in the front end.
*/
public function __construct(
#[OA\Property(
property: "topLeftXpos",
description: "X position of the top-left corner as percentage from left (0-100)",
type: "integer",
minimum: 0,
maximum: 100,
example: 70
)]
public int $topLeftXpos = 70,
#[OA\Property(
property: "topLeftYpos",
description: "Y position of the top-left corner as percentage from top (0-100)",
type: "integer",
minimum: 0,
maximum: 100,
example: 47
)]
public int $topLeftYpos = 47,
#[OA\Property(
property: "bottomRightXpos",
description: "X position of the bottom-right corner as percentage from left (0-100)",
type: "integer",
minimum: 0,
maximum: 100,
example: 70
)]
public int $bottomRightXpos = 70,
#[OA\Property(
property: "bottomRightYpos",
description: "Y position of the bottom-right corner as percentage from top (0-100)",
type: "integer",
minimum: 0,
maximum: 100,
example: 47
)]
public int $bottomRightYpos = 47,
) {
Assertion::allBetween(
[$this->topLeftXpos, $this->topLeftYpos, $this->bottomRightXpos, $this->bottomRightYpos],
0,
100
);
Assertion::greaterOrEqualThan($this->bottomRightXpos, $this->topLeftXpos);
Assertion::greaterOrEqualThan($this->bottomRightYpos, $this->topLeftYpos);
}
}