pub struct Text {
pub text: String,
pub color: Color,
pub font_size: u16,
pub font_name: String,
pub font_style: FontStyle,
}
Fields§
§text: String
§color: Color
§font_size: u16
§font_name: String
§font_style: FontStyle
Implementations§
Source§impl Text
impl Text
Sourcepub fn new(text: String, font_size: u16, font_name: Option<&str>) -> Self
pub fn new(text: String, font_size: u16, font_name: Option<&str>) -> Self
Examples found in repository?
examples/basic.rs (line 55)
43fn main() {
44 let mut my_app = MyApp;
45
46 let mut pd_sdl: PgSdl = PgSdl::init("Benday", 1200, 720, Some(60), true, Colors::SKY_BLUE);
47
48 pd_sdl
49 .add_widget(
50 "button",
51 Box::new(Button::new(
52 Colors::ROYAL_BLUE,
53 rect!(500, 500, 200, 100),
54 Some(9),
55 Some(Text::new("Auto !".to_string(), 16, None)),
56 )),
57 )
58 .add_widget(
59 "slider",
60 Box::new(Slider::new(
61 Colors::ROYAL_BLUE,
62 rect!(110, 220, 200, 100),
63 Some(9),
64 SliderType::Continuous {
65 display: None,
66 default_value: 0.5,
67 },
68 )),
69 )
70 .add_widget(
71 "text input",
72 Box::new(TextInput::new(
73 Colors::WHITE,
74 rect!(222, 295, 200, 100),
75 Some(9),
76 Some(Text::new("Auto !".to_string(), 16, None)),
77 )),
78 );
79
80 pd_sdl.run(&mut my_app);
81}
More examples
examples/spring_test/main.rs (line 121)
92fn main() {
93 let my_app = &mut PhysicsApp {
94 masses: Vec::from([
95 Mass::new(Vec2::new(0.0, 0.0), 0.0, 0.0, Colors::BLACK, true),
96 Mass::new(Vec2::new(600.0, 400.0), 1.0, 20.0, Colors::ORANGE, true),
97 Mass::new(Vec2::new(600.0, 450.0), 1.0, 15.0, Colors::ORANGE, true),
98 Mass::new(Vec2::new(600.0, 550.0), 5.0, 25.0, Colors::RED, false),
99 Mass::new(Vec2::new(800.0, 200.0), 1.0, 20.0, Colors::GREEN, true),
100 Mass::new(Vec2::new(800.0, 650.0), 1.0, 20.0, Colors::MAGENTA, false),
101 ]),
102 rods: Vec::from([
103 Rod::new(3, 4, 250.0, 10.0, Colors::BROWN),
104 Rod::new(3, 5, 50.0, 10.0, Colors::BROWN),
105 ]),
106 springs: Vec::from([
107 Spring::new(0, 0, 1.0, 0.5, 0.0, 20.0, Colors::WHITE),
108 Spring::new(2, 3, 0.5, 0.2, 150.0, 40.0, Colors::BEIGE),
109 ]),
110 motors: Vec::from([Motor::new(1, 2, 0.4, Colors::LIGHT_GREY)]),
111 };
112
113 let mut app: PgSdl = PgSdl::init("Spring test", 1200, 720, Some(60), true, Colors::SKY_BLUE);
114 app.add_widgets(HashMap::from([
115 (
116 "play",
117 Box::new(Button::new(
118 Colors::ORANGE,
119 rect!(300, 35, 120, 50),
120 Some(9),
121 Some(Text::new("Start".to_string(), 18, None)),
122 )) as Box<dyn Widget>,
123 ),
124 (
125 "speed",
126 Box::new(Slider::new(
127 Colors::ORANGE,
128 rect!(500, 50, 200, 30),
129 Some(20),
130 SliderType::Continuous {
131 default_value: 0.0,
132 display: Some(Box::new(|value| format!("{:.2}", value))),
133 },
134 )),
135 ),
136 ]));
137 app.run(my_app);
138}
Trait Implementations§
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