pub struct FocalPoint { /* private fields */ }Expand description
A focal point: the spot a crop keeps in view, as fractions of the width
and height (0.0..=1.0).
PHP: the $x and $y arguments of crop().
use utopia_image::FocalPoint;
let point = FocalPoint::new(0.75, 0.5)?;
assert_eq!((point.x(), point.y()), (0.75, 0.5));
assert!(FocalPoint::new(1.1, 0.5).is_err());
assert!(FocalPoint::from_parts(Some(0.5), None).is_err());
assert_eq!(FocalPoint::from_parts(None, None)?, None);use Utopia\Image\Image;
$source = new \Imagick();
$source->newImage(6, 2, 'red', 'png');
$image = new Image($source->getImageBlob());
$image->crop(2, 2, x: 0.75, y: 0.5);
try {
$image->crop(2, 2, x: 1.1, y: 0.5);
} catch (\InvalidArgumentException $e) {
echo $e->getMessage(), "\n";
}Implementations§
Source§impl FocalPoint
impl FocalPoint
Sourcepub fn new(x: f64, y: f64) -> Result<Self>
pub fn new(x: f64, y: f64) -> Result<Self>
A focal point, refused unless both coordinates are finite and within
0.0..=1.0.
Trait Implementations§
Source§impl Clone for FocalPoint
impl Clone for FocalPoint
impl Copy for FocalPoint
Source§impl Debug for FocalPoint
impl Debug for FocalPoint
Source§impl PartialEq for FocalPoint
impl PartialEq for FocalPoint
impl StructuralPartialEq for FocalPoint
Auto Trait Implementations§
impl Forget for FocalPoint
impl Freeze for FocalPoint
impl Move for FocalPoint
impl RefUnwindSafe for FocalPoint
impl Send for FocalPoint
impl Sync for FocalPoint
impl Unpin for FocalPoint
impl UnsafeUnpin for FocalPoint
impl UnwindSafe for FocalPoint
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more