pub struct Text {
pub position: Point2<i16>,
pub text: CString,
pub font: Font,
pub horizontal_align: HAlign,
pub vertical_align: VAlign,
}
Expand description
A piece of text that can be drawn on the display.
Fields§
§position: Point2<i16>
Top left corner coordinates of text on the display
text: CString
C-String of the desired text to be displayed on the display
font: Font
The font that will be used when this text is displayed
horizontal_align: HAlign
Horizontal alignment of text displayed on the display
vertical_align: VAlign
Vertical alignment of text displayed on the display
Implementations§
Source§impl Text
impl Text
Sourcepub fn new(text: &str, font: Font, position: impl Into<Point2<i16>>) -> Self
pub fn new(text: &str, font: Font, position: impl Into<Point2<i16>>) -> Self
Create a new text with a given position (defaults to top left corner alignment) and font
Sourcepub fn new_aligned(
text: &str,
font: Font,
position: impl Into<Point2<i16>>,
horizontal_align: HAlign,
vertical_align: VAlign,
) -> Self
pub fn new_aligned( text: &str, font: Font, position: impl Into<Point2<i16>>, horizontal_align: HAlign, vertical_align: VAlign, ) -> Self
Create a new text with a given position (based on alignment) and font
Source§impl Text
impl Text
Sourcepub fn draw(
&self,
_display: &mut Display,
color: impl Into<Rgb<u8>>,
bg_color: Option<Rgb<u8>>,
)
pub fn draw( &self, _display: &mut Display, color: impl Into<Rgb<u8>>, bg_color: Option<Rgb<u8>>, )
Write the text to the display.
§Arguments
display
- The display to write the text to.color
- The color of the text.bg_color
- The background color of the text. IfNone
, the background will be transparent.
Trait Implementations§
impl Eq for Text
impl StructuralPartialEq for Text
Auto Trait Implementations§
impl Freeze for Text
impl RefUnwindSafe for Text
impl Send for Text
impl Sync for Text
impl Unpin for Text
impl UnwindSafe for Text
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