pub struct Graphics<'gfx> { /* private fields */ }
Expand description
A context used to prepare graphics to render.
This type is used in these APIs:
Implementations§
source§impl<'gfx> Graphics<'gfx>
impl<'gfx> 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()
.
source§impl<'gfx> Graphics<'gfx>
impl<'gfx> Graphics<'gfx>
sourcepub fn new(
kludgine: &'gfx mut Kludgine,
device: &'gfx Device,
queue: &'gfx Queue,
) -> Self
pub fn new( kludgine: &'gfx mut Kludgine, device: &'gfx Device, queue: &'gfx Queue, ) -> Self
Returns a new instance.
sourcepub const fn device(&self) -> &'gfx Device
pub const fn device(&self) -> &'gfx Device
Returns a reference to the underlying wgpu::Device
.
sourcepub const fn queue(&self) -> &'gfx Queue
pub const fn queue(&self) -> &'gfx Queue
Returns a reference to the underlying wgpu::Queue
.
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 const fn size(&self) -> Size<UPx>
pub const 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 const fn clip_rect(&self) -> Rect<UPx>
pub const 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: impl Into<Fraction>,
new_zoom: impl Into<Fraction>,
queue: &Queue,
)
pub fn resize( &mut self, new_size: Size<UPx>, new_scale: impl Into<Fraction>, new_zoom: impl Into<Fraction>, 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 set_zoom(&mut self, new_zoom: impl Into<Fraction>, queue: &Queue)
pub fn set_zoom(&mut self, new_zoom: impl Into<Fraction>, queue: &Queue)
Sets the current zoom level.
Zoom and DPI scale are multiplied to create an effective scale for all DPI-scaled operations.
sourcepub fn set_dpi_scale(&mut self, new_scale: impl Into<Fraction>, queue: &Queue)
pub fn set_dpi_scale(&mut self, new_scale: impl Into<Fraction>, queue: &Queue)
Sets the current DPI scale.
This scaling factor should come from the window server when possible.
sourcepub fn next_frame(&mut self) -> Frame<'_>
pub fn next_frame(&mut self) -> Frame<'_>
Begins rendering a new frame.
Trait Implementations§
source§impl Clipped for Graphics<'_>
impl Clipped for Graphics<'_>
impl KludgineGraphics for Graphics<'_>
Auto Trait Implementations§
impl<'gfx> Freeze for Graphics<'gfx>
impl<'gfx> !RefUnwindSafe for Graphics<'gfx>
impl<'gfx> Send for Graphics<'gfx>
impl<'gfx> Sync for Graphics<'gfx>
impl<'gfx> Unpin for Graphics<'gfx>
impl<'gfx> !UnwindSafe for Graphics<'gfx>
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>,
source§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.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
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.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> 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>,
source§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> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§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> Pointable for T
impl<T> Pointable for T
source§impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
source§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