pub struct Draw2D<'ctx>(/* private fields */);Implementations§
Source§impl<'ctx> Draw2D<'ctx>
impl<'ctx> Draw2D<'ctx>
Sourcepub fn text(&self, text: &str, at: Vec2, color: Color, shadow: bool)
pub fn text(&self, text: &str, at: Vec2, color: Color, shadow: bool)
Draws text at GUI position at, a drop shadow under it if shadow.
Sourcepub fn text_font(
&self,
text: &str,
font: &str,
at: Vec2,
color: Color,
shadow: bool,
)
pub fn text_font( &self, text: &str, font: &str, at: Vec2, color: Color, shadow: bool, )
Self::text in the font font (empty: the default one).
Sourcepub fn text_width(&self, text: &str, font: &str) -> f32
pub fn text_width(&self, text: &str, font: &str) -> f32
Width in GUI pixels of text in font (empty = default), measured by
the host’s text renderer.
Sourcepub fn gradient(&self, r: Rect, top: Color, bottom: Color)
pub fn gradient(&self, r: Rect, top: Color, bottom: Color)
Fills r with a vertical gradient, top to bottom.
Sourcepub fn item(&self, id: &str, at: Vec2, size: f32)
pub fn item(&self, id: &str, at: Vec2, size: f32)
Renders an item stack (3D block models included) via Minecraft’s item
renderer — like inventory slots or Patchouli’s item icons: item id
(minecraft:crafting_table) at at, size GUI pixels big (16 = an
inventory icon).
Sourcepub fn image(&self, source: &str, r: Rect)
pub fn image(&self, source: &str, r: Rect)
Draws the image source — a Yog image source such as "item:apple",
"block:stone", "sprite:button" or "mymod:gui/logo" (see
crate::image) — scaled into r. The host resolves it for its
Minecraft version.
Sourcepub fn image_region(
&self,
source: &str,
r: Rect,
region: Option<Rect>,
tint: Color,
)
pub fn image_region( &self, source: &str, r: Rect, region: Option<Rect>, tint: Color, )
Self::image drawing only region of it (in the image’s own
pixels; None = all of it) multiplied by tint (white = none).
Items and sprites are always drawn whole, and items ignore the tint.
Sourcepub fn svg(&self, data: &str, r: Rect)
pub fn svg(&self, data: &str, r: Rect)
Draws the SVG document data scaled into r (sharp at any GUI
scale: the host rasterizes it at the screen’s resolution). An .svg
file is an image source like any other — mymod:gui/logo.svg — for
Self::image.
Sourcepub fn text_scaled(&self, text: &str, at: Vec2, style: &TextStyle<'_>)
pub fn text_scaled(&self, text: &str, at: Vec2, style: &TextStyle<'_>)
text at at in style.
Sourcepub fn blocks(
&self,
blocks: &[((i32, i32, i32), &str)],
r: Rect,
yaw: f32,
pitch: f32,
)
pub fn blocks( &self, blocks: &[((i32, i32, i32), &str)], r: Rect, yaw: f32, pitch: f32, )
Draws blocks in 3D, as big as fits in r — a multiblock structure,
a block on display: each is ((x, y, z), state) with a full block
state (minecraft:furnace[facing=north]), turned yaw degrees about
the vertical and tilted pitch degrees toward the viewer (30 looks
down on it like Patchouli does).
Sourcepub fn entity(&self, entity: &str, r: Rect, yaw: f32, pitch: f32)
pub fn entity(&self, entity: &str, r: Rect, yaw: f32, pitch: f32)
Draws a living entity of type entity (minecraft:zombie,
mymod:wisp) standing in r, as big as fits, turned yaw degrees
(0 = facing the viewer) and tilted pitch degrees.
Sourcepub fn image_size(&self, source: &str) -> Option<Vec2>
pub fn image_size(&self, source: &str) -> Option<Vec2>
Natural size in GUI pixels of the image source (None if the host
can’t resolve it).