pub struct Rectangle {
pub color: Color,
pub corner_radius: CornerRadius,
}Fields§
§color: Color§corner_radius: CornerRadiusImplementations§
Source§impl Rectangle
impl Rectangle
Sourcepub fn new() -> Self
pub fn new() -> Self
Examples found in repository?
examples/basic_rectangle.rs (line 22)
9fn main() {
10 // Create the clay instance
11 let clay = Clay::new((800., 600.).into());
12
13 // Begin the layout
14 clay.begin();
15
16 // Adds a red rectangle with a corner radius of 5.
17 // The Layout makes the rectangle have a width and height of 50.
18 clay.with(
19 [
20 Id::new("red_rectangle"),
21 Layout::new().width(fixed!(50.)).height(fixed!(50.)).end(),
22 Rectangle::new()
23 .color((0xFF, 0x00, 0x00).into())
24 .corner_radius(CornerRadius::All(5.))
25 .end(),
26 ],
27 |_| {},
28 );
29
30 // Return the list of render commands of your layout
31 let render_commands = clay.end();
32
33 for command in render_commands {
34 println!("Id of the element: {}", command.id); // Note: Ids are in fact numbers generated by Clay
35 println!("Bounding box: {:?}", command.bounding_box);
36 println!("Type and config: {:?}", command.config);
37 }
38}Sourcepub fn color(&mut self, color: Color) -> &mut Self
pub fn color(&mut self, color: Color) -> &mut Self
Examples found in repository?
examples/basic_rectangle.rs (line 23)
9fn main() {
10 // Create the clay instance
11 let clay = Clay::new((800., 600.).into());
12
13 // Begin the layout
14 clay.begin();
15
16 // Adds a red rectangle with a corner radius of 5.
17 // The Layout makes the rectangle have a width and height of 50.
18 clay.with(
19 [
20 Id::new("red_rectangle"),
21 Layout::new().width(fixed!(50.)).height(fixed!(50.)).end(),
22 Rectangle::new()
23 .color((0xFF, 0x00, 0x00).into())
24 .corner_radius(CornerRadius::All(5.))
25 .end(),
26 ],
27 |_| {},
28 );
29
30 // Return the list of render commands of your layout
31 let render_commands = clay.end();
32
33 for command in render_commands {
34 println!("Id of the element: {}", command.id); // Note: Ids are in fact numbers generated by Clay
35 println!("Bounding box: {:?}", command.bounding_box);
36 println!("Type and config: {:?}", command.config);
37 }
38}Sourcepub fn corner_radius(&mut self, corner_radius: CornerRadius) -> &mut Self
pub fn corner_radius(&mut self, corner_radius: CornerRadius) -> &mut Self
Examples found in repository?
examples/basic_rectangle.rs (line 24)
9fn main() {
10 // Create the clay instance
11 let clay = Clay::new((800., 600.).into());
12
13 // Begin the layout
14 clay.begin();
15
16 // Adds a red rectangle with a corner radius of 5.
17 // The Layout makes the rectangle have a width and height of 50.
18 clay.with(
19 [
20 Id::new("red_rectangle"),
21 Layout::new().width(fixed!(50.)).height(fixed!(50.)).end(),
22 Rectangle::new()
23 .color((0xFF, 0x00, 0x00).into())
24 .corner_radius(CornerRadius::All(5.))
25 .end(),
26 ],
27 |_| {},
28 );
29
30 // Return the list of render commands of your layout
31 let render_commands = clay.end();
32
33 for command in render_commands {
34 println!("Id of the element: {}", command.id); // Note: Ids are in fact numbers generated by Clay
35 println!("Bounding box: {:?}", command.bounding_box);
36 println!("Type and config: {:?}", command.config);
37 }
38}Sourcepub fn end(&self) -> TypedConfig
pub fn end(&self) -> TypedConfig
Examples found in repository?
examples/basic_rectangle.rs (line 25)
9fn main() {
10 // Create the clay instance
11 let clay = Clay::new((800., 600.).into());
12
13 // Begin the layout
14 clay.begin();
15
16 // Adds a red rectangle with a corner radius of 5.
17 // The Layout makes the rectangle have a width and height of 50.
18 clay.with(
19 [
20 Id::new("red_rectangle"),
21 Layout::new().width(fixed!(50.)).height(fixed!(50.)).end(),
22 Rectangle::new()
23 .color((0xFF, 0x00, 0x00).into())
24 .corner_radius(CornerRadius::All(5.))
25 .end(),
26 ],
27 |_| {},
28 );
29
30 // Return the list of render commands of your layout
31 let render_commands = clay.end();
32
33 for command in render_commands {
34 println!("Id of the element: {}", command.id); // Note: Ids are in fact numbers generated by Clay
35 println!("Bounding box: {:?}", command.bounding_box);
36 println!("Type and config: {:?}", command.config);
37 }
38}Trait Implementations§
Source§impl From<Clay_RectangleElementConfig> for Rectangle
impl From<Clay_RectangleElementConfig> for Rectangle
Source§fn from(value: Clay_RectangleElementConfig) -> Self
fn from(value: Clay_RectangleElementConfig) -> Self
Converts to this type from the input type.
Source§impl From<Rectangle> for Clay_RectangleElementConfig
impl From<Rectangle> for Clay_RectangleElementConfig
impl Copy for Rectangle
Auto Trait Implementations§
impl Freeze for Rectangle
impl RefUnwindSafe for Rectangle
impl Send for Rectangle
impl Sync for Rectangle
impl Unpin for Rectangle
impl UnwindSafe for Rectangle
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