Struct theo::RenderContext

source ·
pub struct RenderContext<'dsp, 'surf> { /* private fields */ }
Expand description

The context used to draw to a Surface.

This is the whole point of this crate, and is the aperture used to actually draw with vector graphics. It’s created from a Display and a Surface, and can be used to draw to the surface.

See the RenderContext documentation for more information.

Implementations§

source§

impl<'dsp, 'surf> RenderContext<'dsp, 'surf>

source

pub fn new( display: &'dsp mut Display, surface: &'surf mut Surface, width: u32, height: u32 ) -> Result<Self, Error>

Create a new RenderContext from a Surface and a Display.

This creates a new RenderContext from a Surface and a Display. This is the only way to create a RenderContext.

source

pub unsafe fn new_unchecked( display: &'dsp mut Display, surface: &'surf mut Surface, width: u32, height: u32 ) -> Result<Self, Error>

Create a new RenderContext without checking for exclusive access.

Safety

The same as new, but you need to make sure that there are no other OpenGL contexts active on the current thread.

Trait Implementations§

source§

impl Debug for RenderContext<'_, '_>

source§

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

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

impl Drop for RenderContext<'_, '_>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl RenderContext for RenderContext<'_, '_>

§

type Brush = Brush

The type of a “brush”. Read more
§

type Image = Image

The associated type of an image.
§

type Text = Text

An associated factory for creating text layouts and related resources.
§

type TextLayout = TextLayout

The type use to represent text layout objects.
source§

fn status(&mut self) -> Result<(), Error>

Report an internal error. Read more
source§

fn solid_brush(&mut self, color: Color) -> Self::Brush

Create a new brush resource. Read more
source§

fn gradient( &mut self, gradient: impl Into<FixedGradient> ) -> Result<Self::Brush, Error>

Create a new gradient brush.
source§

fn clear(&mut self, region: impl Into<Option<Rect>>, color: Color)

Replace a region of the canvas with the provided Color. Read more
source§

fn stroke( &mut self, shape: impl Shape, brush: &impl IntoBrush<Self>, width: f64 )

Stroke a [Shape], using the default StrokeStyle.
source§

fn stroke_styled( &mut self, shape: impl Shape, brush: &impl IntoBrush<Self>, width: f64, style: &StrokeStyle )

Stroke a [Shape], providing a custom StrokeStyle.
source§

fn fill(&mut self, shape: impl Shape, brush: &impl IntoBrush<Self>)

Fill a [Shape], using the non-zero fill rule.
source§

fn fill_even_odd(&mut self, shape: impl Shape, brush: &impl IntoBrush<Self>)

Fill a shape, using the even-odd fill rule.
source§

fn clip(&mut self, shape: impl Shape)

Clip to a [Shape]. Read more
source§

fn text(&mut self) -> &mut Self::Text

Returns a reference to a shared Text object. Read more
source§

fn draw_text(&mut self, layout: &Self::TextLayout, pos: impl Into<Point>)

source§

fn save(&mut self) -> Result<(), Error>

Save the context state. Read more
source§

fn restore(&mut self) -> Result<(), Error>

Restore the context state. Read more
source§

fn finish(&mut self) -> Result<(), Error>

Finish any pending operations. Read more
source§

fn transform(&mut self, transform: Affine)

Apply a transform. Read more
source§

fn make_image( &mut self, width: usize, height: usize, buf: &[u8], format: ImageFormat ) -> Result<Self::Image, Error>

Create a new Image from a pixel buffer. Read more
source§

fn draw_image( &mut self, image: &Self::Image, dst_rect: impl Into<Rect>, interp: InterpolationMode )

Draw an Image into the provided [Rect]. Read more
source§

fn draw_image_area( &mut self, image: &Self::Image, src_rect: impl Into<Rect>, dst_rect: impl Into<Rect>, interp: InterpolationMode )

Draw a specified area of an Image. Read more
source§

fn capture_image_area( &mut self, src_rect: impl Into<Rect> ) -> Result<Self::Image, Error>

Create an Image of the specified region of the context. Read more
source§

fn blurred_rect( &mut self, rect: Rect, blur_radius: f64, brush: &impl IntoBrush<Self> )

Draw a rectangle with Gaussian blur. Read more
source§

fn current_transform(&self) -> Affine

Returns the transformations currently applied to the context.
source§

fn with_save( &mut self, f: impl FnOnce(&mut Self) -> Result<(), Error> ) -> Result<(), Error>

Do graphics operations with the context state saved and then restored. Read more
source§

impl IntoBrush<RenderContext<'_, '_>> for Brush

Auto Trait Implementations§

§

impl<'dsp, 'surf> !RefUnwindSafe for RenderContext<'dsp, 'surf>

§

impl<'dsp, 'surf> !Send for RenderContext<'dsp, 'surf>

§

impl<'dsp, 'surf> !Sync for RenderContext<'dsp, 'surf>

§

impl<'dsp, 'surf> Unpin for RenderContext<'dsp, 'surf>

§

impl<'dsp, 'surf> !UnwindSafe for RenderContext<'dsp, 'surf>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

impl<T> Downcast for Twhere T: Any,

§

fn into_any(self: Box<T, Global>) -> Box<dyn Any, Global>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T, Global>) -> Rc<dyn Any, Global>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere 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> RoundFrom<T> for T

source§

fn round_from(x: T) -> T

Performs the conversion.
source§

impl<T, U> RoundInto<U> for Twhere U: RoundFrom<T>,

source§

fn round_into(self) -> U

Performs the conversion.
source§

impl<T, U> TryFrom<U> for Twhere 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 Twhere 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.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more