Struct Rectangle

Source
pub struct Rectangle {
    pub color: Color,
    pub corner_radius: CornerRadius,
}

Fields§

§color: Color§corner_radius: CornerRadius

Implementations§

Source§

impl Rectangle

Source

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}
Source

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}
Source

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}
Source

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 Clone for Rectangle

Source§

fn clone(&self) -> Rectangle

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Rectangle

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Rectangle

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl From<Clay_RectangleElementConfig> for Rectangle

Source§

fn from(value: Clay_RectangleElementConfig) -> Self

Converts to this type from the input type.
Source§

impl From<Rectangle> for Clay_RectangleElementConfig

Source§

fn from(value: Rectangle) -> Self

Converts to this type from the input type.
Source§

impl Copy for Rectangle

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.