extendr_api::graphics

Struct 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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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
§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

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>,

Source§

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>,

Source§

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.