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<'_, '_>
Source§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> Freeze for RenderContext<'dsp, 'surf>
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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§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.Source§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.