Skip to main content

Draw2D

Struct Draw2D 

Source
pub struct Draw2D<'ctx>(/* private fields */);
Expand description

2D drawing helpers, valid only within on_hud_render.

Obtain via GfxContext::draw2d.

Implementations§

Source§

impl<'ctx> Draw2D<'ctx>

Source

pub fn text(&self, text: &str, x: f32, y: f32, color: u32, shadow: bool)

Draw a text string at GUI position (x, y). color is 0xAARRGGBB. shadow adds a drop-shadow.

Source

pub fn rect(&self, x1: f32, y1: f32, x2: f32, y2: f32, color: u32)

Fill a rectangle with a flat color (0xAARRGGBB).

Source

pub fn gradient( &self, x1: f32, y1: f32, x2: f32, y2: f32, top: u32, bottom: u32, )

Fill a rectangle with a vertical gradient (top → bottom, 0xAARRGGBB).

Source

pub fn mc_texture( &self, id: &str, x: f32, y: f32, u0: f32, v0: f32, w: f32, h: f32, tw: f32, th: f32, )

Blit a region from a Minecraft texture identified by namespace + path.

  • id: e.g. "minecraft:textures/gui/icons.png"
  • (x, y): screen position
  • (u0, v0): top-left UV in texels
  • (w, h): region size in pixels
  • (tw, th): full texture size in pixels

Auto Trait Implementations§

§

impl<'ctx> Freeze for Draw2D<'ctx>

§

impl<'ctx> RefUnwindSafe for Draw2D<'ctx>

§

impl<'ctx> Send for Draw2D<'ctx>

§

impl<'ctx> Sync for Draw2D<'ctx>

§

impl<'ctx> Unpin for Draw2D<'ctx>

§

impl<'ctx> UnsafeUnpin for Draw2D<'ctx>

§

impl<'ctx> UnwindSafe for Draw2D<'ctx>

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.