Struct extendr_api::graphics::Device
source · pub struct Device { /* private fields */ }
Implementations§
source§impl Device
impl Device
sourcepub fn device_number(&self) -> i32
pub fn device_number(&self) -> i32
Get the device number for this device.
sourcepub fn get_device(number: i32) -> Result<Device>
pub fn get_device(number: i32) -> Result<Device>
Get a device by number.
sourcepub fn from_device_coords(&self, value: (f64, f64), from: Unit) -> (f64, f64)
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.
sourcepub fn to_device_coords(&self, value: (f64, f64), to: Unit) -> (f64, f64)
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.
sourcepub fn from_device_wh(&self, value: (f64, f64), from: Unit) -> (f64, f64)
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.
sourcepub fn to_device_wh(&self, value: (f64, f64), to: Unit) -> (f64, f64)
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.
sourcepub fn line(&self, from: (f64, f64), to: (f64, f64), gc: &Context)
pub fn line(&self, from: (f64, f64), to: (f64, f64), gc: &Context)
Draw a stroked line. gc.color() is the stroke color.
sourcepub fn polyline<T: IntoIterator<Item = (f64, f64)>>(
&self,
coords: T,
gc: &Context
)
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.
sourcepub fn polygon<T: IntoIterator<Item = (f64, f64)>>(
&self,
coords: T,
gc: &Context
)
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.
sourcepub fn circle(&self, center: (f64, f64), radius: f64, gc: &Context)
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.
sourcepub fn rect(&self, from: (f64, f64), to: (f64, f64), gc: &Context)
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.
sourcepub fn path<T: IntoIterator<Item = impl IntoIterator<Item = (f64, f64)>>>(
&self,
coords: T,
winding: bool,
gc: &Context
)
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.
sourcepub fn capture(&self) -> Robj
pub fn capture(&self) -> Robj
Screen capture. Returns an integer matrix representing pixels if it is able.
sourcepub fn raster<T: AsRef<[u32]>>(
&self,
raster: Raster<T>,
pos: (f64, f64),
size: (f64, f64),
angle: f64,
interpolate: bool,
gc: &Context
)
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.
sourcepub fn text<T: AsRef<str>>(
&self,
pos: (f64, f64),
text: T,
center: (f64, f64),
rot: f64,
gc: &Context
)
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?
sourcepub fn symbol(&self, pos: (f64, f64), symbol: i32, size: f64, gc: &Context)
pub fn symbol(&self, pos: (f64, f64), symbol: i32, size: f64, gc: &Context)
Draw a special symbol centered on pos. See https://stat.ethz.ch/R-manual/R-devel/library/graphics/html/points.html
sourcepub fn char_metric(&self, c: char, gc: &Context) -> TextMetric
pub fn char_metric(&self, c: char, gc: &Context) -> TextMetric
Get the metrics for a single unicode codepoint.
sourcepub fn text_width<T: AsRef<str>>(&self, text: T, gc: &Context) -> f64
pub fn text_width<T: AsRef<str>>(&self, text: T, gc: &Context) -> f64
Get the width of a unicode string.
sourcepub fn text_height<T: AsRef<str>>(&self, text: T, gc: &Context) -> f64
pub fn text_height<T: AsRef<str>>(&self, text: T, gc: &Context) -> f64
Get the height of a unicode string.
sourcepub fn text_metric<T: AsRef<str>>(&self, text: T, gc: &Context) -> TextMetric
pub fn text_metric<T: AsRef<str>>(&self, text: T, gc: &Context) -> TextMetric
Get the metrics for a unicode string.
sourcepub fn math_text_width(&self, expr: &Robj, gc: &Context) -> f64
pub fn math_text_width(&self, expr: &Robj, gc: &Context) -> f64
Get the width of a mathematical expression.
sourcepub fn math_text_height(&self, expr: &Robj, gc: &Context) -> f64
pub fn math_text_height(&self, expr: &Robj, gc: &Context) -> f64
Get the height of a mathematical expression.
sourcepub fn math_text_metric(&self, expr: &Robj, gc: &Context) -> TextMetric
pub fn math_text_metric(&self, expr: &Robj, gc: &Context) -> TextMetric
Get the metrics for a mathematical expression.