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>
impl<'ctx> Draw2D<'ctx>
Sourcepub fn text(&self, text: &str, x: f32, y: f32, color: u32, shadow: bool)
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.
Sourcepub fn rect(&self, x1: f32, y1: f32, x2: f32, y2: f32, color: u32)
pub fn rect(&self, x1: f32, y1: f32, x2: f32, y2: f32, color: u32)
Fill a rectangle with a flat color (0xAARRGGBB).
Sourcepub fn gradient(
&self,
x1: f32,
y1: f32,
x2: f32,
y2: f32,
top: u32,
bottom: u32,
)
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).
Sourcepub fn mc_texture(
&self,
id: &str,
x: f32,
y: f32,
u0: f32,
v0: f32,
w: f32,
h: f32,
tw: f32,
th: f32,
)
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> 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