pub struct ScreenSpace {
pub display: String,
pub origin: [f32; 2],
pub device_pixel_ratio: f32,
}Expand description
Logical screen points for actuation, from source pixels of a screenshot.
A screenshot of a 1512×982-point display at device pixel ratio 2 is 3024×1964 pixels;
to_points halves the coordinates before a click. A screen action’s
target is derived through this type from a region of a screenshot whose digest the
action records (V-I14).
§Example
use adk_vision::ScreenSpace;
let screen = ScreenSpace::new("built-in", [0.0, 0.0], 2.0);
assert_eq!(screen.to_points([3024.0, 1964.0]), [1512.0, 982.0]);Fields§
§display: StringThe display the screenshot shows.
origin: [f32; 2]The display’s top-left corner in the global point space.
device_pixel_ratio: f32Pixels per point.
Implementations§
Source§impl ScreenSpace
impl ScreenSpace
Sourcepub fn new(
display: impl Into<String>,
origin: [f32; 2],
device_pixel_ratio: f32,
) -> Self
pub fn new( display: impl Into<String>, origin: [f32; 2], device_pixel_ratio: f32, ) -> Self
A display at origin with its device pixel ratio.
Sourcepub fn to_points(&self, pixel: [f32; 2]) -> [f32; 2]
pub fn to_points(&self, pixel: [f32; 2]) -> [f32; 2]
Maps a screenshot pixel to logical screen points.
Sourcepub fn to_pixels(&self, point: [f32; 2]) -> [f32; 2]
pub fn to_pixels(&self, point: [f32; 2]) -> [f32; 2]
Maps logical screen points to a screenshot pixel.
Sourcepub fn bbox_to_points(&self, bbox: &BBox) -> BBox
pub fn bbox_to_points(&self, bbox: &BBox) -> BBox
Maps a box in screenshot pixels to logical screen points.
Trait Implementations§
Source§impl Clone for ScreenSpace
impl Clone for ScreenSpace
Source§impl Debug for ScreenSpace
impl Debug for ScreenSpace
Source§impl<'de> Deserialize<'de> for ScreenSpace
impl<'de> Deserialize<'de> for ScreenSpace
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for ScreenSpace
impl PartialEq for ScreenSpace
Source§impl Serialize for ScreenSpace
impl Serialize for ScreenSpace
impl StructuralPartialEq for ScreenSpace
Auto Trait Implementations§
impl Forget for ScreenSpace
impl Freeze for ScreenSpace
impl Move for ScreenSpace
impl RefUnwindSafe for ScreenSpace
impl Send for ScreenSpacewhere
RawVecInner: Send,
impl Sync for ScreenSpacewhere
RawVecInner: Sync,
impl Unpin for ScreenSpace
impl UnsafeUnpin for ScreenSpace
impl UnwindSafe for ScreenSpacewhere
RawVecInner: UnwindSafe,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Downcast for T
impl<T> Downcast for T
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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 moreSource§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
impl<T> MaybeSend for Twhere
T: Send,
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
impl<T> Scalar for T
impl<T> Scalar for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.