Struct arcdps_imgui::draw_list::DrawListMut
source · pub struct DrawListMut<'ui> { /* private fields */ }
Expand description
Object implementing the custom draw API.
Called from Ui::get_window_draw_list
, Ui::get_background_draw_list
or Ui::get_foreground_draw_list
.
No more than one instance of this structure can live in a program at the same time.
The program will panic on creating a second instance.
Implementations§
source§impl<'ui> DrawListMut<'ui>
impl<'ui> DrawListMut<'ui>
sourcepub fn channels_split<F: FnOnce(&ChannelsSplit<'_>)>(
&self,
channels_count: u32,
f: F
)
pub fn channels_split<F: FnOnce(&ChannelsSplit<'_>)>( &self, channels_count: u32, f: F )
Split into channels_count drawing channels. At the end of the closure, the channels are merged. The objects are then drawn in the increasing order of their channel number, and not in the order they were called.
§Example
fn custom_drawing(ui: &Ui) {
let draw_list = ui.get_window_draw_list();
draw_list.channels_split(2, |channels| {
channels.set_current(1);
// ... Draw channel 1
channels.set_current(0);
// ... Draw channel 0
});
}
source§impl<'ui> DrawListMut<'ui>
impl<'ui> DrawListMut<'ui>
Drawing functions
sourcepub fn add_line<C>(&'ui self, p1: [f32; 2], p2: [f32; 2], c: C) -> Line<'ui>
pub fn add_line<C>(&'ui self, p1: [f32; 2], p2: [f32; 2], c: C) -> Line<'ui>
Returns a line from point p1
to p2
with color c
.
sourcepub fn add_rect<C>(&'ui self, p1: [f32; 2], p2: [f32; 2], c: C) -> Rect<'ui>
pub fn add_rect<C>(&'ui self, p1: [f32; 2], p2: [f32; 2], c: C) -> Rect<'ui>
Returns a rectangle whose upper-left corner is at point p1
and lower-right corner is at point p2
, with color c
.
sourcepub fn add_rect_filled_multicolor<C1, C2, C3, C4>(
&self,
p1: [f32; 2],
p2: [f32; 2],
col_upr_left: C1,
col_upr_right: C2,
col_bot_right: C3,
col_bot_left: C4
)
pub fn add_rect_filled_multicolor<C1, C2, C3, C4>( &self, p1: [f32; 2], p2: [f32; 2], col_upr_left: C1, col_upr_right: C2, col_bot_right: C3, col_bot_left: C4 )
Draw a rectangle whose upper-left corner is at point p1
and lower-right corner is at point p2
.
The remains parameters are the respective color of the corners
in the counter-clockwise starting from the upper-left corner
first.
sourcepub fn add_triangle<C>(
&'ui self,
p1: [f32; 2],
p2: [f32; 2],
p3: [f32; 2],
c: C
) -> Triangle<'ui>
pub fn add_triangle<C>( &'ui self, p1: [f32; 2], p2: [f32; 2], p3: [f32; 2], c: C ) -> Triangle<'ui>
Returns a triangle with the given 3 vertices p1
, p2
and p3
and color c
.
sourcepub fn add_circle<C>(
&'ui self,
center: [f32; 2],
radius: f32,
color: C
) -> Circle<'ui>
pub fn add_circle<C>( &'ui self, center: [f32; 2], radius: f32, color: C ) -> Circle<'ui>
Returns a circle with the given center
, radius
and color
.
sourcepub fn add_text<C, T>(&self, pos: [f32; 2], col: C, text: T)
pub fn add_text<C, T>(&self, pos: [f32; 2], col: C, text: T)
Draw a text whose upper-left corner is at point pos
.
sourcepub fn add_bezier_curve<C>(
&'ui self,
pos0: [f32; 2],
cp0: [f32; 2],
cp1: [f32; 2],
pos1: [f32; 2],
color: C
) -> BezierCurve<'ui>
pub fn add_bezier_curve<C>( &'ui self, pos0: [f32; 2], cp0: [f32; 2], cp1: [f32; 2], pos1: [f32; 2], color: C ) -> BezierCurve<'ui>
Returns a Bezier curve stretching from pos0
to pos1
, whose
curvature is defined by cp0
and cp1
.
source§impl<'ui> DrawListMut<'ui>
impl<'ui> DrawListMut<'ui>
§Images
sourcepub fn add_image(
&'ui self,
texture_id: TextureId,
p_min: [f32; 2],
p_max: [f32; 2]
) -> Image<'_>
pub fn add_image( &'ui self, texture_id: TextureId, p_min: [f32; 2], p_max: [f32; 2] ) -> Image<'_>
Draw the specified image in the rect specified by p_min
to
p_max
.
§Examples
fn custom_button(ui: &Ui, img_id: TextureId) {
// Invisible button is good widget to customise with image
ui.invisible_button(im_str!("custom_button"), [100.0, 20.0]);
// Get draw list and draw image over invisible button
let draw_list = ui.get_window_draw_list();
draw_list
.add_image(img_id, ui.item_rect_min(), ui.item_rect_max())
.build();
}
sourcepub fn add_image_quad(
&'ui self,
texture_id: TextureId,
p1: [f32; 2],
p2: [f32; 2],
p3: [f32; 2],
p4: [f32; 2]
) -> ImageQuad<'_>
pub fn add_image_quad( &'ui self, texture_id: TextureId, p1: [f32; 2], p2: [f32; 2], p3: [f32; 2], p4: [f32; 2] ) -> ImageQuad<'_>
Draw the specified image to a quad with the specified
coordinates. Similar to DrawListMut::add_image
but this
method is able to draw non-rectangle images.
sourcepub fn add_image_rounded(
&'ui self,
texture_id: TextureId,
p_min: [f32; 2],
p_max: [f32; 2],
rounding: f32
) -> ImageRounded<'_>
pub fn add_image_rounded( &'ui self, texture_id: TextureId, p_min: [f32; 2], p_max: [f32; 2], rounding: f32 ) -> ImageRounded<'_>
Draw the speciied image, with rounded corners