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>
impl<'dsp, 'surf> RenderContext<'dsp, 'surf>
sourcepub fn new(
display: &'dsp mut Display,
surface: &'surf mut Surface,
width: u32,
height: u32
) -> Result<Self, Error>
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
.
sourcepub unsafe fn new_unchecked(
display: &'dsp mut Display,
surface: &'surf mut Surface,
width: u32,
height: u32
) -> Result<Self, Error>
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<'_, '_>
impl Debug for RenderContext<'_, '_>
source§impl Drop for RenderContext<'_, '_>
impl Drop for RenderContext<'_, '_>
source§impl RenderContext for RenderContext<'_, '_>
impl RenderContext for RenderContext<'_, '_>
§type TextLayout = TextLayout
type TextLayout = TextLayout
The type use to represent text layout objects.
source§fn gradient(
&mut self,
gradient: impl Into<FixedGradient>
) -> Result<Self::Brush, Error>
fn gradient( &mut self, gradient: impl Into<FixedGradient> ) -> Result<Self::Brush, Error>
Create a new gradient brush.
source§fn stroke(
&mut self,
shape: impl Shape,
brush: &impl IntoBrush<Self>,
width: f64
)
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
)
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>)
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>)
fn fill_even_odd(&mut self, shape: impl Shape, brush: &impl IntoBrush<Self>)
Fill a shape, using the even-odd fill rule.
source§fn draw_text(&mut self, layout: &Self::TextLayout, pos: impl Into<Point>)
fn draw_text(&mut self, layout: &Self::TextLayout, pos: impl Into<Point>)
Draw a
TextLayout
. Read moresource§fn make_image(
&mut self,
width: usize,
height: usize,
buf: &[u8],
format: ImageFormat
) -> Result<Self::Image, Error>
fn make_image( &mut self, width: usize, height: usize, buf: &[u8], format: ImageFormat ) -> Result<Self::Image, Error>
source§fn draw_image(
&mut self,
image: &Self::Image,
dst_rect: impl Into<Rect>,
interp: InterpolationMode
)
fn draw_image( &mut self, image: &Self::Image, dst_rect: impl Into<Rect>, interp: InterpolationMode )
source§fn draw_image_area(
&mut self,
image: &Self::Image,
src_rect: impl Into<Rect>,
dst_rect: impl Into<Rect>,
interp: InterpolationMode
)
fn draw_image_area( &mut self, image: &Self::Image, src_rect: impl Into<Rect>, dst_rect: impl Into<Rect>, interp: InterpolationMode )
source§fn blurred_rect(
&mut self,
rect: Rect,
blur_radius: f64,
brush: &impl IntoBrush<Self>
)
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
fn current_transform(&self) -> Affine
Returns the transformations currently applied to the context.
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> 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<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere T: Any,
§fn into_any(self: Box<T, Global>) -> Box<dyn Any, Global>
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>
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)
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)
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> 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, U> RoundInto<U> for Twhere
U: RoundFrom<T>,
impl<T, U> RoundInto<U> for Twhere U: RoundFrom<T>,
source§fn round_into(self) -> U
fn round_into(self) -> U
Performs the conversion.