Struct kludgine::tilemap::LayerContext
source · pub struct LayerContext<'render, 'ctx, 'pass> { /* private fields */ }
Implementations§
source§impl LayerContext<'_, '_, '_>
impl LayerContext<'_, '_, '_>
pub const fn top_left(&self) -> &TileOffset
pub const fn bottom_right(&self) -> &TileOffset
pub const fn tile_size(&self) -> Px
pub const fn origin(&self) -> Point<Px>
pub const fn visible_rect(&self) -> Rect<Px>
pub const fn elapsed(&self) -> Duration
pub const fn zoom(&self) -> f32
Methods from Deref<Target = Renderer<'ctx, 'pass>>§
sourcepub fn as_plot_area(
&mut self
) -> DrawingArea<PlotterBackend<'_, 'render, 'gfx>, Shift>
pub fn as_plot_area( &mut self ) -> DrawingArea<PlotterBackend<'_, 'render, 'gfx>, Shift>
Returns this renderer as a [DrawingArea
] compatible with the
plotters crate.
sourcepub fn measure_text<'a, Unit>(
&mut self,
text: impl Into<Text<'a, Unit>>
) -> MeasuredText<Unit>where
Unit: ScreenUnit,
pub fn measure_text<'a, Unit>(
&mut self,
text: impl Into<Text<'a, Unit>>
) -> MeasuredText<Unit>where
Unit: ScreenUnit,
Measures text
using the current text settings.
default_color
does not affect the
sourcepub fn draw_text<'a, Unit, Source>(&mut self, text: Source)
pub fn draw_text<'a, Unit, Source>(&mut self, text: Source)
Draws text
using the current text settings.
sourcepub fn draw_text_buffer<'a, Unit>(
&mut self,
buffer: impl Into<Drawable<&'a Buffer, Unit>>,
default_color: Color,
origin: TextOrigin<Px>
)where
Unit: ScreenUnit,
pub fn draw_text_buffer<'a, Unit>(
&mut self,
buffer: impl Into<Drawable<&'a Buffer, Unit>>,
default_color: Color,
origin: TextOrigin<Px>
)where
Unit: ScreenUnit,
Prepares the text layout contained in buffer
to be rendered.
When the text in buffer
has no color defined, default_color
will be
used.
origin
allows controlling how the text will be drawn relative to the
coordinate provided in render()
.
sourcepub fn measure_text_buffer<Unit>(
&mut self,
buffer: &Buffer,
default_color: Color
) -> MeasuredText<Unit>where
Unit: ScreenUnit,
pub fn measure_text_buffer<Unit>(
&mut self,
buffer: &Buffer,
default_color: Color
) -> MeasuredText<Unit>where
Unit: ScreenUnit,
Measures buffer
and caches the results using default_color
when
the buffer has no color associated with text.
sourcepub fn draw_measured_text<'a, Unit>(
&mut self,
text: impl Into<Drawable<&'a MeasuredText<Unit>, Unit>>,
origin: TextOrigin<Unit>
)where
Unit: ScreenUnit,
pub fn draw_measured_text<'a, Unit>(
&mut self,
text: impl Into<Drawable<&'a MeasuredText<Unit>, Unit>>,
origin: TextOrigin<Unit>
)where
Unit: ScreenUnit,
Prepares the text layout contained in buffer
to be rendered.
When the text in buffer
has no color defined, default_color
will be
used.
origin
allows controlling how the text will be drawn relative to the
coordinate provided in render()
.
sourcepub fn draw_shape<'shape, Unit>(
&mut self,
shape: impl Into<Drawable<&'shape Shape<Unit, false>, Unit>>
)where
Unit: Zero + ShaderScalable + ScreenUnit + Unit + Copy,
pub fn draw_shape<'shape, Unit>(
&mut self,
shape: impl Into<Drawable<&'shape Shape<Unit, false>, Unit>>
)where
Unit: Zero + ShaderScalable + ScreenUnit + Unit + Copy,
Draws a shape at the origin, rotating and scaling as needed.
sourcepub fn draw_texture<Unit>(
&mut self,
texture: &impl TextureSource,
destination: Rect<Unit>,
opacity: f32
)
pub fn draw_texture<Unit>( &mut self, texture: &impl TextureSource, destination: Rect<Unit>, opacity: f32 )
Draws texture
at destination
, scaling as necessary.
sourcepub fn draw_texture_at<Unit>(
&mut self,
texture: &impl TextureSource,
destination: Point<Unit>,
opacity: f32
)
pub fn draw_texture_at<Unit>( &mut self, texture: &impl TextureSource, destination: Point<Unit>, opacity: f32 )
Draws texture
at destination
.
sourcepub fn draw_textured_shape<'shape, Unit, Shape>(
&mut self,
shape: impl Into<Drawable<&'shape Shape, Unit>>,
texture: &impl TextureSource
)where
Unit: Zero + ShaderScalable + ScreenUnit + Unit + Copy,
i32: From<<Unit as IntoSigned>::Signed>,
Shape: ShapeSource<Unit, true> + 'shape,
pub fn draw_textured_shape<'shape, Unit, Shape>(
&mut self,
shape: impl Into<Drawable<&'shape Shape, Unit>>,
texture: &impl TextureSource
)where
Unit: Zero + ShaderScalable + ScreenUnit + Unit + Copy,
i32: From<<Unit as IntoSigned>::Signed>,
Shape: ShapeSource<Unit, true> + 'shape,
Draws a shape that was created with texture coordinates, applying the provided texture.
sourcepub fn vertex_count(&self) -> usize
pub fn vertex_count(&self) -> usize
Returns the number of vertexes that compose the drawing commands.
sourcepub fn triangle_count(&self) -> usize
pub fn triangle_count(&self) -> usize
Returns the number of triangles that are being rendered in the drawing commands.
sourcepub fn command_count(&self) -> usize
pub fn command_count(&self) -> usize
Returns the number of drawing operations that will be sent to the GPU
during render()
.
sourcepub fn clipped_to(&mut self, clip: Rect<UPx>) -> ClipGuard<'_, Self>
pub fn clipped_to(&mut self, clip: Rect<UPx>) -> ClipGuard<'_, Self>
Returns a ClipGuard
that causes all drawing operations to be offset
and clipped to clip
until it is dropped.
This function causes the Renderer
to act as if the origin of the
context is clip.origin
, and the size of the context is clip.size
.
This means that rendering at 0,0 will actually render at the effective
clip rect’s origin.
clip
is relative to the current clip rect and cannot extend the
current clipping rectangle.
Methods from Deref<Target = Graphics<'gfx>>§
sourcepub fn prepare_text(
&mut self,
buffer: &Buffer,
default_color: Color,
origin: TextOrigin<Px>
) -> PreparedText
pub fn prepare_text( &mut self, buffer: &Buffer, default_color: Color, origin: TextOrigin<Px> ) -> PreparedText
Prepares the text layout contained in buffer
to be rendered.
When the text in buffer
has no color defined, default_color
will be
used.
origin
allows controlling how the text will be drawn relative to the
coordinate provided in render()
.
sourcepub fn font_system(&mut self) -> &mut FontSystem
pub fn font_system(&mut self) -> &mut FontSystem
Returns a mutable reference to the [cosmic_text::FontSystem
] used when
rendering text.
sourcepub fn size(&self) -> Size<UPx>
pub fn size(&self) -> Size<UPx>
Returns the current clipped size of the context.
If this context has not been clipped, the value returned will be
equivalent to Kludgine::size
.
sourcepub fn clip_rect(&self) -> Rect<UPx>
pub fn clip_rect(&self) -> Rect<UPx>
Returns the current rectangular area of the context.
If this context has not been clipped, the value returned will be
equivalent to Kludgine::size
with an origin of 0,0
.
Methods from Deref<Target = Kludgine>§
sourcepub fn font_system(&mut self) -> &mut FontSystem
pub fn font_system(&mut self) -> &mut FontSystem
Returns a mutable reference to the [cosmic_text::FontSystem
] used when
rendering text.
sourcepub fn rebuild_font_system(&mut self)
pub fn rebuild_font_system(&mut self)
Rebuilds the font system, invalidating font database caches.
This function can be invoked after loading fonts into the font database to ensure that all future text rendering considers the newly loaded fonts.
sourcepub fn set_font_size(&mut self, size: impl ScreenScale<Lp = Lp>)
pub fn set_font_size(&mut self, size: impl ScreenScale<Lp = Lp>)
Sets the font size.
sourcepub fn set_line_height(&mut self, size: impl ScreenScale<Lp = Lp>)
pub fn set_line_height(&mut self, size: impl ScreenScale<Lp = Lp>)
Sets the line height for multi-line layout.
sourcepub fn line_height(&self) -> Lp
pub fn line_height(&self) -> Lp
Returns the current line height.
sourcepub fn set_font_family(&mut self, family: FamilyOwned)
pub fn set_font_family(&mut self, family: FamilyOwned)
Sets the current font family.
sourcepub fn font_family(&self) -> Family<'_>
pub fn font_family(&self) -> Family<'_>
Returns the current font family.
sourcepub fn set_font_style(&mut self, style: Style)
pub fn set_font_style(&mut self, style: Style)
Sets the current font style.
sourcepub fn font_style(&self) -> Style
pub fn font_style(&self) -> Style
Returns the current font style.
sourcepub fn set_font_weight(&mut self, weight: Weight)
pub fn set_font_weight(&mut self, weight: Weight)
Sets the current font weight.
sourcepub fn font_weight(&self) -> Weight
pub fn font_weight(&self) -> Weight
Returns the current font weight.
sourcepub fn set_text_stretch(&mut self, width: Stretch)
pub fn set_text_stretch(&mut self, width: Stretch)
Sets the current text stretching.
sourcepub fn text_stretch(&self) -> Stretch
pub fn text_stretch(&self) -> Stretch
Returns the current text stretch.
sourcepub fn text_attrs(&self) -> Attrs<'_>
pub fn text_attrs(&self) -> Attrs<'_>
Returns the current text attributes.
sourcepub fn set_text_attributes(&mut self, attrs: Attrs<'_>)
pub fn set_text_attributes(&mut self, attrs: Attrs<'_>)
Sets the current text attributes.
sourcepub fn reset_text_attributes(&mut self)
pub fn reset_text_attributes(&mut self)
Resets all of the text related properties to their default settings.
pub const REQURED_FEATURES: Features = wgpu::Features::PUSH_CONSTANTS
sourcepub fn id(&self) -> KludgineId
pub fn id(&self) -> KludgineId
Returns the unique id of this instance.
sourcepub fn resize(&mut self, new_size: Size<UPx>, new_scale: f32, queue: &Queue)
pub fn resize(&mut self, new_size: Size<UPx>, new_scale: f32, queue: &Queue)
Updates the size and scale of this Kludgine instance.
This function updates data stored in the GPU that affects how graphics
are rendered. It should be called before calling next_frame()
if the
size or scale of the underlying surface has changed.
sourcepub fn next_frame(&mut self) -> Frame<'_>
pub fn next_frame(&mut self) -> Frame<'_>
Begins rendering a new frame.
Trait Implementations§
source§impl<'ctx, 'pass> Deref for LayerContext<'_, 'ctx, 'pass>
impl<'ctx, 'pass> Deref for LayerContext<'_, 'ctx, 'pass>
Auto Trait Implementations§
impl<'render, 'ctx, 'pass> Freeze for LayerContext<'render, 'ctx, 'pass>
impl<'render, 'ctx, 'pass> !RefUnwindSafe for LayerContext<'render, 'ctx, 'pass>
impl<'render, 'ctx, 'pass> Send for LayerContext<'render, 'ctx, 'pass>
impl<'render, 'ctx, 'pass> Sync for LayerContext<'render, 'ctx, 'pass>
impl<'render, 'ctx, 'pass> Unpin for LayerContext<'render, 'ctx, 'pass>
impl<'render, 'ctx, 'pass> !UnwindSafe for LayerContext<'render, 'ctx, 'pass>
Blanket Implementations§
source§impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: Real + Zero + Arithmetics + Clone,
Swp: WhitePoint<T>,
Dwp: WhitePoint<T>,
D: AdaptFrom<S, Swp, Dwp, T>,
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: Real + Zero + Arithmetics + Clone,
Swp: WhitePoint<T>,
Dwp: WhitePoint<T>,
D: AdaptFrom<S, Swp, Dwp, T>,
source§fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<T>,
fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<T>,
source§fn adapt_into(self) -> D
fn adapt_into(self) -> D
source§impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
source§fn arrays_from(colors: C) -> T
fn arrays_from(colors: C) -> T
source§impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
source§fn arrays_into(self) -> C
fn arrays_into(self) -> C
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
source§impl<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
impl<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
§type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
parameters
when converting.source§fn cam16_into_unclamped(
self,
parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>
) -> T
fn cam16_into_unclamped( self, parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar> ) -> T
self
into C
, using the provided parameters.§impl<A> Cast for A
impl<A> Cast for A
source§impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
source§fn components_from(colors: C) -> T
fn components_from(colors: C) -> T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
&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)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
source§impl<T> FromAngle<T> for T
impl<T> FromAngle<T> for T
source§fn from_angle(angle: T) -> T
fn from_angle(angle: T) -> T
angle
.source§impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
source§fn from_stimulus(other: U) -> T
fn from_stimulus(other: U) -> T
other
into Self
, while performing the appropriate scaling,
rounding and clamping.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
source§fn into_angle(self) -> U
fn into_angle(self) -> U
T
.source§impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
§type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
parameters
when converting.source§fn into_cam16_unclamped(
self,
parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>
) -> T
fn into_cam16_unclamped( self, parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar> ) -> T
self
into C
, using the provided parameters.source§impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
source§fn into_color(self) -> U
fn into_color(self) -> U
source§impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
source§fn into_color_unclamped(self) -> U
fn into_color_unclamped(self) -> U
source§impl<T> IntoStimulus<T> for T
impl<T> IntoStimulus<T> for T
source§fn into_stimulus(self) -> T
fn into_stimulus(self) -> T
self
into T
, while performing the appropriate scaling,
rounding and clamping.source§impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
§type Error = <C as TryFromComponents<T>>::Error
type Error = <C as TryFromComponents<T>>::Error
try_into_colors
fails to cast.source§fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
source§impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
source§fn try_into_color(self) -> Result<U, OutOfBounds<U>>
fn try_into_color(self) -> Result<U, OutOfBounds<U>>
OutOfBounds
error is returned which contains
the unclamped color. Read more