Struct extendr_api::graphics::Device

source ·
pub struct Device {
    inner: pGEDevDesc,
}

Fields§

§inner: pGEDevDesc

Implementations§

source§

impl Device

source

pub(crate) fn inner(&self) -> pGEDevDesc

source§

impl Device

source

pub fn current() -> Result<Device>

Get the current device.

source

pub fn mode_on(&self) -> Result<()>

Enable device rendering.

source

pub fn mode_off(&self) -> Result<()>

Disable device rendering and flush.

source

pub fn device_number(&self) -> i32

Get the device number for this device.

source

pub fn get_device(number: i32) -> Result<Device>

Get a device by number.

source

pub fn from_device_coords(&self, value: (f64, f64), from: Unit) -> (f64, f64)

Convert device coordinates into a specified unit. This is usually done by the API.

source

pub fn to_device_coords(&self, value: (f64, f64), to: Unit) -> (f64, f64)

Convert a specified unit coordinates into device coordinates. This is usually done by the API.

source

pub fn from_device_wh(&self, value: (f64, f64), from: Unit) -> (f64, f64)

Convert device width/height coordinates into a specified unit. This is usually done by the API.

source

pub fn to_device_wh(&self, value: (f64, f64), to: Unit) -> (f64, f64)

Convert a specified unit width/height coordinates into device coordinates. This is usually done by the API.

source

pub fn new_page(&self, gc: &Context)

Start a new page. The page color can be set in advance.

source

pub fn clip(&self, from: (f64, f64), to: (f64, f64), gc: &Context)

Change the clip rectangle.

source

pub fn line(&self, from: (f64, f64), to: (f64, f64), gc: &Context)

Draw a stroked line. gc.color() is the stroke color.

source

pub fn polyline<T: IntoIterator<Item = (f64, f64)>>( &self, coords: T, gc: &Context )

Draw a stroked/filled polyline. gc.color() is the stroke color. The input is anything yielding (x,y) coordinate pairs. Polylines are not closed.

source

pub fn polygon<T: IntoIterator<Item = (f64, f64)>>( &self, coords: T, gc: &Context )

Draw a stroked/filled polygon. gc.color() is the stroke color. The input is anything yielding (x,y) coordinate pairs. Polygons are closed.

source

pub fn circle(&self, center: (f64, f64), radius: f64, gc: &Context)

Draw a stroked/filled circle. gc.color() is the stroke color. gc.fill() is the fill color.

source

pub fn rect(&self, from: (f64, f64), to: (f64, f64), gc: &Context)

Draw a stroked/filled axis-aligned rectangle. gc.color() is the stroke color. gc.fill() is the fill color.

source

pub fn path<T: IntoIterator<Item = impl IntoIterator<Item = (f64, f64)>>>( &self, coords: T, winding: bool, gc: &Context )

Draw a path with multiple segments. gc.color() is the stroke color. gc.fill() is the fill color. The input is an interator of iterators yielding (x,y) pairs.

source

pub fn capture(&self) -> Robj

Screen capture. Returns an integer matrix representing pixels if it is able.

source

pub fn raster<T: AsRef<[u32]>>( &self, raster: Raster<T>, pos: (f64, f64), size: (f64, f64), angle: f64, interpolate: bool, gc: &Context )

Draw a bitmap.

source

pub fn text<T: AsRef<str>>( &self, pos: (f64, f64), text: T, center: (f64, f64), rot: f64, gc: &Context )

Draw a text string starting at pos. TODO: do we need to convert units?

source

pub fn symbol(&self, pos: (f64, f64), symbol: i32, size: f64, gc: &Context)

source

pub fn char_metric(&self, c: char, gc: &Context) -> TextMetric

Get the metrics for a single unicode codepoint.

source

pub fn text_width<T: AsRef<str>>(&self, text: T, gc: &Context) -> f64

Get the width of a unicode string.

source

pub fn text_height<T: AsRef<str>>(&self, text: T, gc: &Context) -> f64

Get the height of a unicode string.

source

pub fn text_metric<T: AsRef<str>>(&self, text: T, gc: &Context) -> TextMetric

Get the metrics for a unicode string.

source

pub fn math_text_width(&self, expr: &Robj, gc: &Context) -> f64

Get the width of a mathematical expression.

source

pub fn math_text_height(&self, expr: &Robj, gc: &Context) -> f64

Get the height of a mathematical expression.

source

pub fn math_text_metric(&self, expr: &Robj, gc: &Context) -> TextMetric

Get the metrics for a mathematical expression.

source

pub fn math_text( &self, expr: &Robj, pos: (f64, f64), center: (f64, f64), rot: f64, gc: &Context )

Draw a mathematical expression.

Trait Implementations§

source§

impl Clone for Device

source§

fn clone(&self) -> Device

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Device

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl PartialEq for Device

source§

fn eq(&self, other: &Device) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl StructuralPartialEq for Device

Auto Trait Implementations§

§

impl Freeze for Device

§

impl RefUnwindSafe for Device

§

impl !Send for Device

§

impl !Sync for Device

§

impl Unpin for Device

§

impl UnwindSafe for Device

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.