public function FocalPointManager::absoluteToRelative in Focal Point 8
Converts absolute focal point coordinates to relative coordinates.
Parameters
int $x: Absolute X coordinate of the focal point on the original image.
int $y: Absolute Y coordinate of the focal point on the original image.
int $width: Width of the original image.
int $height: Height of the original image.
Return value
array The relative coordinates of the focal point where each coordinate is a percentage. 'x' and 'y' are used for array keys and corresponding coordinates as values.
Overrides FocalPointManagerInterface::absoluteToRelative
See also
relativeToAbsolute
File
- src/
FocalPointManager.php, line 61
Class
- FocalPointManager
- Provides business logic related to focal point.
Namespace
Drupal\focal_pointCode
public function absoluteToRelative($x, $y, $width, $height) {
return [
'x' => $width ? (int) round($x / $width * 100) : 0,
'y' => $height ? (int) round($y / $height * 100) : 0,
];
}